https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127360
Bug ID: 127360
Summary: missed tree-switch-conversion
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: gjl at gcc dot gnu.org
Target Milestone: ---
Created attachment 65574
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65574&action=edit
switch.c: C test case
int select16 (int x)
{
switch (x)
{
case -1: return x;
case 0: return x + 1;
case 1: return x - 1;
case 2: return 7;
case 3: return 6;
case 4: return 5;
case 5: return 2 * x;
case 6: return -x;
case 7: return x;
}
return 0;
}
int select16_c (int x)
{
switch (x)
{
case -1: return -1;
case 0: return 1;
case 1: return 0;
case 2: return 7;
case 3: return 6;
case 4: return 5;
case 5: return 10;
case 6: return -6;
case 7: return 7;
}
return 0;
}
When compiled with
$ gcc -O2 -S
then select16_c() is optimized with tree-switch-conversion, whereas select16()
is not even though it is equivalent code. The .switchconv tree dump says
> Bailing out - non-invariant value from a case
I see this with current trunk and also v13 (possibly more).