https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114086
--- Comment #5 from Jan Schultke ---
Well, it's not quite equivalent to either of the bit-shifts we've posted. To
account for shifting more than the operand size, it would be:
bool foo (int x)
{
return x > 6 ? 0 : ((85 >> x) & 1);
}
This
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114086
--- Comment #4 from Jakub Jelinek ---
But sure, confirmed for both:
int
foo (int e)
{
switch (e)
{
case 1:
case 3:
case 5:
case 7:
case 9:
case 11:
case 13:
return 1;
default:
return 0;
}
}
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114086
--- Comment #3 from Jakub Jelinek ---
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
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114086
--- Comment #2 from Jan Schultke ---
Yeah right, the actual optimal output (which clang finds) is:
> test_switch(E):
> test edi, -7
> sete al
> ret
Testing with -7 also makes sure that the 8-bit and greater are all zero.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114086
Jakub Jelinek changed:
What|Removed |Added
CC||jakub at gcc dot gnu.org
--- Comment