[PATCH] D22630: Loop rotation

Aditya Kumar via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 21 08:40:57 PDT 2016


hiraditya created this revision.
hiraditya added reviewers: hfinkel, sanjoy.
hiraditya added subscribers: mzolotukhin, sebpop, jlebar, llvm-commits.
Herald added a subscriber: sanjoy.

This patch implements Loop Rotation Pass:

 1. Canonicalize loop latch to have only one successor.
 2. Clone all the BBs which are exiting the loop.
 3. Adjust phi of cloned BBs
 4. Add phi to the new loop header
 5. Update DOM

With this patch all the basic blocks which are exiting the loop can be copied during rotation. This is helpful for passes like gvn/licm which can now remove loop invariant code
because some computations (which might not dominate all the basic blocks of loop) can now be PRE'd as they are available outside of the loop (due to loop rotation).

Several test cases have been added to exercise loop rotation for different loop bodies.

Relevant test case to demonstrate loop rotation can help gvn.
llvm/test/Transforms/LoopVectorize/vect.omp.persistence.ll

This patch depends on https://reviews.llvm.org/D22558, which is used to clone SEME.

Worked in collaboration with Sebastian Pop


https://reviews.llvm.org/D22630

Files:
  llvm/include/llvm/Analysis/LoopInfo.h
  llvm/include/llvm/Analysis/LoopInfoImpl.h
  llvm/include/llvm/Transforms/Utils/Cloning.h
  llvm/lib/Analysis/LoopInfo.cpp
  llvm/lib/Transforms/Scalar/LoopRotation.cpp
  llvm/lib/Transforms/Utils/CloneFunction.cpp
  llvm/test/Analysis/GlobalsModRef/memset-escape.ll
  llvm/test/Analysis/ScalarEvolution/2012-03-26-LoadConstant.ll
  llvm/test/Transforms/LoopRotate/alloca.ll
  llvm/test/Transforms/LoopRotate/basic.ll
  llvm/test/Transforms/LoopRotate/dbgvalue.ll
  llvm/test/Transforms/LoopRotate/loop-rotate-0.ll
  llvm/test/Transforms/LoopRotate/loop-rotate-1.ll
  llvm/test/Transforms/LoopRotate/loop-rotate-10.ll
  llvm/test/Transforms/LoopRotate/loop-rotate-2.ll
  llvm/test/Transforms/LoopRotate/loop-rotate-3.ll
  llvm/test/Transforms/LoopRotate/loop-rotate-4.ll
  llvm/test/Transforms/LoopRotate/loop-rotate-5.ll
  llvm/test/Transforms/LoopRotate/loop-rotate-6.ll
  llvm/test/Transforms/LoopRotate/loop-rotate-7.ll
  llvm/test/Transforms/LoopRotate/loop-rotate-8.ll
  llvm/test/Transforms/LoopRotate/loop-rotate-9.ll
  llvm/test/Transforms/LoopRotate/multiple-exits-merge-phi.ll
  llvm/test/Transforms/LoopRotate/multiple-exits.ll
  llvm/test/Transforms/LoopRotate/nosimplifylatch.ll
  llvm/test/Transforms/LoopRotate/phi-duplicate.ll
  llvm/test/Transforms/LoopRotate/pr7447.ll
  llvm/test/Transforms/LoopRotate/preserve-loop-simplify.ll
  llvm/test/Transforms/LoopRotate/simplifylatch.ll
  llvm/test/Transforms/LoopSimplify/ashr-crash.ll
  llvm/test/Transforms/LoopVectorize/vect.omp.persistence.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D22630.64898.patch
Type: text/x-patch
Size: 83006 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160721/100fd6ec/attachment.bin>


More information about the llvm-commits mailing list