https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128050
Bug ID: 128050
Summary: `X != C1 ? abs(X) : C2` match pattern does not match
when the inner X has a cast involved
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: easyhack, missed-optimization
Severity: enhancement
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Testcase:
```
unsigned f(unsigned a)
{
signed b = a;
if (a == 0)
return 0;
b = __builtin_abs (b);
return b;
}
unsigned f1(unsigned a)
{
return a ? __builtin_abs(a) : 0;
}
```
The convert from unsigned to signed gets in the way.