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

            Bug ID: 49306
           Summary: Loop-interchange : Some triangular loop nests are
                    interchanged
           Product: tools
           Version: 11.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: opt
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

$ clang -Os -mllvm -enable-loopinterchange=true traingular_fail.c && ./a.out
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

$ clang -Os -mllvm -enable-loopinterchange=false triangular_fail.c && ./a.out
0 2 7 83 0 0 9 43 0 0 0 0 0 0 0 0


$ cat triangular_fail.c
#include <stdio.h>

int foo() {

  int A[4][4] = {{ 0, 0, 0, 0},
                { 0, 0, 0, 0},
                { 0, 0, 0, 0},
                { 0, 0, 0, 0}};
  int B[4][4] = {{ 16, 2, 7, 83},
                { 35, 8, 9, 43},
                { 47, 123, 32, 0},
                { 21, 11, 19, 29}};
  for (int i = 0; i < 4; ++i)
    for (int j = 0; j < i; ++j)
      A[j][i] = B[j][i];

  for (int i = 0; i < 4; ++i)
    for (int j = 0; j < 4; j++)
      printf("%d ", A[i][j]);

  printf("\n");

  return 0;
}

int main() {
  foo();
 return 0;
}

LoopInterchange does not detect the issue with the operation `j<i` in the inner
loop, thus, breaking the program correctness.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to