[Bug target/56110] Sub-optimal code: unnecessary CMP after AND
tilman@code-monkey.de
gcc-bugzilla@gcc.gnu.org
Sat Feb 16 16:49:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56110
--- Comment #1 from Tilman Sauerbeck <tilman@code-monkey.de> 2013-02-16 16:49:34 UTC ---
Changing the literal in the test function so that it fits in 8 bits makes gcc
go with the TST instruction instead of AND+CMP:
unsigned f2 (unsigned x, unsigned m)
{
if (m & 0x80)
x >>= 8;
return x;
}
=>
tst r1, #128
movne r0, r0, lsr #8
bx lr
So I guess I shouldn't ask why gcc generates AND+CMP instead of ANDS, but why
it chooses not to use TST.
More information about the Gcc-bugs
mailing list