https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89059
Bug ID: 89059
Summary: Once we emit switchconf tables, we don't optimize them
anymore
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: jakub at gcc dot gnu.org
Target Milestone: ---
For the following testcase:
static inline int
foo (int a)
{
switch (a)
{
case 0:
return 0;
case 1 ... 3:
return 1;
case 4 ... 10:
return -1;
default:
return 42;
}
}
int
bar (int a)
{
if (a < 0 || a > 3)
__builtin_unreachable ();
return foo (a);
}
we emit unnecessary code, I understand we want to run switchconf early, so that
inliner can already see simple code, but in this case we don't know value
ranges of the switch condition. So, I wonder if we couldn't mark the CSWTCH
tables with some attribute or whatever and in late GIMPLE reconsider if we
can't emit something simpler, whether it is a bit test or simple comparison.
If we commit to a bit test, I wonder if we are able to simplify it later too.