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: unassignedb...@nondot.org
          Reporter: chenmindong...@gmail.com
                CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to