https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112310
Bug ID: 112310
Summary: [14 Regression] Wrong code at -O2/3 on
x86_64-linux-gnu since r14-1161-g5476de2618f
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: shaohua.li at inf dot ethz.ch
CC: rguenth at gcc dot gnu.org
Target Milestone: ---
gcc at -O2/3 produces the wrong code.
Bisected to r14-1161-g5476de2618f
Compiler explorer: https://godbolt.org/z/Kb4qMKE9K
$ cat a.c
int printf(const char *, ...);
short a, b;
static int c, d, e, f = -7;
char g;
int *h = &d;
int **i = &h;
int j;
short(k)(int l) { return l >= 2 ? 0 : l; }
int(m)(int l, int n) { return l < -2147483647 / n ? l : l * n; }
void o() { &c; }
int main() {
{
int p;
for (; g <= 3; g++) {
for (; c; c++)
;
a = 2;
for (; a <= 7; a++) {
short *r = &b;
p = m(*h, 2022160547);
unsigned q = 2022160547;
e = p * q;
*r ^= e;
j = k(c + 3);
**i = 0;
}
*i = &f;
}
}
printf("%d\n", b);
}
$
$ gcc -O0 a.c && ./a.out
-3189
$ gcc -O2 a.c && ./a.out
0
$