[llvm] [InstCombine] Replace all dominated uses of condition with constants (PR #105510)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 30 23:39:55 PDT 2024


================
@@ -3705,6 +3705,20 @@ Instruction *InstCombinerImpl::visitBranchInst(BranchInst &BI) {
     return nullptr;
   }
 
+  // Replace all dominated uses of the condition with true/false
+  if (BI.getSuccessor(0) != BI.getSuccessor(1)) {
+    for (auto &U : make_early_inc_range(Cond->uses())) {
+      BasicBlockEdge Edge0(BI.getParent(), BI.getSuccessor(0));
+      if (DT.dominates(Edge0, U)) {
+        replaceUse(U, ConstantInt::getTrue(Cond->getType()));
----------------
dtcxzyw wrote:

Done.

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


More information about the llvm-commits mailing list