https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117572
Bug ID: 117572
Summary: Missing optimization after SCCP due to rewriting for
overflow
Product: gcc
Version: 15.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
Target Milestone: ---
Take:
```
int printf(const char *, ...);
int a[6];
int b, d, i, j, l, m, n;
char *c;
int f[8][8][4];
int *g = &d;
char p[11];
int main() {
short q[6];
int k = 0;
for (; k < 2; k++) {
{
char o[3];
int e = 53;
char *h = o;
c = p;
while (e)
*c++ = e /= 10;
while (c != p)
*h++ = *--c;
*h++ = '\0';
n = h - o;
}
q[n - 2] = 1;
}
*g = q[1];
printf("%d\n", d);
l = 0;
for (; l < 10; l++)
if (m)
printf("index = \n");
i = 0;
for (; i < 7; i++) {
j = 0;
for (; j < 7; j++)
b = a[b];
}
j = 0;
for (; j < 8; j++) {
l = 0;
for (; l < 4; l++)
b = a[b ^ f[i][j][l]];
}
}
```
At -O3 at .optimized we have:
```
_386 = (sizetype) &o;
_387 = (sizetype) &MEM <char[11]> [(void *)&p + 2B];
_388 = _386 + _387;
_389 = (sizetype) &p;
_390 = _388 - _389;
h_391 = (char *) _390;
```
but that is `(&o + (&p + 2)) - &p` or rather `&o + 2`.
I have not looked into why this is missed yet. But this definitely shows up a
few times. It definitely hurts scoped conflicts too.