[llvm] [VPlan] Expand VPBlendRecipe earlier in simplifyBlends (PR #171851)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 5 01:47:33 PST 2026


================
@@ -1743,39 +1736,22 @@ static void simplifyBlends(VPlan &Plan) {
         }
       }
 
-      SmallVector<VPValue *, 4> OperandsWithMask;
-      OperandsWithMask.push_back(Blend->getIncomingValue(StartIndex));
-
+      // Expand VPBlendRecipe into VPInstruction::Select.
+      VPBuilder Builder(&R);
+      VPValue *NewBlend = Blend->getIncomingValue(StartIndex);
       for (unsigned I = 0; I != Blend->getNumIncomingValues(); ++I) {
         if (I == StartIndex)
           continue;
-        OperandsWithMask.push_back(Blend->getIncomingValue(I));
-        OperandsWithMask.push_back(Blend->getMask(I));
+        NewBlend =
+            Builder.createSelect(Blend->getMask(I), Blend->getIncomingValue(I),
+                                 NewBlend, Blend->getDebugLoc(), "predphi");
+        NewBlend->setUnderlyingValue(Blend->getUnderlyingValue());
----------------
lukel97 wrote:

This is just the existing behaviour of VPBlendRecipe, its underlying value was the original PHI node despite emitting selects. 

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


More information about the llvm-commits mailing list