[Bug tree-optimization/58073] Suboptimal optimisation of ((x & 0x70) == 0x00 || (x & 0x70) == 0x10 || (x & 0x70) == 0x20) on x86_64
dhowells at redhat dot com
gcc-bugzilla@gcc.gnu.org
Wed Jul 27 08:24:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58073
--- Comment #5 from dhowells at redhat dot com <dhowells at redhat dot com> ---
There's a further potential optimisation. If shift is large enough that the
bits under test are outside of the LSB, the TESTB changes to a TESTL at the
same address:
Shift 2:
0: f6 07 1c testb $0x1c,(%rdi)
3: 0f 94 c0 sete %al
6: c3 retq
Shift 10:
0: f7 07 00 1c 00 00 testl $0x1c00,(%rdi)
6: 0f 94 c0 sete %al
9: c3 retq
Shift 18:
0: f7 07 00 00 1c 00 testl $0x1c0000,(%rdi)
6: 0f 94 c0 sete %al
9: c3 retq
However, one could do a TESTW or a TESTB instead with a smaller immediate value
and a displaced address.
More information about the Gcc-bugs
mailing list