[PATCH] D22630: Loop rotation

Michael Zolotukhin via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 26 11:52:20 PDT 2016


mzolotukhin added a comment.

Hi,

FWIW, I'm also working on a patch for loop-rotate, my goal also being to teach it to rotate loops with more complicated CFG.

As an example I use the following simple test:

  declare void @use(i32)
  
  define void @test(i32 %v) {
  entry:
    br label %for_header
  
  for_header:
    %iv = phi i32 [ 0, %entry ], [ %inc, %for_crit ]
    %inc = add nsw i32 %iv, 1
    %cmp = icmp slt i32 %iv, 1
    br i1 %cmp, label %for_crit, label %for_end
  
  for_crit:
    call void @use(i32 %iv)
    br label %for_header
  
  for_end:
    %x = phi i32 [%iv, %for_header]
    ret void
  }

This test is base on a real one, and the ultimate goal is to unroll it removing the loop completely. Currently we can't do it, because loop-rotation bails out early, and unfortunately, this patch also doesn't help here. I'll post my patch soon, and hopefully we'll be able to assemble all-best version out of two.


================
Comment at: llvm/lib/Transforms/Scalar/LoopRotation.cpp:676
@@ -675,3 @@
-    auto *SE = SEWP ? &SEWP->getSE() : nullptr;
-    LoopRotate LR(MaxHeaderSize, LI, TTI, AC, DT, SE);
-    return LR.processLoop(L);
----------------
sebpop wrote:
> Meinersbur wrote:
> > Doesn't ScalarEvolution need be updated anymore? `getLoopAnalysisUsage()` adds `SCEVAAWrapperPass` (but not `ScalarEvolution` itself?)
> The previous version of loop rotation was using the SE analysis.  Our revised loop rotation does not require SE: it only works on the CFG and DT.  There is no need to invalidate the SE, as LoopRotation adds new phi nodes, and the old phi nodes are removed.
Are you sure about that? SE also provides info about, for instance, back-edge trip-count, and this would be different for the rotated loop.


https://reviews.llvm.org/D22630





More information about the llvm-commits mailing list