Issue 209010
Summary [Clang] Wrong code at -O2/3 on x86_64-linux_gnu
Labels clang
Assignees
Reporter zxt5
    Compiler Explorer: https://godbolt.org/z/bPK3c746h

- fails: trunk
- works: 22.1.0 and earlier

small.c
```c
#include <stdio.h>
short a, h, b, c;
int d = 9, e;
int main() {
  e = a;
  h = 0;
  for (; h <= 2; h++) {
    int f = e | 5;
    b = 2;
    for (; b >= 0; b--)
      d &= (++c ^ f) < 58593;
 }
  printf("%d\n", d);
}
```

```
$ clang-trunk -v
clang version 23.0.0git (https://github.com/llvm/llvm-project.git e62c0cb076fbcb70752530571726944648a48829)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /data/x27zhou/compiler-nightly/install/llvm/bin
Build config: +assertions
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12
Candidate multilib: .;@m64
Selected multilib: .;@m64
Found CUDA installation: /usr/local/cuda, version 12.3
$ clang-trunk -O0 small.c && ./a.out  
1
$ clang-trunk -O3 small.c && ./a.out
0
```


_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to