[llvm] r261575 - [LoopUnrolling] Fix a bug introduced in r259869 (PR26688).
Michael Zolotukhin via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 22 13:21:47 PST 2016
Author: mzolotukhin
Date: Mon Feb 22 15:21:45 2016
New Revision: 261575
URL: http://llvm.org/viewvc/llvm-project?rev=261575&view=rev
Log:
[LoopUnrolling] Fix a bug introduced in r259869 (PR26688).
The issue was that we only required LCSSA rebuilding if the immediate
parent-loop had values used outside of it. The fix is to enaable the
same logic for all outer loops, not only immediate parent.
Modified:
llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp
llvm/trunk/test/Transforms/LoopUnroll/rebuild_lcssa.ll
Modified: llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp?rev=261575&r1=261574&r2=261575&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LoopUnroll.cpp Mon Feb 22 15:21:45 2016
@@ -142,9 +142,13 @@ static bool needToInsertPhisForLCSSA(Loo
continue;
for (Instruction &I : *BB) {
for (Use &U : I.operands()) {
- if (auto Def = dyn_cast<Instruction>(U))
- if (LI->getLoopFor(Def->getParent()) == L)
+ if (auto Def = dyn_cast<Instruction>(U)) {
+ Loop *DefLoop = LI->getLoopFor(Def->getParent());
+ if (!DefLoop)
+ continue;
+ if (DefLoop->contains(L))
return true;
+ }
}
}
}
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=261575&r1=261574&r2=261575&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LoopUnroll/rebuild_lcssa.ll (original)
+++ llvm/trunk/test/Transforms/LoopUnroll/rebuild_lcssa.ll Mon Feb 22 15:21:45 2016
@@ -117,3 +117,37 @@ Exit:
%a_lcssa2 = phi i8* [ %a_lcssa1, %L2_exit ]
ret void
}
+
+; PR26688
+; CHECK-LABEL: @foo4
+define i8 @foo4() {
+entry:
+ br label %L1_header
+
+L1_header:
+ %x = icmp eq i32 1, 0
+ br label %L2_header
+
+L2_header:
+ br label %L3_header
+
+L3_header:
+ br i1 true, label %L2_header, label %L3_exiting
+
+L3_exiting:
+ br i1 true, label %L3_body, label %L1_latch
+
+; CHECK: L3_body:
+; CHECK-NEXT: %x.lcssa = phi i1
+L3_body:
+ br i1 %x, label %L3_latch, label %L3_latch
+
+L3_latch:
+ br i1 false, label %L3_header, label %exit
+
+L1_latch:
+ br label %L1_header
+
+exit:
+ ret i8 0
+}
More information about the llvm-commits
mailing list