sext.w

Sign extend word Pseudo-instructionRV64 only

Sets the first register to the low 32 bits of the second, sign-extended to 64 bits.

RISC-V manual: addiw

Forms

Operands

t1
Any integer register, x0 to x31, or its named alias, such as zero, t0 or t6.
t2
An integer register. It may be the same register as t1.

This example runs on RV64.

.text
li t0, 2147483649
# t0=2147483649; sext.w writes −2147483647 (0xFFFFFFFF80000001) to t2.
sext.w t2, t0