[llvm] [VPlan] Verify dominance for incoming values of phi-like recipes. (PR #124838)

via llvm-commits llvm-commits at lists.llvm.org
Wed May 14 07:33:05 PDT 2025


================
@@ -220,12 +219,28 @@ bool VPlanVerifier::verifyVPBasicBlock(const VPBasicBlock *VPBB) {
 
       for (const VPUser *U : V->users()) {
         auto *UI = cast<VPRecipeBase>(U);
-        // TODO: check dominance of incoming values for phis properly.
-        if (!UI ||
-            isa<VPHeaderPHIRecipe, VPWidenPHIRecipe, VPPredInstPHIRecipe,
-                VPIRPhi>(UI) ||
-            (isa<VPInstruction>(UI) &&
-             cast<VPInstruction>(UI)->getOpcode() == Instruction::PHI))
+        if (auto *Phi = dyn_cast<VPPhiAccessors>(UI)) {
+          for (unsigned Idx = 0; Idx != Phi->getNumIncoming(); ++Idx) {
+            VPValue *IncVPV = Phi->getIncomingValue(Idx);
+            const VPBasicBlock *IncVPBB = Phi->getIncomingBlock(Idx);
+            if (IncVPV != V)
+              continue;
+            if (IncVPBB != VPBB && !VPDT.dominates(VPBB, IncVPBB)) {
+              errs() << "Incoming def at index " << Idx
+                     << " does not dominate incoming block!\n";
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+              VPSlotTracker Tracker(VPBB->getPlan());
+              IncVPV->getDefiningRecipe()->print(errs(), "  ", Tracker);
+              errs() << "\n  does not dominate " << IncVPBB->getName()
+                     << " for\n";
+              UI->print(errs(), "  ", Tracker);
+#endif
+              return false;
+            }
+          }
+          continue;
+        }
+        if (isa<VPPredInstPHIRecipe>(UI))
----------------
ayalz wrote:

Anything to check?

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


More information about the llvm-commits mailing list