[llvm-bugs] [Bug 30480] New: [LoopInterchange] Calls with side effects should prevent loop interchange.

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Sep 21 14:52:08 PDT 2016


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

            Bug ID: 30480
           Summary: [LoopInterchange] Calls with side effects should
                    prevent loop interchange.
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: mcrosier at codeaurora.org
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Given the below test case:

void foo(unsigned a);
unsigned A[100][100];

void interchange_w_call() {
  for (int i = 0; i < 100; ++i)
    for(int j = 0; j < 100; ++j) {
      foo(A[j][i]);
      A[j][i] = i * j;
    }
}

The loop interchange pass will interchange this loop.  However, the interchange
will change the order of the values passed to foo().  If foo() has side
effects, I believe this optimization is legal.

Compile with debug output:
 clang loopinterchange.c -S -o /dev/null -O3 -mllvm -enable-loopinterchange
-mllvm -debug-only=loop-interchange

Calling populateWorklist on Func: interchange_w_call Loop: %for.cond1.preheader
Worklist size = 1
Processing LoopList of size = 2
Found 2 Loads and Stores to analyze
Found anti dependency between Src and Dst
 Src:  %0 = load i32, i32* %arrayidx6, align 4, !tbaa !1
 Dst:  store i32 %2, i32* %arrayidx6, align 4, !tbaa !1
Processing Inner Loop Id = 1 and OuterLoopId = 0
Checking if loops are tightly nested
Checking instructions in Loop header and Loop latch
Loops are perfectly nested
Loops are legal to interchange
Cost = -1
Calling Split Inner Loop
splitInnerLoopLatch done
Output of splitInnerLoopHeader InnerLoopHeaderSucc & InnerLoopHeader
splitInnerLoopHeader done
adjustLoopBranches called
Loops interchanged

-- 
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/20160921/8871d1e9/attachment.html>


More information about the llvm-bugs mailing list