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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 4 03:06:20 PST 2026


================
@@ -1779,39 +1772,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 *Select = 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));
+        Select =
+            Builder.createSelect(Blend->getMask(I), Blend->getIncomingValue(I),
+                                 Select, Blend->getDebugLoc(), "predphi");
+        Select->setUnderlyingValue(Blend->getUnderlyingValue());
----------------
fhahn wrote:

It would be better to not set the underlying value here, to avoid having the same recipe with the same underlying instruction/phi underlying instr for a select.

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


More information about the llvm-commits mailing list