C language:
if(a < b) {
b += a;
}
Assume $t1 = 1, $t2 = b.
MIPS assembly:
SLT $t0, $t1, $t2
BEQ $t0, $0, Label
ADD $t2, $t2, $t1
Label: ...
But, it can be reached different way:
SUB $t0, $t1, $t2
BGEZ $t0, Label
ADD $t2, $t2, $t1
Label: ...
My question:
It can be proved that every SLT
instruction can be replaced by some form of ADD/SUB instructions. So, what's the key usage of instruction SLT
? Can it be carry out detection as shown here or something else that I missed?
Sorry for my English.