[llvm-bugs] [Bug 38260] New: clang miscompiles with "-newgvn" at -O2 on valid code

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Jul 21 23:14:50 PDT 2018


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

            Bug ID: 38260
           Summary: clang miscompiles with "-newgvn" at -O2 on valid code
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: helloqirun at gmail.com
                CC: llvm-bugs at lists.llvm.org

clang-r312400: first working build
clang-r312401: next failing build


$ clang-trunk abc.c ; ./a.out
0


$ clang-trunk -mllvm -enable-newgvn -O2 abc.c ; ./a.out
-1


$ clang-trunk -v
clang version 7.0.0 (trunk 337641)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin

$ cat abc.c
int printf(char *, ...);
long a;
int g, h, i, k, l, b, d;
char m, p, q, s, j;
struct {
  int n;
} r = {9}, o;
short f;
int __attribute__((noinline)) t() {
  volatile int c = 0;
  return a;
}
char(u)(char v, char w) { return v + w; }
char(x)(char v, char w) { return v + w; }
static unsigned y() {
  int e = 0;
  for (; e != 5; e++) {
    if (e && r.n)
      --p;
    b = i == 0 ? 0 : h / i;
    k = b;
    if (b) {
      volatile int c = 0;
    }
    if (a)
      g &= t();
    j = a = f * m;
    if (u(r.n && d, d))
      for (; s <= 7; s = u(s, 5))
        ;
    for (; q < 9; q = x(q, 3))
      r = o;
    l--;
  }
}
int main() {
  y();
  printf("%d\n", p);
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180722/51a47a87/attachment-0001.html>


More information about the llvm-bugs mailing list