[llvm] r179227 - Manually remove successors in if conversion when CopyAndPredicateBlock is used
Hal Finkel
hfinkel at anl.gov
Wed Apr 10 15:05:26 PDT 2013
Author: hfinkel
Date: Wed Apr 10 17:05:25 2013
New Revision: 179227
URL: http://llvm.org/viewvc/llvm-project?rev=179227&view=rev
Log:
Manually remove successors in if conversion when CopyAndPredicateBlock is used
In the simple and triangle if-conversion cases, when CopyAndPredicateBlock is
used because the to-be-predicated block has other predecessors, we need to
explicitly remove the old copied block from the successors list. Normally if
conversion relies on TII->AnalyzeBranch combined with BB->CorrectExtraCFGEdges
to cleanup the successors list, but if the predicated block contained an
un-analyzable branch (such as a now-predicated return), then this will fail.
These extra successors were causing a problem on PPC because it was causing
later passes (such as PPCEarlyReturm) to leave dead return-only basic blocks in
the code.
Modified:
llvm/trunk/lib/CodeGen/IfConversion.cpp
llvm/trunk/test/CodeGen/PowerPC/bdzlr.ll
llvm/trunk/test/CodeGen/PowerPC/early-ret2.ll
Modified: llvm/trunk/lib/CodeGen/IfConversion.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/IfConversion.cpp?rev=179227&r1=179226&r2=179227&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/IfConversion.cpp (original)
+++ llvm/trunk/lib/CodeGen/IfConversion.cpp Wed Apr 10 17:05:25 2013
@@ -1054,6 +1054,10 @@ bool IfConverter::IfConvertSimple(BBInfo
// Copy instructions in the true block, predicate them, and add them to
// the entry block.
CopyAndPredicateBlock(BBI, *CvtBBI, Cond, Redefs);
+
+ // RemoveExtraEdges won't work if the block has an unanalyzable branch, so
+ // explicitly remove CvtBBI as a successor.
+ BBI.BB->removeSuccessor(CvtBBI->BB);
} else {
PredicateBlock(*CvtBBI, CvtBBI->BB->end(), Cond, Redefs);
@@ -1146,6 +1150,10 @@ bool IfConverter::IfConvertTriangle(BBIn
// Copy instructions in the true block, predicate them, and add them to
// the entry block.
CopyAndPredicateBlock(BBI, *CvtBBI, Cond, Redefs, true);
+
+ // RemoveExtraEdges won't work if the block has an unanalyzable branch, so
+ // explicitly remove CvtBBI as a successor.
+ BBI.BB->removeSuccessor(CvtBBI->BB);
} else {
// Predicate the 'true' block after removing its branch.
CvtBBI->NonPredSize -= TII->RemoveBranch(*CvtBBI->BB);
Modified: llvm/trunk/test/CodeGen/PowerPC/bdzlr.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/bdzlr.ll?rev=179227&r1=179226&r2=179227&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/bdzlr.ll (original)
+++ llvm/trunk/test/CodeGen/PowerPC/bdzlr.ll Wed Apr 10 17:05:25 2013
@@ -53,6 +53,7 @@ for.end:
; CHECK: bnelr
; CHECK: bnelr
; CHECK: bdzlr
+; CHECK-NOT: blr
}
attributes #0 = { nounwind }
Modified: llvm/trunk/test/CodeGen/PowerPC/early-ret2.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/early-ret2.ll?rev=179227&r1=179226&r2=179227&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/early-ret2.ll (original)
+++ llvm/trunk/test/CodeGen/PowerPC/early-ret2.ll Wed Apr 10 17:05:25 2013
@@ -17,7 +17,6 @@ while.end:
; CHECK: @_Z8example3iPiS_
; CHECK: bnelr
-; CHECK: bnelr
}
attributes #0 = { noinline nounwind }
More information about the llvm-commits
mailing list