Skip to content

Commit 2ae795d

Browse files
committed
[LV] Add test case where variable induction step needs truncating.
1 parent 60a9874 commit 2ae795d

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

llvm/test/Transforms/LoopVectorize/cast-induction.ll

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,43 @@ loop:
7373
exit:
7474
ret void
7575
}
76+
77+
78+
define void @cast_variable_step(i64 %step) {
79+
; VF4-LABEL: @cast_variable_step(
80+
; VF4-LABEL: vector.body:
81+
; VF4: [[VEC_IND:%.+]] = phi <4 x i32>
82+
; VF4: store <4 x i32> [[VEC_IND]]
83+
; VF4: middle.block:
84+
;
85+
; IC2-LABEL: @cast_variable_step(
86+
; IC2-LABEL: vector.body:
87+
; IC2-NEXT: [[INDEX:%.+]] = phi i64 [ 0, %vector.ph ]
88+
; IC2-NEXT: [[MUL:%.+]] = mul i64 %index, %step
89+
; IC2-NEXT: [[OFFSET_IDX:%.+]] = add i64 10, [[MUL]]
90+
; IC2-NEXT: [[TRUNC_OFF:%.+]] = trunc i64 [[OFFSET_IDX]] to i32
91+
; IC2-NEXT: [[TRUNC_STEP:%.+]] = trunc i64 %step to i32
92+
; IC2-NEXT: [[STEP0:%.+]] = mul i32 0, [[TRUNC_STEP]]
93+
; IC2-NEXT: [[T0:%.+]] = add i32 [[TRUNC_OFF]], [[STEP0]]
94+
; IC2-NEXT: [[STEP1:%.+]] = mul i32 1, [[TRUNC_STEP]]
95+
; IC2-NEXT: [[T1:%.+]] = add i32 [[TRUNC_OFF]], [[STEP1]]
96+
; IC2: store i32 [[T0]],
97+
; IC2-NEXT: store i32 [[T1]],
98+
;
99+
entry:
100+
br label %loop
101+
102+
loop:
103+
%iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
104+
%iv.2 = phi i64 [ 10, %entry ], [ %iv.2.next, %loop ]
105+
%gep = getelementptr inbounds [2048 x i32], ptr @a, i64 0, i64 %iv
106+
%iv.2.trunc = trunc i64 %iv.2 to i32
107+
store i32 %iv.2.trunc, ptr %gep, align 4
108+
%iv.next = add i64 %iv, 1
109+
%iv.2.next = add i64 %iv.2, %step
110+
%exitcond = icmp eq i64 %iv.next, 1024
111+
br i1 %exitcond, label %exit, label %loop
112+
113+
exit:
114+
ret void
115+
}

0 commit comments

Comments
 (0)