https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118483
Bug ID: 118483
Summary: Missed optimization due to cast being used more than
once
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Take:
```
int d;
int f(int b)
{
int e = b == 0;
d = e;
int l = b != 0;
if (l == e)
__builtin_abort ();
}
```
The call to abort should be eliminated but currently is not.
I accidently noticed this while fixing PR 102705. I was (manually) replacing
`b >= 2 ? 0 : 1 >> b` with `(b == 0)` since those 2 expressions are the same
(with taking into account the undefined behavior for `b >= sizeof(int)` cases).
It just happens simplifying `1 >> b` into `(type)b == 0` in the case of PR
102705 works because of an extra cast to char in there ...