1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2 ; RUN: opt -passes=loop-vectorize -force-vector-width=4 -S %s | FileCheck %s
4 @dst = external global [32 x i16], align 1
6 define void @blend_uniform_iv_trunc(i1 %c) {
7 ; CHECK-LABEL: define void @blend_uniform_iv_trunc(
8 ; CHECK-SAME: i1 [[C:%.*]]) {
9 ; CHECK-NEXT: [[ENTRY:.*]]:
10 ; CHECK-NEXT: br i1 false, label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]
11 ; CHECK: [[VECTOR_PH]]:
12 ; CHECK-NEXT: br label %[[VECTOR_BODY:.*]]
13 ; CHECK: [[VECTOR_BODY]]:
14 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
15 ; CHECK-NEXT: [[TMP0:%.*]] = trunc i64 [[INDEX]] to i16
16 ; CHECK-NEXT: [[TMP1:%.*]] = add i16 [[TMP0]], 0
17 ; CHECK-NEXT: [[PREDPHI:%.*]] = select i1 [[C]], i16 [[TMP1]], i16 undef
18 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds [32 x i16], ptr @dst, i16 0, i16 [[PREDPHI]]
19 ; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds i16, ptr [[TMP2]], i32 0
20 ; CHECK-NEXT: store <4 x i16> zeroinitializer, ptr [[TMP3]], align 2
21 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4
22 ; CHECK-NEXT: [[TMP4:%.*]] = icmp eq i64 [[INDEX_NEXT]], 32
23 ; CHECK-NEXT: br i1 [[TMP4]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
24 ; CHECK: [[MIDDLE_BLOCK]]:
25 ; CHECK-NEXT: br i1 true, label %[[EXIT:.*]], label %[[SCALAR_PH]]
26 ; CHECK: [[SCALAR_PH]]:
27 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 32, %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]
28 ; CHECK-NEXT: br label %[[LOOP_HEADER:.*]]
29 ; CHECK: [[LOOP_HEADER]]:
30 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], %[[LOOP_LATCH:.*]] ]
31 ; CHECK-NEXT: [[IV_TRUNC_2:%.*]] = trunc i64 [[IV]] to i16
32 ; CHECK-NEXT: br i1 [[C]], label %[[LOOP_NEXT:.*]], label %[[LOOP_LATCH]]
33 ; CHECK: [[LOOP_NEXT]]:
34 ; CHECK-NEXT: br label %[[LOOP_LATCH]]
35 ; CHECK: [[LOOP_LATCH]]:
36 ; CHECK-NEXT: [[BLEND:%.*]] = phi i16 [ undef, %[[LOOP_HEADER]] ], [ [[IV_TRUNC_2]], %[[LOOP_NEXT]] ]
37 ; CHECK-NEXT: [[DST_PTR:%.*]] = getelementptr inbounds [32 x i16], ptr @dst, i16 0, i16 [[BLEND]]
38 ; CHECK-NEXT: store i16 0, ptr [[DST_PTR]], align 2
39 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
40 ; CHECK-NEXT: [[CMP439:%.*]] = icmp ult i64 [[IV]], 31
41 ; CHECK-NEXT: br i1 [[CMP439]], label %[[LOOP_HEADER]], label %[[EXIT]], !llvm.loop [[LOOP3:![0-9]+]]
43 ; CHECK-NEXT: ret void
48 loop.header: ; preds = %loop.latch, %entry
49 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]
50 %iv.trunc.2 = trunc i64 %iv to i16
51 br i1 %c, label %loop.next, label %loop.latch
53 loop.next: ; preds = %loop.header
56 loop.latch: ; preds = %loop.next, %loop.header
57 %blend = phi i16 [ undef, %loop.header ], [ %iv.trunc.2, %loop.next ]
58 %dst.ptr = getelementptr inbounds [32 x i16], ptr @dst, i16 0, i16 %blend
59 store i16 0, ptr %dst.ptr
60 %iv.next = add nuw nsw i64 %iv, 1
61 %cmp439 = icmp ult i64 %iv, 31
62 br i1 %cmp439, label %loop.header, label %exit
64 exit: ; preds = %loop.latch
68 define void @blend_uniform_iv(i1 %c) {
69 ; CHECK-LABEL: define void @blend_uniform_iv(
70 ; CHECK-SAME: i1 [[C:%.*]]) {
71 ; CHECK-NEXT: [[ENTRY:.*]]:
72 ; CHECK-NEXT: br i1 false, label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]
73 ; CHECK: [[VECTOR_PH]]:
74 ; CHECK-NEXT: br label %[[VECTOR_BODY:.*]]
75 ; CHECK: [[VECTOR_BODY]]:
76 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
77 ; CHECK-NEXT: [[TMP0:%.*]] = add i64 [[INDEX]], 0
78 ; CHECK-NEXT: [[PREDPHI:%.*]] = select i1 [[C]], i64 [[TMP0]], i64 undef
79 ; CHECK-NEXT: [[TMP1:%.*]] = getelementptr inbounds [32 x i16], ptr @dst, i16 0, i64 [[PREDPHI]]
80 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds i16, ptr [[TMP1]], i32 0
81 ; CHECK-NEXT: store <4 x i16> zeroinitializer, ptr [[TMP2]], align 2
82 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4
83 ; CHECK-NEXT: [[TMP3:%.*]] = icmp eq i64 [[INDEX_NEXT]], 32
84 ; CHECK-NEXT: br i1 [[TMP3]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP4:![0-9]+]]
85 ; CHECK: [[MIDDLE_BLOCK]]:
86 ; CHECK-NEXT: br i1 true, label %[[EXIT:.*]], label %[[SCALAR_PH]]
87 ; CHECK: [[SCALAR_PH]]:
88 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 32, %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]
89 ; CHECK-NEXT: br label %[[LOOP_HEADER:.*]]
90 ; CHECK: [[LOOP_HEADER]]:
91 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], %[[LOOP_LATCH:.*]] ]
92 ; CHECK-NEXT: br i1 [[C]], label %[[LOOP_NEXT:.*]], label %[[LOOP_LATCH]]
93 ; CHECK: [[LOOP_NEXT]]:
94 ; CHECK-NEXT: br label %[[LOOP_LATCH]]
95 ; CHECK: [[LOOP_LATCH]]:
96 ; CHECK-NEXT: [[BLEND:%.*]] = phi i64 [ undef, %[[LOOP_HEADER]] ], [ [[IV]], %[[LOOP_NEXT]] ]
97 ; CHECK-NEXT: [[DST_PTR:%.*]] = getelementptr inbounds [32 x i16], ptr @dst, i16 0, i64 [[BLEND]]
98 ; CHECK-NEXT: store i16 0, ptr [[DST_PTR]], align 2
99 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
100 ; CHECK-NEXT: [[CMP439:%.*]] = icmp ult i64 [[IV]], 31
101 ; CHECK-NEXT: br i1 [[CMP439]], label %[[LOOP_HEADER]], label %[[EXIT]], !llvm.loop [[LOOP5:![0-9]+]]
103 ; CHECK-NEXT: ret void
107 br label %loop.header
109 loop.header: ; preds = %loop.latch, %entry
110 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]
111 br i1 %c, label %loop.next, label %loop.latch
113 loop.next: ; preds = %loop.header
116 loop.latch: ; preds = %loop.next, %loop.header
117 %blend = phi i64 [ undef, %loop.header ], [ %iv, %loop.next ]
118 %dst.ptr = getelementptr inbounds [32 x i16], ptr @dst, i16 0, i64 %blend
119 store i16 0, ptr %dst.ptr
120 %iv.next = add nuw nsw i64 %iv, 1
121 %cmp439 = icmp ult i64 %iv, 31
122 br i1 %cmp439, label %loop.header, label %exit
124 exit: ; preds = %loop.latch
128 define void @blend_chain_iv(i1 %c) {
129 ; CHECK-LABEL: define void @blend_chain_iv(
130 ; CHECK-SAME: i1 [[C:%.*]]) {
131 ; CHECK-NEXT: [[ENTRY:.*]]:
132 ; CHECK-NEXT: br i1 false, label %[[SCALAR_PH:.*]], label %[[VECTOR_PH:.*]]
133 ; CHECK: [[VECTOR_PH]]:
134 ; CHECK-NEXT: [[BROADCAST_SPLATINSERT:%.*]] = insertelement <4 x i1> poison, i1 [[C]], i64 0
135 ; CHECK-NEXT: [[BROADCAST_SPLAT:%.*]] = shufflevector <4 x i1> [[BROADCAST_SPLATINSERT]], <4 x i1> poison, <4 x i32> zeroinitializer
136 ; CHECK-NEXT: br label %[[VECTOR_BODY:.*]]
137 ; CHECK: [[VECTOR_BODY]]:
138 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
139 ; CHECK-NEXT: [[VEC_IND:%.*]] = phi <4 x i64> [ <i64 0, i64 1, i64 2, i64 3>, %[[VECTOR_PH]] ], [ [[VEC_IND_NEXT:%.*]], %[[VECTOR_BODY]] ]
140 ; CHECK-NEXT: [[TMP0:%.*]] = select <4 x i1> [[BROADCAST_SPLAT]], <4 x i1> [[BROADCAST_SPLAT]], <4 x i1> zeroinitializer
141 ; CHECK-NEXT: [[PREDPHI:%.*]] = select <4 x i1> [[TMP0]], <4 x i64> [[VEC_IND]], <4 x i64> undef
142 ; CHECK-NEXT: [[PREDPHI1:%.*]] = select <4 x i1> [[BROADCAST_SPLAT]], <4 x i64> [[PREDPHI]], <4 x i64> undef
143 ; CHECK-NEXT: [[TMP1:%.*]] = extractelement <4 x i64> [[PREDPHI1]], i32 0
144 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds [32 x i16], ptr @dst, i16 0, i64 [[TMP1]]
145 ; CHECK-NEXT: [[TMP3:%.*]] = extractelement <4 x i64> [[PREDPHI1]], i32 1
146 ; CHECK-NEXT: [[TMP4:%.*]] = getelementptr inbounds [32 x i16], ptr @dst, i16 0, i64 [[TMP3]]
147 ; CHECK-NEXT: [[TMP5:%.*]] = extractelement <4 x i64> [[PREDPHI1]], i32 2
148 ; CHECK-NEXT: [[TMP6:%.*]] = getelementptr inbounds [32 x i16], ptr @dst, i16 0, i64 [[TMP5]]
149 ; CHECK-NEXT: [[TMP7:%.*]] = extractelement <4 x i64> [[PREDPHI1]], i32 3
150 ; CHECK-NEXT: [[TMP8:%.*]] = getelementptr inbounds [32 x i16], ptr @dst, i16 0, i64 [[TMP7]]
151 ; CHECK-NEXT: store i16 0, ptr [[TMP2]], align 2
152 ; CHECK-NEXT: store i16 0, ptr [[TMP4]], align 2
153 ; CHECK-NEXT: store i16 0, ptr [[TMP6]], align 2
154 ; CHECK-NEXT: store i16 0, ptr [[TMP8]], align 2
155 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], 4
156 ; CHECK-NEXT: [[VEC_IND_NEXT]] = add <4 x i64> [[VEC_IND]], <i64 4, i64 4, i64 4, i64 4>
157 ; CHECK-NEXT: [[TMP9:%.*]] = icmp eq i64 [[INDEX_NEXT]], 32
158 ; CHECK-NEXT: br i1 [[TMP9]], label %[[MIDDLE_BLOCK:.*]], label %[[VECTOR_BODY]], !llvm.loop [[LOOP6:![0-9]+]]
159 ; CHECK: [[MIDDLE_BLOCK]]:
160 ; CHECK-NEXT: br i1 true, label %[[EXIT:.*]], label %[[SCALAR_PH]]
161 ; CHECK: [[SCALAR_PH]]:
162 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 32, %[[MIDDLE_BLOCK]] ], [ 0, %[[ENTRY]] ]
163 ; CHECK-NEXT: br label %[[LOOP_HEADER:.*]]
164 ; CHECK: [[LOOP_HEADER]]:
165 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], %[[SCALAR_PH]] ], [ [[IV_NEXT:%.*]], %[[LOOP_LATCH:.*]] ]
166 ; CHECK-NEXT: br i1 [[C]], label %[[LOOP_NEXT:.*]], label %[[LOOP_LATCH]]
167 ; CHECK: [[LOOP_NEXT]]:
168 ; CHECK-NEXT: br i1 [[C]], label %[[LOOP_NEXT_2:.*]], label %[[LOOP_NEXT_3:.*]]
169 ; CHECK: [[LOOP_NEXT_2]]:
170 ; CHECK-NEXT: br label %[[LOOP_NEXT_3]]
171 ; CHECK: [[LOOP_NEXT_3]]:
172 ; CHECK-NEXT: [[BLEND_1:%.*]] = phi i64 [ undef, %[[LOOP_NEXT]] ], [ [[IV]], %[[LOOP_NEXT_2]] ]
173 ; CHECK-NEXT: br label %[[LOOP_LATCH]]
174 ; CHECK: [[LOOP_LATCH]]:
175 ; CHECK-NEXT: [[BLEND:%.*]] = phi i64 [ undef, %[[LOOP_HEADER]] ], [ [[BLEND_1]], %[[LOOP_NEXT_3]] ]
176 ; CHECK-NEXT: [[DST_PTR:%.*]] = getelementptr inbounds [32 x i16], ptr @dst, i16 0, i64 [[BLEND]]
177 ; CHECK-NEXT: store i16 0, ptr [[DST_PTR]], align 2
178 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
179 ; CHECK-NEXT: [[CMP439:%.*]] = icmp ult i64 [[IV]], 31
180 ; CHECK-NEXT: br i1 [[CMP439]], label %[[LOOP_HEADER]], label %[[EXIT]], !llvm.loop [[LOOP7:![0-9]+]]
182 ; CHECK-NEXT: ret void
186 br label %loop.header
188 loop.header: ; preds = %loop.latch, %entry
189 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop.latch ]
190 br i1 %c, label %loop.next, label %loop.latch
192 loop.next: ; preds = %loop.header
193 br i1 %c, label %loop.next.2, label %loop.next.3
196 br label %loop.next.3
199 %blend.1 = phi i64 [ undef, %loop.next ], [ %iv, %loop.next.2 ]
202 loop.latch: ; preds = %loop.next, %loop.header
203 %blend = phi i64 [ undef, %loop.header ], [ %blend.1, %loop.next.3 ]
204 %dst.ptr = getelementptr inbounds [32 x i16], ptr @dst, i16 0, i64 %blend
205 store i16 0, ptr %dst.ptr
206 %iv.next = add nuw nsw i64 %iv, 1
207 %cmp439 = icmp ult i64 %iv, 31
208 br i1 %cmp439, label %loop.header, label %exit
210 exit: ; preds = %loop.latch
214 ; CHECK: [[LOOP0]] = distinct !{[[LOOP0]], [[META1:![0-9]+]], [[META2:![0-9]+]]}
215 ; CHECK: [[META1]] = !{!"llvm.loop.isvectorized", i32 1}
216 ; CHECK: [[META2]] = !{!"llvm.loop.unroll.runtime.disable"}
217 ; CHECK: [[LOOP3]] = distinct !{[[LOOP3]], [[META2]], [[META1]]}
218 ; CHECK: [[LOOP4]] = distinct !{[[LOOP4]], [[META1]], [[META2]]}
219 ; CHECK: [[LOOP5]] = distinct !{[[LOOP5]], [[META2]], [[META1]]}
220 ; CHECK: [[LOOP6]] = distinct !{[[LOOP6]], [[META1]], [[META2]]}
221 ; CHECK: [[LOOP7]] = distinct !{[[LOOP7]], [[META2]], [[META1]]}