[llvm] 2ae795d - [LV] Add test case where variable induction step needs truncating.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 14 12:14:29 PST 2024
Author: Florian Hahn
Date: 2024-01-14T20:14:12Z
New Revision: 2ae795d3d65ec584865491af7e6ab16b8d22acef
URL: https://github.com/llvm/llvm-project/commit/2ae795d3d65ec584865491af7e6ab16b8d22acef
DIFF: https://github.com/llvm/llvm-project/commit/2ae795d3d65ec584865491af7e6ab16b8d22acef.diff
LOG: [LV] Add test case where variable induction step needs truncating.
Added:
Modified:
llvm/test/Transforms/LoopVectorize/cast-induction.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/LoopVectorize/cast-induction.ll b/llvm/test/Transforms/LoopVectorize/cast-induction.ll
index a2a7c02c1164220..c5edf9831d7d905 100644
--- a/llvm/test/Transforms/LoopVectorize/cast-induction.ll
+++ b/llvm/test/Transforms/LoopVectorize/cast-induction.ll
@@ -73,3 +73,43 @@ loop:
exit:
ret void
}
+
+
+define void @cast_variable_step(i64 %step) {
+; VF4-LABEL: @cast_variable_step(
+; VF4-LABEL: vector.body:
+; VF4: [[VEC_IND:%.+]] = phi <4 x i32>
+; VF4: store <4 x i32> [[VEC_IND]]
+; VF4: middle.block:
+;
+; IC2-LABEL: @cast_variable_step(
+; IC2-LABEL: vector.body:
+; IC2-NEXT: [[INDEX:%.+]] = phi i64 [ 0, %vector.ph ]
+; IC2-NEXT: [[MUL:%.+]] = mul i64 %index, %step
+; IC2-NEXT: [[OFFSET_IDX:%.+]] = add i64 10, [[MUL]]
+; IC2-NEXT: [[TRUNC_OFF:%.+]] = trunc i64 [[OFFSET_IDX]] to i32
+; IC2-NEXT: [[TRUNC_STEP:%.+]] = trunc i64 %step to i32
+; IC2-NEXT: [[STEP0:%.+]] = mul i32 0, [[TRUNC_STEP]]
+; IC2-NEXT: [[T0:%.+]] = add i32 [[TRUNC_OFF]], [[STEP0]]
+; IC2-NEXT: [[STEP1:%.+]] = mul i32 1, [[TRUNC_STEP]]
+; IC2-NEXT: [[T1:%.+]] = add i32 [[TRUNC_OFF]], [[STEP1]]
+; IC2: store i32 [[T0]],
+; IC2-NEXT: store i32 [[T1]],
+;
+entry:
+ br label %loop
+
+loop:
+ %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
+ %iv.2 = phi i64 [ 10, %entry ], [ %iv.2.next, %loop ]
+ %gep = getelementptr inbounds [2048 x i32], ptr @a, i64 0, i64 %iv
+ %iv.2.trunc = trunc i64 %iv.2 to i32
+ store i32 %iv.2.trunc, ptr %gep, align 4
+ %iv.next = add i64 %iv, 1
+ %iv.2.next = add i64 %iv.2, %step
+ %exitcond = icmp eq i64 %iv.next, 1024
+ br i1 %exitcond, label %exit, label %loop
+
+exit:
+ ret void
+}
More information about the llvm-commits
mailing list