[llvm] r277505 - [IRCE] Preserve DomTree and LCSSA
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 2 12:31:55 PDT 2016
Author: sanjoy
Date: Tue Aug 2 14:31:54 2016
New Revision: 277505
URL: http://llvm.org/viewvc/llvm-project?rev=277505&view=rev
Log:
[IRCE] Preserve DomTree and LCSSA
This changes IRCE to "preserve" LCSSA and DomTree by recomputing them.
It still does not preserve LoopSimplify.
Modified:
llvm/trunk/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
llvm/trunk/test/Transforms/IRCE/single-access-no-preloop.ll
llvm/trunk/test/Transforms/IRCE/single-access-with-preloop.ll
Modified: llvm/trunk/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp?rev=277505&r1=277504&r2=277505&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp Tue Aug 2 14:31:54 2016
@@ -570,6 +570,7 @@ class LoopConstrainer {
Function &F;
LLVMContext &Ctx;
ScalarEvolution &SE;
+ DominatorTree &DT;
// Information about the original loop we started out with.
Loop &OriginalLoop;
@@ -590,11 +591,12 @@ class LoopConstrainer {
public:
LoopConstrainer(Loop &L, LoopInfo &LI, const LoopStructure &LS,
- ScalarEvolution &SE, InductiveRangeCheck::Range R)
+ ScalarEvolution &SE, DominatorTree &DT,
+ InductiveRangeCheck::Range R)
: F(*L.getHeader()->getParent()), Ctx(L.getHeader()->getContext()),
- SE(SE), OriginalLoop(L), OriginalLoopInfo(LI), LatchTakenCount(nullptr),
- OriginalPreheader(nullptr), MainLoopPreheader(nullptr), Range(R),
- MainLoopStructure(LS) {}
+ SE(SE), DT(DT), OriginalLoop(L), OriginalLoopInfo(LI),
+ LatchTakenCount(nullptr), OriginalPreheader(nullptr),
+ MainLoopPreheader(nullptr), Range(R), MainLoopStructure(LS) {}
// Entry point for the algorithm. Returns true on success.
bool run();
@@ -1274,6 +1276,9 @@ bool LoopConstrainer::run() {
addToParentLoopIfNeeded(PreLoop.Blocks);
addToParentLoopIfNeeded(PostLoop.Blocks);
+ DT.recalculate(F);
+ formLCSSARecursively(OriginalLoop, DT, &OriginalLoopInfo, &SE);
+
return true;
}
@@ -1444,8 +1449,9 @@ bool InductiveRangeCheckElimination::run
if (!SafeIterRange.hasValue())
return false;
+ auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
LoopConstrainer LC(*L, getAnalysis<LoopInfoWrapperPass>().getLoopInfo(), LS,
- SE, SafeIterRange.getValue());
+ SE, DT, SafeIterRange.getValue());
bool Changed = LC.run();
if (Changed) {
Modified: llvm/trunk/test/Transforms/IRCE/single-access-no-preloop.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IRCE/single-access-no-preloop.ll?rev=277505&r1=277504&r2=277505&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/IRCE/single-access-no-preloop.ll (original)
+++ llvm/trunk/test/Transforms/IRCE/single-access-no-preloop.ll Tue Aug 2 14:31:54 2016
@@ -31,12 +31,13 @@ define void @single_access_no_preloop_no
; CHECK: br i1 true, label %in.bounds, label %out.of.bounds
; CHECK: main.exit.selector:
-; CHECK-NEXT: [[continue:%[^ ]+]] = icmp slt i32 %idx.next, %n
+; CHECK-NEXT: %idx.next.lcssa = phi i32 [ %idx.next, %in.bounds ]
+; CHECK-NEXT: [[continue:%[^ ]+]] = icmp slt i32 %idx.next.lcssa, %n
; CHECK-NEXT: br i1 [[continue]], label %main.pseudo.exit, label %exit.loopexit
; CHECK: main.pseudo.exit:
-; CHECK-NEXT: %idx.copy = phi i32 [ 0, %loop.preheader ], [ %idx.next, %main.exit.selector ]
-; CHECK-NEXT: %indvar.end = phi i32 [ 0, %loop.preheader ], [ %idx.next, %main.exit.selector ]
+; CHECK-NEXT: %idx.copy = phi i32 [ 0, %loop.preheader ], [ %idx.next.lcssa, %main.exit.selector ]
+; CHECK-NEXT: %indvar.end = phi i32 [ 0, %loop.preheader ], [ %idx.next.lcssa, %main.exit.selector ]
; CHECK-NEXT: br label %postloop
; CHECK: postloop:
@@ -102,7 +103,7 @@ define void @single_access_no_preloop_wi
; CHECK: br i1 [[continue_main_loop]], label %loop, label %main.exit.selector
; CHECK: main.pseudo.exit:
-; CHECK: %idx.copy = phi i32 [ 0, %loop.preheader ], [ %idx.next, %main.exit.selector ]
+; CHECK: %idx.copy = phi i32 [ 0, %loop.preheader ], [ %idx.next.lcssa, %main.exit.selector ]
; CHECK: br label %postloop
; CHECK: loop.postloop:
Modified: llvm/trunk/test/Transforms/IRCE/single-access-with-preloop.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/IRCE/single-access-with-preloop.ll?rev=277505&r1=277504&r2=277505&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/IRCE/single-access-with-preloop.ll (original)
+++ llvm/trunk/test/Transforms/IRCE/single-access-with-preloop.ll Tue Aug 2 14:31:54 2016
@@ -53,7 +53,7 @@ define void @single_access_with_preloop(
; CHECK: br i1 [[continue_mainloop_cond]], label %loop, label %main.exit.selector
; CHECK: main.exit.selector:
-; CHECK: [[mainloop_its_left:[^ ]+]] = icmp slt i32 %idx.next, %n
+; CHECK: [[mainloop_its_left:[^ ]+]] = icmp slt i32 %idx.next.lcssa, %n
; CHECK: br i1 [[mainloop_its_left]], label %main.pseudo.exit, label %exit.loopexit
; CHECK: in.bounds.preloop:
More information about the llvm-commits
mailing list