https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126972
Bug ID: 126972
Summary: ranger could be taught about bitreverse
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: enhancement
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Blocks: 85316
Target Milestone: ---
Take:
```
int
f1 (unsigned char x)
{
if (x != 0 && x != 1)
return 1;
x = __builtin_bitreverse8 (x);
if (((signed char)x) > 0)
__builtin_trap();
return x;
}
unsigned f(unsigned char a)
{
a &=1;
unsigned t = __builtin_bitreverseg(a);
if (((signed char)t) > 0)
__builtin_trap();
return 0;
}
```
These f is handled because ccp/bit tracking handles bitreverse but ranger does
not handle the builtin so f1 is not handled. The very least bitmask/value could
be handled by the ranger. But also it could handle the case where there is a
couple of values (not ranges) which can be reversed.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85316
[Bug 85316] [meta-bug] VRP range propagation missed cases