Issue 58223
Summary Wrong code at -Os on x86_64-linux_gnu
Labels new issue
Assignees
Reporter shao-hua-li
    ```console
% clang-tk -v
clang version 16.0.0 (https://github.com/llvm/llvm-project.git 0c1a3da8ea1f0e024ebfd85c7532926f26c6bde5)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /zdata/shaoli/compilers/ccbuilder-compilers
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
%
% clang-tk -w -O0 a.c && ./a.out
1
% clang-tk -w -Os a.c && ./a.out
0
%
% cat a.c
void printf();
int a = 1;
int *b = &a, *c = &b;
short d;
char e, f = 1;
static int *g = &a;
static int ***h = &c;
char *i = &f;
static char *j = &e;
long k;
short l[1];
short *m;
int main() {
  int ***n = &c;
  m = l;
  for (;;) {
    d = 0;
    for (; d <= 1; d++) {
      k = ***n;
      if (m)
        *g = *j = 0;
    }
    ***n && (*i = 0);
    if (**h)
      break;
  }
  printf("%d\n", f);
}
%
```
Compiler explorer: https://godbolt.org/z/z8Gnz514T

I have reported another bug before :https://github.com/llvm/llvm-project/issues/58140, but I don't think they are the same after I did `opt-bisect-limit`.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to