Issue 66176
Summary Wrong code at -O2/3 on x86_64 (recent regression since d01aec4)
Labels new issue
Assignees
Reporter shao-hua-li
    clang at -O2/3 produced the wrong code.

Bisected to d01aec4c769d50fb92e86decd41d077c94105841, which was committed by @nikic 

Compiler explorer: https://godbolt.org/z/9bhhc5rGM

```console
% cat a.c
int printf(const char *, ...);
int a, c;
long b, g;
static int d[1] = {5};
unsigned h;
long *i() {
  c = 0;
  for (; c <= 2; c++) {
 for (;;) {
      char e[1] = {97};
      char f = *e + c;
 
      if (d[f - 97]) {
        int *j[] = {&d[0], &d[0]};
 h++;
        break;
      }
      return &b;
    }
    for (; h <= 2;)
      return &g;
  }
  for (;;)
    ;
}
int main() {
  i();
  printf("%d\n", a);
}
%
% clang -O0 a.c && ./a.out
0
% clang -O2 a.c
% ./a.out
(Timeout)
%
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to