[llvm-bugs] [Bug 51086] New: wrong code at -O3 on x86_64-linux-gnu

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Jul 13 21:20:58 PDT 2021


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

            Bug ID: 51086
           Summary: wrong code at -O3 on x86_64-linux-gnu
           Product: clang
           Version: trunk
          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. clang-12 works fine.


$ clang-trunk -v
clang version 13.0.0 (https://github.com/llvm/llvm-project.git
20176bc7dd3f431db4c3d59b51a9f53d52190c82)
Target: x86_64-unknown-linux-gnu
Thread model: posix


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


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


$ cat abc.c
int a, b;
static int c = 92;
long d;
short(e)(f) { return f; }
long g() {
  short h;
  int i = d >= 0;
  for (; b > -26; --b) {
    if (i)
      continue;
    for (; i - 30; i--) {
      h = a << c;
      if (h)
        return 7;
    }
  }
}
int main() {
  g();
  if (e(0))
    c++;
  printf("%d\n", b);
}

-- 
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/20210714/cdb8d5f9/attachment.html>


More information about the llvm-bugs mailing list