[llvm-bugs] [Bug 49306] New: Loop-interchange : Some triangular loop nests are interchanged

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Feb 22 01:57:00 PST 2021


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: unassignedbugs at nondot.org
          Reporter: flemairen6 at gmail.com
                CC: llvm-bugs at lists.llvm.org

$ 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210222/c96805c8/attachment.html>


More information about the llvm-bugs mailing list