This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/58073] Suboptimal optimisation of ((x & 0x70) == 0x00 || (x & 0x70) == 0x10 || (x & 0x70) == 0x20) on x86_64
- From: "dhowells at redhat dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 27 Jul 2016 08:24:11 +0000
- Subject: [Bug tree-optimization/58073] Suboptimal optimisation of ((x & 0x70) == 0x00 || (x & 0x70) == 0x10 || (x & 0x70) == 0x20) on x86_64
- Auto-submitted: auto-generated
- References: <bug-58073-4@http.gcc.gnu.org/bugzilla/>
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.