[llvm] r282541 - [LoopSimplify] When simplifying phis in loop-simplify, do it only if it preserves LCSSA form.
Michael Zolotukhin via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 27 14:03:45 PDT 2016
Author: mzolotukhin
Date: Tue Sep 27 16:03:45 2016
New Revision: 282541
URL: http://llvm.org/viewvc/llvm-project?rev=282541&view=rev
Log:
[LoopSimplify] When simplifying phis in loop-simplify, do it only if it preserves LCSSA form.
Modified:
llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp
llvm/trunk/test/Transforms/LoopUnroll/rebuild_lcssa.ll
Modified: llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp?rev=282541&r1=282540&r2=282541&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LoopSimplify.cpp Tue Sep 27 16:03:45 2016
@@ -622,8 +622,10 @@ ReprocessLoop:
(PN = dyn_cast<PHINode>(I++)); )
if (Value *V = SimplifyInstruction(PN, DL, nullptr, DT, AC)) {
if (SE) SE->forgetValue(PN);
- PN->replaceAllUsesWith(V);
- PN->eraseFromParent();
+ if (!PreserveLCSSA || LI->replacementPreservesLCSSAForm(PN, V)) {
+ PN->replaceAllUsesWith(V);
+ PN->eraseFromParent();
+ }
}
// If this loop has multiple exits and the exits all go to the same
Modified: llvm/trunk/test/Transforms/LoopUnroll/rebuild_lcssa.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopUnroll/rebuild_lcssa.ll?rev=282541&r1=282540&r2=282541&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LoopUnroll/rebuild_lcssa.ll (original)
+++ llvm/trunk/test/Transforms/LoopUnroll/rebuild_lcssa.ll Tue Sep 27 16:03:45 2016
@@ -151,3 +151,40 @@ L1_latch:
exit:
ret i8 0
}
+
+; CHECK-LABEL: @foo5
+define void @foo5() {
+entry:
+ br label %outer
+
+outer:
+ br label %inner1
+
+; CHECK: inner1:
+; CHECK-NOT: br i1 true
+; CHECK: br label %inner2_indirect_exit
+inner1:
+ br i1 true, label %inner2_indirect_exit.preheader, label %inner1
+
+inner2_indirect_exit.preheader:
+ br label %inner2_indirect_exit
+
+inner2_indirect_exit:
+ %a = phi i32 [ %b, %inner2_latch ], [ undef, %inner2_indirect_exit.preheader ]
+ indirectbr i8* undef, [label %inner2_latch, label %inner3, label %outer_latch]
+
+inner2_latch:
+ %b = load i32, i32* undef, align 8
+ br label %inner2_indirect_exit
+
+inner3:
+ %a.lcssa = phi i32 [ %a.lcssa, %inner3 ], [ %a, %inner2_indirect_exit ]
+ br i1 true, label %outer_latch.loopexit, label %inner3
+
+outer_latch.loopexit:
+ %a.lcssa.lcssa = phi i32 [ %a.lcssa, %inner3 ]
+ br label %outer_latch
+
+outer_latch:
+ br label %outer
+}
More information about the llvm-commits
mailing list