[llvm] [LV] Avoid adding stray predicates in isConsecutivePtr (PR #213662)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 6 02:14:21 PDT 2026


================
@@ -14,43 +14,32 @@ define void @stride_exceeds_i32_max(ptr noalias readonly %src, ptr noalias %dst,
 ; CHECK-NEXT:    [[TMP4:%.*]] = add nuw nsw i32 [[TMP3]], 1
 ; CHECK-NEXT:    br label %[[VECTOR_SCEVCHECK:.*]]
 ; CHECK:       [[VECTOR_SCEVCHECK]]:
-; CHECK-NEXT:    [[TMP5:%.*]] = icmp slt i16 -1, [[START]]
-; CHECK-NEXT:    br i1 [[TMP5]], label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]
-; CHECK:       [[VECTOR_PH]]:
-; CHECK-NEXT:    [[TMP12:%.*]] = sext i16 [[START]] to i64
-; CHECK-NEXT:    [[TMP13:%.*]] = mul nsw i64 [[TMP12]], 3000000000
-; CHECK-NEXT:    [[SCEVGEP:%.*]] = getelementptr i8, ptr [[SRC]], i64 [[TMP13]]
 ; CHECK-NEXT:    [[BROADCAST_SPLATINSERT:%.*]] = insertelement <vscale x 16 x ptr> poison, ptr [[DST]], i64 0
 ; CHECK-NEXT:    [[BROADCAST_SPLAT:%.*]] = shufflevector <vscale x 16 x ptr> [[BROADCAST_SPLATINSERT]], <vscale x 16 x ptr> poison, <vscale x 16 x i32> zeroinitializer
+; CHECK-NEXT:    [[TMP8:%.*]] = call <vscale x 16 x i16> @llvm.stepvector.nxv16i16()
----------------
lukel97 wrote:

Yeah I think we need to teach convertToStridedAccesses to handle non-constant strides, but that's out of scope. I agree with the premise of this PR that `isConsecutivePtr` shouldn't be adding predicates if it doesn't result in a consecutive pointer that can be made unit-strided. 

And in any case even with the gather instead of the vp.strided.load there's more of a chance we'll enter the vector loop. So maybe it's not really a regression after all.

This test case is trying to test `convertToStridedAccesses` though, so I think switching the `sext` to `zext` is good enough

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


More information about the llvm-commits mailing list