[llvm] [VPlan] Use VPlan operand order for VPBlendRecipes. (PR #139475)

via llvm-commits llvm-commits at lists.llvm.org
Mon May 12 04:37:37 PDT 2025


================
@@ -8538,36 +8538,30 @@ VPWidenIntOrFpInductionRecipe *VPRecipeBuilder::tryToOptimizeInductionTruncate(
   return nullptr;
 }
 
-VPBlendRecipe *VPRecipeBuilder::tryToBlend(PHINode *Phi,
-                                           ArrayRef<VPValue *> Operands) {
-  unsigned NumIncoming = Phi->getNumIncomingValues();
+VPBlendRecipe *VPRecipeBuilder::tryToBlend(VPWidenPHIRecipe *PhiR) {
+  unsigned NumIncoming = PhiR->getNumIncoming();
 
   // We know that all PHIs in non-header blocks are converted into selects, so
   // we don't have to worry about the insertion order and we can just use the
   // builder. At this point we generate the predication tree. There may be
   // duplications since this is a simple recursive scan, but future
   // optimizations will clean it up.
 
-  // Map incoming IR BasicBlocks to incoming VPValues, for lookup below.
-  // TODO: Add operands and masks in order from the VPlan predecessors.
-  DenseMap<BasicBlock *, VPValue *> VPIncomingValues;
-  for (const auto &[Idx, Pred] : enumerate(predecessors(Phi->getParent())))
-    VPIncomingValues[Pred] = Operands[Idx];
-
   SmallVector<VPValue *, 2> OperandsWithMask;
   for (unsigned In = 0; In < NumIncoming; In++) {
-    BasicBlock *Pred = Phi->getIncomingBlock(In);
-    OperandsWithMask.push_back(VPIncomingValues.lookup(Pred));
-    VPValue *EdgeMask = getEdgeMask(Pred, Phi->getParent());
+    const VPBasicBlock *Pred = PhiR->getIncomingBlock(In);
+    OperandsWithMask.push_back(PhiR->getIncomingValue(In));
----------------
ayalz wrote:

nit, now that getting the incoming value is independent of the incoming block:
```suggestion
    OperandsWithMask.push_back(PhiR->getIncomingValue(In));
    const VPBasicBlock *Pred = PhiR->getIncomingBlock(In);
```

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


More information about the llvm-commits mailing list