https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114086

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
And the rest boils down to what code to generate for
bool
foo (int x)
{
  return ((682 >> x) & 1);
}
Both that and switch from the #c0 testcase boil down to
  _1 = 682 >> x_2(D);
  _3 = (_Bool) _1;
or
  _6 = 682 >> _4;
  _8 = (_Bool) _6;
in GIMPLE dump.  Now, for the foo above, gcc emits
        movl    $682, %eax
        btl     %edi, %eax
        setc    %al
        ret
and clang emits the same:
        movl    $682, %eax                      # imm = 0x2AA
        btl     %edi, %eax
        setb    %al
        retq
Though, e.g. clang 14 emitted
        movl    %edi, %ecx
        movl    $682, %eax                      # imm = 0x2AA
        shrl    %cl, %eax
        andb    $1, %al
        retq
which is longer, dunno what is faster.

Reply via email to