[llvm] [VPlan] Introduce VPInstruction::InsertLastLane for start value of VPFirstOrderRecurrencePHIRecipe. (PR #171590)

Mel Chen via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 15 00:56:52 PST 2025


================
@@ -2246,6 +2256,15 @@ bool VPlanTransforms::adjustFixedOrderRecurrences(VPlan &Plan,
       RecurrencePhis.push_back(FOR);
 
   for (VPFirstOrderRecurrencePHIRecipe *FOR : RecurrencePhis) {
+    /// Adjust start value of fixed-order recurrence phi to [poison, ... ,
+    /// poison, start value].
+    VPValue *StartV = FOR->getStartValue();
+    VPValue *NewStart = PHBuilder.createNaryOp(
+        VPInstruction::InsertLastLane, {Plan.getOrAddLiveIn(PoisonValue::get(
+                                            TypeInfo.inferScalarType(StartV))),
+                                        StartV});
----------------
Mel-Chen wrote:

My downstream repo actually has a version with `VPInstruction::FORInitVector(start_value, VF)`. Would this be better?

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


More information about the llvm-commits mailing list