[llvm] [SimplifyCFG] Simplify conditional branches on const icmp eq's (PR #73334)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 24 07:03:02 PST 2023


================
@@ -3578,6 +3578,14 @@ static bool FoldTwoEntryPHINode(PHINode *PN, const TargetTransformInfo &TTI,
   return true;
 }
 
+static BranchInst *decayCondBranchToUncondBranch(IRBuilderBase &Builder,
+                                                 BranchInst *BI, bool Eval) {
+  unsigned SuccessorIdx = (Eval) ? 0 : 1;
+  auto *NewBI = Builder.CreateBr(BI->getSuccessor(SuccessorIdx));
+  BI->eraseFromParent();
----------------
nikic wrote:

This fails to update the dominator tree. I think it would be better to just replace the branch condition with true/false and let ConstantFoldTerminator take care of the rest.

https://github.com/llvm/llvm-project/pull/73334


More information about the llvm-commits mailing list