Issue 98139
Summary wrong code at -O{s,2,3} on x86_64-linux-gnu
Labels new issue
Assignees
Reporter zhendongsu
    It appears to be a recent regression as it doesn't reproduce with 18.1.0 and earlier.

Compiler Explorer: https://godbolt.org/z/o595xsMdb

```
[512] % clangtk -v
clang version 19.0.0git (https://github.com/llvm/llvm-project.git 765e2f9a8de27cc8fd8c75540844e9630d8229ad)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/suz-local/software/local/clang-trunk/bin
Build config: +assertions
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Candidate multilib: .;@m64
Selected multilib: .;@m64
[513] % 
[513] % clangtk -O1 small.c; ./a.out
1
[514] % clangtk -O3 small.c; ./a.out
-2
1
[515] % cat small.c
int printf(const char *, ...);
int a, b, c, e;
char d;
int main() {
  int f = 1;
  unsigned g = 1;
  for (; c < 2; c++) {
    if (g)
      b = 1;
    char h = f;
    f = ~h;
 d = ~b - ~g * (a || f);
    g = ~g;
    if (g < 1)
      break;
 if (d)
      printf("%d\n", g);
    f = e;
  }
  return 0;
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to