[PATCH] D65596: [SimplifyCFG] Cleanup redundant conditions [NFC].
Alina Sbirlea via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 2 11:10:59 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL367699: [SimplifyCFG] Cleanup redundant conditions [NFC]. (authored by asbirlea, committed by ).
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65596/new/
https://reviews.llvm.org/D65596
Files:
llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
Index: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -4178,24 +4178,22 @@
IRBuilder<> Builder(TI);
if (auto *BI = dyn_cast<BranchInst>(TI)) {
if (BI->isUnconditional()) {
- if (BI->getSuccessor(0) == BB) {
- new UnreachableInst(TI->getContext(), TI);
- TI->eraseFromParent();
- Changed = true;
- }
+ assert(BI->getSuccessor(0) == BB && "Incorrect CFG");
+ new UnreachableInst(TI->getContext(), TI);
+ TI->eraseFromParent();
+ Changed = true;
} else {
Value* Cond = BI->getCondition();
if (BI->getSuccessor(0) == BB) {
Builder.CreateAssumption(Builder.CreateNot(Cond));
Builder.CreateBr(BI->getSuccessor(1));
- EraseTerminatorAndDCECond(BI);
- Changed = true;
- } else if (BI->getSuccessor(1) == BB) {
+ } else {
+ assert(BI->getSuccessor(1) == BB && "Incorrect CFG");
Builder.CreateAssumption(Cond);
Builder.CreateBr(BI->getSuccessor(0));
- EraseTerminatorAndDCECond(BI);
- Changed = true;
}
+ EraseTerminatorAndDCECond(BI);
+ Changed = true;
}
} else if (auto *SI = dyn_cast<SwitchInst>(TI)) {
SwitchInstProfUpdateWrapper SU(*SI);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65596.213092.patch
Type: text/x-patch
Size: 1465 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190802/276e78fd/attachment.bin>
More information about the llvm-commits
mailing list