max

Maximum (signed)

Sets the first register to the larger of the second and third, comparing as signed.

RISC-V manual: max

Forms

  • max , ,

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.
t3
An integer register. It may be the same register as t1.

Branch free, unlike the usual blt and move

.text
li t0, 18
li t1, 5
# t0=18, t1=5; max writes 18 to t2.
max t2, t0, t1