https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111408

            Bug ID: 111408
           Summary: [14 Regression] Wrong code at -O2/3 on
                    x86_64-linux-gnu since r14-2866-ge68a31549d9
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: shaohua.li at inf dot ethz.ch
  Target Milestone: ---

gcc at -O2/s produced the wrong code.

Bisected to r14-2866-ge68a31549d9

Compiler explorer: https://godbolt.org/z/secjqP8ao

$ cat a.c
int printf(const char *, ...);
int a, b, c, d;
short e;
int f() {
  c = a % (sizeof(int) * 8);
  if (b & 1 << c)
    return -1;
  return 0;
}
int main() {
  for (; e != 1; e++) {
    int g = f();
    if (g + d - 9 + d)
      continue;
    for (;;)
      __builtin_abort();
  }
}
$
$ gcc -O0 a.c && ./a.out
$
$ gcc -O2 a.c && ./a.out
[2]    1281121 abort      ./a.out
$

Reply via email to