[PATCH] D13040: [SimplifyCFG] Constant fold a branch implied by it's incoming edge
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 24 01:06:05 PDT 2015
sanjoy accepted this revision.
sanjoy added a comment.
This revision is now accepted and ready to land.
lgtm modulo minor nits
================
Comment at: lib/Transforms/Utils/SimplifyCFG.cpp:2515
@@ +2514,3 @@
+ PBI->getSuccessor(0) != PBI->getSuccessor(1) &&
+ BB->getSinglePredecessor()) {
+ // Turn this into a branch on constant.
----------------
I don't think you need to check `PBI->getSuccessor(0) != PBI->getSuccessor(1)` -- please verify this, but I think `getSinglePredecessor` (as opposed to `getUniquePredecessor`) should return `nullptr` if you have two branches from the same block to `BB`.
================
Comment at: lib/Transforms/Utils/SimplifyCFG.cpp:2518
@@ +2517,3 @@
+ auto *OldCond = BI->getCondition();
+ BI->setCondition(ConstantInt::getTrue(Type::getInt1Ty(BB->getContext())));
+ RecursivelyDeleteTriviallyDeadInstructions(OldCond);
----------------
Since you're not creating vectors of `i1`s, I think `ConstantInt::getTrue(BB->getContext())` should be sufficient.
http://reviews.llvm.org/D13040
More information about the llvm-commits
mailing list