Hi Richard, > Any compare can be done in at most 2 instructions: > > void doit(void); > void f(long long a) > { > if (a <= 1) > doit(); > } > > f: > cmp r0, #2 > sbcs r3, r1, #0 > blt .L4
> Well, this one requires that you be able to add 1 to an input and for that > input to not overflow. But you're right that I should be using this sequence > for LT (not LE). And for GE. For LE and GT swap operands and condition. You can safely increment the immediate since small immediates that fit CMP have no chance of overflowing and large immediates have to be split off anyway (and then are treated like register variants). Cheers, Wilco