https://bugs.llvm.org/show_bug.cgi?id=52379

            Bug ID: 52379
           Summary: wrong code at -O1, -O2, -O3 (but -Os) on
                    x86_64-linux-gnu
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedb...@nondot.org
          Reporter: zhendong...@inf.ethz.ch
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org

This appears to be a recent regression.

[508] % clangtk -v
clang version 14.0.0 (https://github.com/llvm/llvm-project.git
8cabd8f0d26c3cff03faec9b1cea974f08618d6d)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/suz-local/opfuzz/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
[509] % 
[509] % clangtk -O0 small.c; ./a.out
[510] % 
[510] % clangtk -O1 small.c
[511] % ./a.out
Segmentation fault
[512] % 
[512] % cat small.c
int printf(const char *, ...);
int a = 354757809, b[2], c, d = 147639773, e, n = 2000;
short f = -25324;
long g;
int main() {
  int h = a, k = ~d, m = 0;
  a = ~h;
  if (a > 3)
    goto L2;
  a = h;
  --d;
  e = d;
L1:
  d = ~(~48988294629 & ~d * (~48988294629 | ~e));
  a = (h | d) ^ ~(e | f) ^ (a - 48988294629);
  unsigned l;
  if (k)
    if (a > 1523073808)
      c++;
  if (a <= 1523073808)
    l = d;
  if (a >= 1523073808) {
    m = a;
    while (a > 1523073808)
      ;
  }
  a = m;
L2:
  a = l;
  if (m)
    g = ~a;
  if (g > 4073172680703UL) {
    printf("%d\n", b[n]);
    goto L1;
  }
  return 0;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to