Issue 179070
Summary [clang] Wrong code at -O2/3/s with -march=native on x86_64-linux_gnu
Labels clang
Assignees
Reporter zxt5
    Compiler explorer: https://godbolt.org/z/hhhsK5Mqa

```
$ cat small.c
int printf(const char *, ...);
int a(unsigned b, int c, int d) {
  int e = 1;
 while (b >> e > d) {
    e++;
    if (e > c)
      return c;
  }
 return e;
}
#define f() 0
static int g = 141283461;
unsigned char h;
unsigned short i(int *b) { return f(); }
static int k() {
  unsigned char *j = &h;
  (*j = a(43, g - 141283429, g - 141283456)) < i(&g);
}
int main() {
  k();
  printf("%d\n", h);
}
$
$ clang-trunk -O2 -march=native small.c && ./a.out
$ 34
$ clang-trunk -O0 -march=native small.c && ./a.out
$ 3
$ clang-trunk -O2 small.c && ./a.out
$ 3
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to