[llvm] [InstCombine] Simplify phi using KnownBits of condition (PR #134712)

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 7 21:00:05 PDT 2025


================
@@ -840,17 +840,28 @@ void llvm::computeKnownBitsFromContext(const Value *V, KnownBits &Known,
 
   if (Q.DC && Q.DT) {
     // Handle dominating conditions.
-    for (BranchInst *BI : Q.DC->conditionsFor(V)) {
-      BasicBlockEdge Edge0(BI->getParent(), BI->getSuccessor(0));
-      if (Q.DT->dominates(Edge0, Q.CxtI->getParent()))
-        computeKnownBitsFromCond(V, BI->getCondition(), Known, Depth, Q,
-                                 /*Invert*/ false);
+    const BasicBlock *CxtIBB = Q.CxtI->getParent();
+    if (isa<PHINode>(Q.CxtI))
----------------
dtcxzyw wrote:

We don't need to specially handle the PHI node here. You should pass a more precise CxtI (See the comments below).


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


More information about the llvm-commits mailing list