@@ -115,3 +115,34 @@ loop:
115115exit:
116116 ret void
117117}
118+
119+ define void @cast_induction_tail_folding (ptr %A ) {
120+ ; VF4-LABEL: @cast_induction_tail_folding(
121+ ; VF4: [[INDEX:%.+]] = phi i32 [ 0, %vector.ph ]
122+ ; VF4-NEXT: [[VEC_IND:%.+]] = phi <4 x i32> [ <i32 0, i32 1, i32 2, i32 3>, %vector.ph ]
123+ ; VF4-NEXT: = icmp ule <4 x i32> [[VEC_IND]], <i32 2, i32 2, i32 2, i32 2>
124+ ; VF4-NEXT: = sext <4 x i32> [[VEC_IND]] to <4 x i64>
125+
126+ ; IC2-LABEL: @cast_induction_tail_folding(
127+ ; IC2: [[INDEX:%.+]] = phi i32 [ 0, %vector.ph ]
128+ ; IC2-NEXT: [[INDEX0:%.+]] = add i32 [[INDEX]], 0
129+ ; IC2-NEXT: [[INDEX1:%.+]] = add i32 [[INDEX]], 1
130+ ; IC2-NEXT: = icmp ule i32 [[INDEX0]], 2
131+ ; IC2-NEXT: = icmp ule i32 [[INDEX1]], 2
132+ ;
133+ entry:
134+ br label %loop
135+
136+ loop:
137+ %iv = phi i32 [ 0 , %entry ], [ %iv.next , %loop ]
138+ %iv.ext = sext i32 %iv to i64
139+ %iv.trunc = trunc i64 %iv.ext to i32
140+ %gep = getelementptr inbounds i32 , ptr %A , i64 %iv.ext
141+ store i32 %iv.trunc , ptr %gep
142+ %iv.next = add i32 %iv , 1
143+ %c = icmp slt i32 %iv.next , 3
144+ br i1 %c , label %loop , label %exit
145+
146+ exit:
147+ ret void
148+ }
0 commit comments