https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112545
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Last reconfirmed| |2023-11-15
Status|UNCONFIRMED |NEW
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The first difference is that the trunk deletes:
_6 = (int) _5;
>From ccp2.
And then in forwprop2 changes:
```
_4 = _2 ^ _3;
_5 = (short unsigned int) _4;
_6 = (int) _5;
c.a = 0;
if (_5 == 0)
```
into:
```
c.a = 0;
if (_2 == _3)
```
Which is correct.
The problem DOM/ranger missed the above. It understood the ^ code for some
reason but not the == code.
And then does not remove the better ranges.
Someone who knows the ranger more than I do should look into it.
Anyways here is the code which shows my change just exposed the missed
optimization (13.2 also misses the issue):
```
static struct {
int a;
int b;
} c;
static int d, e, g;
static short f, i;
int main1() {
d = 6;
for (; d != -7; d--) {
c.a = i;
_Bool t = d <= 0;
signed short tt = d;
signed short ttt = t;
if (tt == ttt)
__builtin_unreachable();
//h(d ^ d < (0 <= 6));
if (d >= 12)
if (e) {
for (; f; ++f) g = c.b;
if (g) e = 0;
}
}
}
```