https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126523
Bug ID: 126523
Summary: `(si)~(ui)si_var` should be converted into just
~si_var
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: missed-optimization, TREE
Severity: enhancement
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Take:
```
typedef int si;
typedef unsigned ui;
si f(si a)
{
ui t = a;
t = ~t;
si a1 = t;
return a1;
}
si f1(si a)
{
return ~a;
}
int g(si a)
{
return f(a) + f1(a) == (si)(2*(~a));
}
```
g should optimize to 1 which it does on the RTL level