[llvm-bugs] [Bug 47523] New: [LoopInterchange] Interchange breaks program correctness

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Sep 14 05:54:55 PDT 2020


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

            Bug ID: 47523
           Summary: [LoopInterchange] Interchange breaks program
                    correctness
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: chenmindong120 at gmail.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 23956
  --> https://bugs.llvm.org/attachment.cgi?id=23956&action=edit
reproducer

$ clang -mllvm -enable-loopinterchange -O2 reproducer.c -w && ./a.out
11
$ clang -O0 reproducer.c -w && ./a.out
9

LoopInterchange wrongly interchanges loops in the following function "h()", in
which the order of *s=3 matters:

struct a {
  unsigned char b
} c[];
d, e, g;
f[4][9] = {5, 3};
h() {
  for (; d <= 2; d++) {
    for (e = 0; e <= 2; e++) {
      short *s = &g;
      if ((long)(f[e][d] && (*s = 3), c) % 4073709551606)
        ++*s;
    }
  }
}
main() {
  h();
  printf("%d\n", g);
}

-- 
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/20200914/7d83fced/attachment.html>


More information about the llvm-bugs mailing list