Why does gcc compile f(1199) and f(1200) differently? Why does gcc compile f(1199) and f(1200) differently? c c

Why does gcc compile f(1199) and f(1200) differently?


This has to do with the way that constant operands are encoded in the ARM instruction set. They are encoded as an (unsigned) 8-bit constant combined with a 4 bit rotate field -- the 8 bit value will be rotated by 2 times the value in that 4 bit field. So any value that fits in that form can be used as a constant argument.

The constant 1200 is 10010110000 in binary, so it can be encoded as the 8-bit constant 01001011 combined with a rotate of 4.

The constant 1199 is 10010101111 in binary, so there's no way to fit it in an ARM constant operand.