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

            Bug ID: 34093
           Summary: wrong code with "-O3 -mllvm -enable-newgvn" in both
                    32-bit and 64-bit mode on x86_64-linux-gnu
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangb...@nondot.org
          Reporter: chengnian...@gmail.com
                CC: llvm-bugs@lists.llvm.org

$ clang-trunk -v
clang version 6.0.0 (trunk 310206)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8.4
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.4
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.2
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
$ clang-trunk -mllvm -enable-newgvn -m32 -O3 -w small.c ; ./a.out
5
$ clang-trunk -m32 -O3 -w small.c ; ./a.out
0
$ cat small.c
int printf(const char *, ...);

int a, b, c, d = 5, e, f, g, h, i, j, k;
short l;
static unsigned fn1(p1) {
  int m = 0;
  a = k;
  j = 7;
  for (; j >= 0; j--) {
    l = j * 7081;
    if (l *((m ^= g | 1) == a)) {
      e &= (short)m &(d = i ^= d && 5);
      for (; f; f++)
        for (; h; h++)
          ;
    } else if (c)
      return p1;
    a |= p1;
  }
}

int main() {
  for (;;) {
    fn1(b);
    break;
  }
  printf("%d\n", d);
  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
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to