You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[VPlan] Iterate over header phis to determine FORs that need EVL fixup. NFCI
This is a follow-up to llvm#146672 (comment)
We can avoid iterating over every recipe to pick out splices that need fixed up given that for now, all splices must use a VPFirstOrderRecurrencePHIRecipe.
An assertion was added since this doesn't hold for unrolled loops:
vector.body:
EMIT-SCALAR vp<%index> = phi [ ir<0>, vector.ph ], [ vp<%index.next>, vector.body ]
FIRST-ORDER-RECURRENCE-PHI ir<%10> = phi ir<%pre_load>, ir<%11>.1
CLONE ir<%indvars.iv.next> = add nuw nsw vp<%index>, ir<1>
CLONE ir<%arrayidx32> = getelementptr inbounds ir<%a>, ir<%indvars.iv.next>
vp<%3> = vector-pointer ir<%arrayidx32>
vp<%4> = vector-pointer ir<%arrayidx32>, ir<1>
WIDEN ir<%11> = load vp<%3>
WIDEN ir<%11>.1 = load vp<%4>
EMIT vp<%5> = first-order splice ir<%10>, ir<%11>
EMIT vp<%6> = first-order splice ir<%11>, ir<%11>.1 <-- doesn't use phi
Or sometimes we splices in loops without a FOR phi at all:
vector.body:
EMIT-SCALAR vp<%index> = phi [ ir<0>, vector.ph ], [ vp<%index.next>, vector.body ]
CLONE ir<%gep.a> = getelementptr ir<%a>, vp<%index>
vp<%3> = vector-pointer ir<%gep.a>
vp<%4> = vector-pointer ir<%gep.a>, ir<1>
WIDEN ir<%load.a> = load vp<%3>
WIDEN ir<%load.a>.1 = load vp<%4>
WIDEN-CAST ir<%ext.a> = zext ir<%load.a> to i32
WIDEN-CAST ir<%ext.a>.1 = zext ir<%load.a>.1 to i32
CLONE ir<%gep.b> = getelementptr ir<%b>, vp<%index>
vp<%5> = vector-pointer ir<%gep.b>
vp<%6> = vector-pointer ir<%gep.b>, ir<1>
WIDEN ir<%load.b> = load vp<%5>
WIDEN ir<%load.b>.1 = load vp<%6>
WIDEN-CAST ir<%ext.b> = zext ir<%load.b> to i32
WIDEN-CAST ir<%ext.b>.1 = zext ir<%load.b>.1 to i32
WIDEN ir<%mul> = mul ir<%ext.b>, ir<%ext.a>
WIDEN ir<%mul>.1 = mul ir<%ext.b>.1, ir<%ext.a>.1
EMIT vp<%7> = first-order splice ir<%mul>, ir<%mul>.1
A test was added for second order recurrences just to double check that they indeed also have their own FOR phi.
; IF-EVL-NEXT: [[TMP15:%.*]] = zext i32 [[TMP14]] to i64
778
+
; IF-EVL-NEXT: [[TMP16:%.*]] = mul i64 1, [[TMP15]]
779
+
; IF-EVL-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <vscale x 2 x i64> poison, i64 [[TMP16]], i64 0
780
+
; IF-EVL-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <vscale x 2 x i64> [[BROADCAST_SPLATINSERT]], <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
781
+
; IF-EVL-NEXT: [[TMP17]] = add <vscale x 2 x i64> [[VEC_IND]], splat (i64 42)
782
+
; IF-EVL-NEXT: [[TMP18]] = call <vscale x 2 x i64> @llvm.experimental.vp.splice.nxv2i64(<vscale x 2 x i64> [[VECTOR_RECUR]], <vscale x 2 x i64> [[TMP17]], i32 -1, <vscale x 2 x i1> splat (i1 true), i32 [[PREV_EVL]], i32 [[TMP14]])
783
+
; IF-EVL-NEXT: [[TMP19:%.*]] = call <vscale x 2 x i64> @llvm.experimental.vp.splice.nxv2i64(<vscale x 2 x i64> [[VECTOR_RECUR2]], <vscale x 2 x i64> [[TMP18]], i32 -1, <vscale x 2 x i1> splat (i1 true), i32 [[PREV_EVL]], i32 [[TMP14]])
; NO-VP-NEXT: [[TMP5:%.*]] = mul nuw i64 [[TMP4]], 2
827
+
; NO-VP-NEXT: [[TMP6:%.*]] = call <vscale x 2 x i64> @llvm.stepvector.nxv2i64()
828
+
; NO-VP-NEXT: [[TMP7:%.*]] = mul <vscale x 2 x i64> [[TMP6]], splat (i64 1)
829
+
; NO-VP-NEXT: [[INDUCTION:%.*]] = add <vscale x 2 x i64> zeroinitializer, [[TMP7]]
830
+
; NO-VP-NEXT: [[TMP8:%.*]] = mul i64 1, [[TMP5]]
831
+
; NO-VP-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <vscale x 2 x i64> poison, i64 [[TMP8]], i64 0
832
+
; NO-VP-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <vscale x 2 x i64> [[BROADCAST_SPLATINSERT]], <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer
; NO-VP-NEXT: [[VEC_IND:%.*]] = phi <vscale x 2 x i64> [ [[INDUCTION]], %[[VECTOR_PH]] ], [ [[VEC_IND_NEXT:%.*]], %[[VECTOR_BODY]] ]
845
+
; NO-VP-NEXT: [[VECTOR_RECUR:%.*]] = phi <vscale x 2 x i64> [ [[VECTOR_RECUR_INIT]], %[[VECTOR_PH]] ], [ [[TMP15:%.*]], %[[VECTOR_BODY]] ]
846
+
; NO-VP-NEXT: [[VECTOR_RECUR2:%.*]] = phi <vscale x 2 x i64> [ [[VECTOR_RECUR_INIT1]], %[[VECTOR_PH]] ], [ [[TMP16:%.*]], %[[VECTOR_BODY]] ]
847
+
; NO-VP-NEXT: [[TMP15]] = add <vscale x 2 x i64> [[VEC_IND]], splat (i64 42)
848
+
; NO-VP-NEXT: [[TMP16]] = call <vscale x 2 x i64> @llvm.vector.splice.nxv2i64(<vscale x 2 x i64> [[VECTOR_RECUR]], <vscale x 2 x i64> [[TMP15]], i32 -1)
849
+
; NO-VP-NEXT: [[TMP17:%.*]] = call <vscale x 2 x i64> @llvm.vector.splice.nxv2i64(<vscale x 2 x i64> [[VECTOR_RECUR2]], <vscale x 2 x i64> [[TMP16]], i32 -1)
0 commit comments