[llvm-bugs] [Bug 45360] New: wrong code at -O2 on x86_64-linux-gnu

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Mar 30 08:56:23 PDT 2020


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

            Bug ID: 45360
           Summary: wrong code at -O2 on x86_64-linux-gnu
           Product: clang
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangbugs at nondot.org
          Reporter: qrzhang at gatech.edu
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

It appears to be a recent regression. It happens at O2 and above. O1 works
fine.

$ clang-trunk -v
clang version 11.0.0 (https://github.com/llvm/llvm-project.git
f6b2c003f360c3d0dcfe13d751805643f229f79b)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin


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

$ clang-trunk -O2 abc.c ; ./a.out
Floating point exception (core dumped)


$ cat abc.c
int printf(const char *, ...);
int a, c, d, e, f, h, i;
unsigned b, k;
short g, j;
volatile int l;
int m() {
  for (;;) {
    j = 2;
    for (; j >= 0; j--)
      for (; g;)
        ;
    h = 0;
    for (; h <= 2; h++)
      f &= d;
    e = 0;
    for (; e <= 2; e++) {
      if (k)
        for (; l; l--)
          ;
      if (j) {
        i = f == 0 ? 0 : b % f;
        if (i)
          ;
        else
          return 1;
      } else {
        c = 0;
        for (; c != 5; c = c + 5)
          f = 0;
      }
    }
  }
}
int main() {
  m();
  printf("%X\n", a);
}

-- 
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/20200330/2819e870/attachment-0001.html>


More information about the llvm-bugs mailing list