[llvm] [SLP][NFC] Add tests for runtime strided loads during revectorization (PR #191875)
Ryan Buchner via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 13 12:04:06 PDT 2026
================
@@ -20,6 +20,55 @@ entry:
ret void
}
+define void @widened_strided_load_runtime(ptr %in0, ptr %out0, i64 %stride) {
+; CHECK-LABEL: @widened_strided_load_runtime(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[IN1:%.*]] = getelementptr <8 x i8>, ptr [[IN0:%.*]], i64 [[STRIDE:%.*]]
+; CHECK-NEXT: [[L0:%.*]] = load <8 x i8>, ptr [[IN0]], align 2
+; CHECK-NEXT: [[L1:%.*]] = load <8 x i8>, ptr [[IN1]], align 2
+; CHECK-NEXT: [[TMP0:%.*]] = shufflevector <8 x i8> [[L0]], <8 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
+; CHECK-NEXT: [[TMP1:%.*]] = shufflevector <8 x i8> [[L1]], <8 x i8> poison, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison, i32 poison>
+; CHECK-NEXT: [[TMP2:%.*]] = shufflevector <16 x i8> [[TMP0]], <16 x i8> [[TMP1]], <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 16, i32 17, i32 18, i32 19, i32 20, i32 21, i32 22, i32 23>
+; CHECK-NEXT: store <16 x i8> [[TMP2]], ptr [[OUT0:%.*]], align 2
+; CHECK-NEXT: ret void
+;
+entry:
+ %in1 = getelementptr <8 x i8>, ptr %in0, i64 %stride
+ %l0 = load <8 x i8>, ptr %in0, align 2
+ %l1 = load <8 x i8>, ptr %in1, align 2
+ %out1 = getelementptr i8, ptr %out0, i64 8
+ store <8 x i8> %l0, ptr %out0, align 2
+ store <8 x i8> %l1, ptr %out1, align 2
+ ret void
+}
+
+; Base case of strided load, implicitly is widened
+define void @widened_strided_load_runtime_more_elements(ptr %in0, ptr %out0, i64 %stride) {
+; CHECK-LABEL: @widened_strided_load_runtime_more_elements(
+; CHECK-NEXT: entry:
+; CHECK-NEXT: [[TMP0:%.*]] = mul i64 [[STRIDE:%.*]], 2
+; CHECK-NEXT: [[TMP1:%.*]] = call <8 x i8> @llvm.experimental.vp.strided.load.v8i8.p0.i64(ptr align 2 [[IN0:%.*]], i64 [[TMP0]], <8 x i1> splat (i1 true), i32 8)
----------------
bababuck wrote:
I mentioned previously that there was no bug here, I did find that there actually is a bug here. I missed seeing the bug because when the number of input pointers is small (NOT accounting for the re-vectorization case) we fallback to the gather case (happens in `@widened_strided_load_runtime`). The fixes for both issues are included in the MR for this.
https://github.com/llvm/llvm-project/pull/191875
More information about the llvm-commits
mailing list