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.

Reply via email to