https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101173
Bug ID: 101173
Summary: wrong code at -O3 on x86_64-linux-gnu
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: qrzhang at gatech dot edu
Target Milestone: ---
It affects gcc-8 to the trunk. Gcc-7.5.0 works.
$ gcc-trunk -v
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210622 (experimental) [master revision
f0e40ea0640:393ac5ed7d8:7822285515cd4dab86f722a9f4969b6952904a37] (GCC)
$ gcc-trunk abc.c ; ./a.out > 1.txt
$ gcc-trunk -O3 abc.c ; ./a.out > 2.txt
$ diff 1.txt 2.txt
11c11
< 0
---
> 8
$ cat abc.c
int a[6][9];
char b, c;
short d;
int e, f;
int main() {
a[1][3] = 8;
b = 1;
for (; b <= 5; b++) {
d = 0;
for (; d <= 5; d++) {
c = 0;
for (; c <= 5; c++)
a[b][c] = a[b][c + 2] & 216;
}
}
for (; e < 6; e++) {
f = 0;
for (; f < 9; f++)
printf("%d\n", a[e][f]);
}
}