1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
3 ; RUN: opt < %s -passes=loop-vectorize -force-vector-interleave=2 -epilogue-vectorization-minimum-VF=0 -prefer-predicate-over-epilogue=scalar-epilogue \
4 ; RUN: -debug-only=loop-vectorize -force-target-instruction-cost=1 -S 2>%t | FileCheck %s --check-prefix=CHECK
5 ; RUN: cat %t | FileCheck %s --check-prefix=DEBUG
6 ; RUN: opt < %s -passes=loop-vectorize -force-vector-interleave=2 -epilogue-vectorization-force-VF=8 \
7 ; RUN: -debug-only=loop-vectorize -S 2>%t | FileCheck %s --check-prefix=CHECK-VF8
8 ; RUN: cat %t | FileCheck %s --check-prefix=DEBUG-FORCED
10 target triple = "aarch64-linux-gnu"
12 ; DEBUG: LV: Checking a loop in 'main_vf_vscale_x_16'
13 ; DEBUG: Create Skeleton for epilogue vectorized loop (first pass)
14 ; DEBUG: Main Loop VF:vscale x 16, Main Loop UF:2, Epilogue Loop VF:vscale x 8, Epilogue Loop UF:1
16 ; DEBUG-FORCED: LV: Checking a loop in 'main_vf_vscale_x_16'
17 ; DEBUG-FORCED: LEV: Epilogue vectorization factor is forced.
18 ; DEBUG-FORCED: Create Skeleton for epilogue vectorized loop (first pass)
19 ; DEBUG-FORCED: Main Loop VF:vscale x 16, Main Loop UF:2, Epilogue Loop VF:8, Epilogue Loop UF:1
21 define void @main_vf_vscale_x_16(ptr %A) #0 {
22 ; CHECK-LABEL: @main_vf_vscale_x_16(
23 ; CHECK-NEXT: iter.check:
24 ; CHECK-NEXT: [[TMP0:%.*]] = call i64 @llvm.vscale.i64()
25 ; CHECK-NEXT: [[TMP1:%.*]] = mul i64 [[TMP0]], 8
26 ; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 1024, [[TMP1]]
27 ; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[VEC_EPILOG_SCALAR_PH:%.*]], label [[VECTOR_MAIN_LOOP_ITER_CHECK:%.*]]
28 ; CHECK: vector.main.loop.iter.check:
29 ; CHECK-NEXT: [[TMP2:%.*]] = call i64 @llvm.vscale.i64()
30 ; CHECK-NEXT: [[TMP3:%.*]] = mul i64 [[TMP2]], 32
31 ; CHECK-NEXT: [[MIN_ITERS_CHECK1:%.*]] = icmp ult i64 1024, [[TMP3]]
32 ; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK1]], label [[VEC_EPILOG_PH:%.*]], label [[VECTOR_PH:%.*]]
34 ; CHECK-NEXT: [[TMP4:%.*]] = call i64 @llvm.vscale.i64()
35 ; CHECK-NEXT: [[TMP5:%.*]] = mul i64 [[TMP4]], 32
36 ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 1024, [[TMP5]]
37 ; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 1024, [[N_MOD_VF]]
38 ; CHECK-NEXT: [[TMP6:%.*]] = call i64 @llvm.vscale.i64()
39 ; CHECK-NEXT: [[TMP7:%.*]] = mul i64 [[TMP6]], 32
40 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
42 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
43 ; CHECK-NEXT: [[TMP8:%.*]] = add i64 [[INDEX]], 0
44 ; CHECK-NEXT: [[TMP9:%.*]] = call i64 @llvm.vscale.i64()
45 ; CHECK-NEXT: [[TMP10:%.*]] = mul i64 [[TMP9]], 16
46 ; CHECK-NEXT: [[TMP11:%.*]] = add i64 [[TMP10]], 0
47 ; CHECK-NEXT: [[TMP12:%.*]] = mul i64 [[TMP11]], 1
48 ; CHECK-NEXT: [[TMP13:%.*]] = add i64 [[INDEX]], [[TMP12]]
49 ; CHECK-NEXT: [[TMP14:%.*]] = getelementptr inbounds i8, ptr [[A:%.*]], i64 [[TMP8]]
50 ; CHECK-NEXT: [[TMP15:%.*]] = getelementptr inbounds i8, ptr [[A]], i64 [[TMP13]]
51 ; CHECK-NEXT: [[TMP16:%.*]] = getelementptr inbounds i8, ptr [[TMP14]], i32 0
52 ; CHECK-NEXT: [[TMP17:%.*]] = call i64 @llvm.vscale.i64()
53 ; CHECK-NEXT: [[TMP18:%.*]] = mul i64 [[TMP17]], 16
54 ; CHECK-NEXT: [[TMP19:%.*]] = getelementptr inbounds i8, ptr [[TMP14]], i64 [[TMP18]]
55 ; CHECK-NEXT: store <vscale x 16 x i8> shufflevector (<vscale x 16 x i8> insertelement (<vscale x 16 x i8> poison, i8 1, i64 0), <vscale x 16 x i8> poison, <vscale x 16 x i32> zeroinitializer), ptr [[TMP16]], align 1
56 ; CHECK-NEXT: store <vscale x 16 x i8> shufflevector (<vscale x 16 x i8> insertelement (<vscale x 16 x i8> poison, i8 1, i64 0), <vscale x 16 x i8> poison, <vscale x 16 x i32> zeroinitializer), ptr [[TMP19]], align 1
57 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], [[TMP7]]
58 ; CHECK-NEXT: [[TMP20:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
59 ; CHECK-NEXT: br i1 [[TMP20]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
60 ; CHECK: middle.block:
61 ; CHECK-NEXT: [[CMP_N:%.*]] = icmp eq i64 1024, [[N_VEC]]
62 ; CHECK-NEXT: br i1 [[CMP_N]], label [[EXIT:%.*]], label [[VEC_EPILOG_ITER_CHECK:%.*]]
63 ; CHECK: vec.epilog.iter.check:
64 ; CHECK-NEXT: [[N_VEC_REMAINING:%.*]] = sub i64 1024, [[N_VEC]]
65 ; CHECK-NEXT: [[TMP21:%.*]] = call i64 @llvm.vscale.i64()
66 ; CHECK-NEXT: [[TMP22:%.*]] = mul i64 [[TMP21]], 8
67 ; CHECK-NEXT: [[MIN_EPILOG_ITERS_CHECK:%.*]] = icmp ult i64 [[N_VEC_REMAINING]], [[TMP22]]
68 ; CHECK-NEXT: br i1 [[MIN_EPILOG_ITERS_CHECK]], label [[VEC_EPILOG_SCALAR_PH]], label [[VEC_EPILOG_PH]]
69 ; CHECK: vec.epilog.ph:
70 ; CHECK-NEXT: [[VEC_EPILOG_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], [[VEC_EPILOG_ITER_CHECK]] ], [ 0, [[VECTOR_MAIN_LOOP_ITER_CHECK]] ]
71 ; CHECK-NEXT: [[TMP23:%.*]] = call i64 @llvm.vscale.i64()
72 ; CHECK-NEXT: [[TMP24:%.*]] = mul i64 [[TMP23]], 8
73 ; CHECK-NEXT: [[N_MOD_VF2:%.*]] = urem i64 1024, [[TMP24]]
74 ; CHECK-NEXT: [[N_VEC3:%.*]] = sub i64 1024, [[N_MOD_VF2]]
75 ; CHECK-NEXT: [[TMP25:%.*]] = call i64 @llvm.vscale.i64()
76 ; CHECK-NEXT: [[TMP26:%.*]] = mul i64 [[TMP25]], 8
77 ; CHECK-NEXT: br label [[VEC_EPILOG_VECTOR_BODY:%.*]]
78 ; CHECK: vec.epilog.vector.body:
79 ; CHECK-NEXT: [[INDEX5:%.*]] = phi i64 [ [[VEC_EPILOG_RESUME_VAL]], [[VEC_EPILOG_PH]] ], [ [[INDEX_NEXT6:%.*]], [[VEC_EPILOG_VECTOR_BODY]] ]
80 ; CHECK-NEXT: [[TMP27:%.*]] = add i64 [[INDEX5]], 0
81 ; CHECK-NEXT: [[TMP28:%.*]] = getelementptr inbounds i8, ptr [[A]], i64 [[TMP27]]
82 ; CHECK-NEXT: [[TMP29:%.*]] = getelementptr inbounds i8, ptr [[TMP28]], i32 0
83 ; CHECK-NEXT: store <vscale x 8 x i8> shufflevector (<vscale x 8 x i8> insertelement (<vscale x 8 x i8> poison, i8 1, i64 0), <vscale x 8 x i8> poison, <vscale x 8 x i32> zeroinitializer), ptr [[TMP29]], align 1
84 ; CHECK-NEXT: [[INDEX_NEXT6]] = add nuw i64 [[INDEX5]], [[TMP26]]
85 ; CHECK-NEXT: [[TMP30:%.*]] = icmp eq i64 [[INDEX_NEXT6]], [[N_VEC3]]
86 ; CHECK-NEXT: br i1 [[TMP30]], label [[VEC_EPILOG_MIDDLE_BLOCK:%.*]], label [[VEC_EPILOG_VECTOR_BODY]], !llvm.loop [[LOOP3:![0-9]+]]
87 ; CHECK: vec.epilog.middle.block:
88 ; CHECK-NEXT: [[CMP_N4:%.*]] = icmp eq i64 1024, [[N_VEC3]]
89 ; CHECK-NEXT: br i1 [[CMP_N4]], label [[EXIT]], label [[VEC_EPILOG_SCALAR_PH]]
90 ; CHECK: vec.epilog.scalar.ph:
91 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC3]], [[VEC_EPILOG_MIDDLE_BLOCK]] ], [ [[N_VEC]], [[VEC_EPILOG_ITER_CHECK]] ], [ 0, [[ITER_CHECK:%.*]] ]
92 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
94 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], [[VEC_EPILOG_SCALAR_PH]] ], [ [[IV_NEXT:%.*]], [[FOR_BODY]] ]
95 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i8, ptr [[A]], i64 [[IV]]
96 ; CHECK-NEXT: store i8 1, ptr [[ARRAYIDX]], align 1
97 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
98 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[IV_NEXT]], 1024
99 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_BODY]], label [[EXIT]], !llvm.loop [[LOOP4:![0-9]+]]
101 ; CHECK-NEXT: ret void
103 ; CHECK-VF8-LABEL: @main_vf_vscale_x_16(
104 ; CHECK-VF8-NEXT: iter.check:
105 ; CHECK-VF8-NEXT: br i1 false, label [[VEC_EPILOG_SCALAR_PH:%.*]], label [[VECTOR_MAIN_LOOP_ITER_CHECK:%.*]]
106 ; CHECK-VF8: vector.main.loop.iter.check:
107 ; CHECK-VF8-NEXT: [[TMP0:%.*]] = call i64 @llvm.vscale.i64()
108 ; CHECK-VF8-NEXT: [[TMP1:%.*]] = mul i64 [[TMP0]], 32
109 ; CHECK-VF8-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 1024, [[TMP1]]
110 ; CHECK-VF8-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[VEC_EPILOG_PH:%.*]], label [[VECTOR_PH:%.*]]
111 ; CHECK-VF8: vector.ph:
112 ; CHECK-VF8-NEXT: [[TMP2:%.*]] = call i64 @llvm.vscale.i64()
113 ; CHECK-VF8-NEXT: [[TMP3:%.*]] = mul i64 [[TMP2]], 32
114 ; CHECK-VF8-NEXT: [[N_MOD_VF:%.*]] = urem i64 1024, [[TMP3]]
115 ; CHECK-VF8-NEXT: [[N_VEC:%.*]] = sub i64 1024, [[N_MOD_VF]]
116 ; CHECK-VF8-NEXT: [[TMP4:%.*]] = call i64 @llvm.vscale.i64()
117 ; CHECK-VF8-NEXT: [[TMP5:%.*]] = mul i64 [[TMP4]], 32
118 ; CHECK-VF8-NEXT: br label [[VECTOR_BODY:%.*]]
119 ; CHECK-VF8: vector.body:
120 ; CHECK-VF8-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
121 ; CHECK-VF8-NEXT: [[TMP6:%.*]] = add i64 [[INDEX]], 0
122 ; CHECK-VF8-NEXT: [[TMP7:%.*]] = call i64 @llvm.vscale.i64()
123 ; CHECK-VF8-NEXT: [[TMP8:%.*]] = mul i64 [[TMP7]], 16
124 ; CHECK-VF8-NEXT: [[TMP9:%.*]] = add i64 [[TMP8]], 0
125 ; CHECK-VF8-NEXT: [[TMP10:%.*]] = mul i64 [[TMP9]], 1
126 ; CHECK-VF8-NEXT: [[TMP11:%.*]] = add i64 [[INDEX]], [[TMP10]]
127 ; CHECK-VF8-NEXT: [[TMP12:%.*]] = getelementptr inbounds i8, ptr [[A:%.*]], i64 [[TMP6]]
128 ; CHECK-VF8-NEXT: [[TMP13:%.*]] = getelementptr inbounds i8, ptr [[A]], i64 [[TMP11]]
129 ; CHECK-VF8-NEXT: [[TMP14:%.*]] = getelementptr inbounds i8, ptr [[TMP12]], i32 0
130 ; CHECK-VF8-NEXT: [[TMP15:%.*]] = call i64 @llvm.vscale.i64()
131 ; CHECK-VF8-NEXT: [[TMP16:%.*]] = mul i64 [[TMP15]], 16
132 ; CHECK-VF8-NEXT: [[TMP17:%.*]] = getelementptr inbounds i8, ptr [[TMP12]], i64 [[TMP16]]
133 ; CHECK-VF8-NEXT: store <vscale x 16 x i8> shufflevector (<vscale x 16 x i8> insertelement (<vscale x 16 x i8> poison, i8 1, i64 0), <vscale x 16 x i8> poison, <vscale x 16 x i32> zeroinitializer), ptr [[TMP14]], align 1
134 ; CHECK-VF8-NEXT: store <vscale x 16 x i8> shufflevector (<vscale x 16 x i8> insertelement (<vscale x 16 x i8> poison, i8 1, i64 0), <vscale x 16 x i8> poison, <vscale x 16 x i32> zeroinitializer), ptr [[TMP17]], align 1
135 ; CHECK-VF8-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], [[TMP5]]
136 ; CHECK-VF8-NEXT: [[TMP18:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
137 ; CHECK-VF8-NEXT: br i1 [[TMP18]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP0:![0-9]+]]
138 ; CHECK-VF8: middle.block:
139 ; CHECK-VF8-NEXT: [[CMP_N:%.*]] = icmp eq i64 1024, [[N_VEC]]
140 ; CHECK-VF8-NEXT: br i1 [[CMP_N]], label [[EXIT:%.*]], label [[VEC_EPILOG_ITER_CHECK:%.*]]
141 ; CHECK-VF8: vec.epilog.iter.check:
142 ; CHECK-VF8-NEXT: [[N_VEC_REMAINING:%.*]] = sub i64 1024, [[N_VEC]]
143 ; CHECK-VF8-NEXT: [[MIN_EPILOG_ITERS_CHECK:%.*]] = icmp ult i64 [[N_VEC_REMAINING]], 8
144 ; CHECK-VF8-NEXT: br i1 [[MIN_EPILOG_ITERS_CHECK]], label [[VEC_EPILOG_SCALAR_PH]], label [[VEC_EPILOG_PH]]
145 ; CHECK-VF8: vec.epilog.ph:
146 ; CHECK-VF8-NEXT: [[VEC_EPILOG_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], [[VEC_EPILOG_ITER_CHECK]] ], [ 0, [[VECTOR_MAIN_LOOP_ITER_CHECK]] ]
147 ; CHECK-VF8-NEXT: br label [[VEC_EPILOG_VECTOR_BODY:%.*]]
148 ; CHECK-VF8: vec.epilog.vector.body:
149 ; CHECK-VF8-NEXT: [[INDEX2:%.*]] = phi i64 [ [[VEC_EPILOG_RESUME_VAL]], [[VEC_EPILOG_PH]] ], [ [[INDEX_NEXT3:%.*]], [[VEC_EPILOG_VECTOR_BODY]] ]
150 ; CHECK-VF8-NEXT: [[TMP19:%.*]] = add i64 [[INDEX2]], 0
151 ; CHECK-VF8-NEXT: [[TMP20:%.*]] = getelementptr inbounds i8, ptr [[A]], i64 [[TMP19]]
152 ; CHECK-VF8-NEXT: [[TMP21:%.*]] = getelementptr inbounds i8, ptr [[TMP20]], i32 0
153 ; CHECK-VF8-NEXT: store <8 x i8> <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>, ptr [[TMP21]], align 1
154 ; CHECK-VF8-NEXT: [[INDEX_NEXT3]] = add nuw i64 [[INDEX2]], 8
155 ; CHECK-VF8-NEXT: [[TMP22:%.*]] = icmp eq i64 [[INDEX_NEXT3]], 1024
156 ; CHECK-VF8-NEXT: br i1 [[TMP22]], label [[VEC_EPILOG_MIDDLE_BLOCK:%.*]], label [[VEC_EPILOG_VECTOR_BODY]], !llvm.loop [[LOOP3:![0-9]+]]
157 ; CHECK-VF8: vec.epilog.middle.block:
158 ; CHECK-VF8-NEXT: br i1 true, label [[EXIT]], label [[VEC_EPILOG_SCALAR_PH]]
159 ; CHECK-VF8: vec.epilog.scalar.ph:
160 ; CHECK-VF8-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 1024, [[VEC_EPILOG_MIDDLE_BLOCK]] ], [ [[N_VEC]], [[VEC_EPILOG_ITER_CHECK]] ], [ 0, [[ITER_CHECK:%.*]] ]
161 ; CHECK-VF8-NEXT: br label [[FOR_BODY:%.*]]
162 ; CHECK-VF8: for.body:
163 ; CHECK-VF8-NEXT: [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], [[VEC_EPILOG_SCALAR_PH]] ], [ [[IV_NEXT:%.*]], [[FOR_BODY]] ]
164 ; CHECK-VF8-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i8, ptr [[A]], i64 [[IV]]
165 ; CHECK-VF8-NEXT: store i8 1, ptr [[ARRAYIDX]], align 1
166 ; CHECK-VF8-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
167 ; CHECK-VF8-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[IV_NEXT]], 1024
168 ; CHECK-VF8-NEXT: br i1 [[EXITCOND]], label [[FOR_BODY]], label [[EXIT]], !llvm.loop [[LOOP4:![0-9]+]]
170 ; CHECK-VF8-NEXT: ret void
176 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
177 %arrayidx = getelementptr inbounds i8, ptr %A, i64 %iv
178 store i8 1, ptr %arrayidx, align 1
179 %iv.next = add nuw nsw i64 %iv, 1
180 %exitcond = icmp ne i64 %iv.next, 1024
181 br i1 %exitcond, label %for.body, label %exit
188 ; DEBUG: LV: Checking a loop in 'main_vf_vscale_x_2'
189 ; DEBUG: Create Skeleton for epilogue vectorized loop (first pass)
190 ; DEBUG: Main Loop VF:vscale x 2, Main Loop UF:2, Epilogue Loop VF:8, Epilogue Loop UF:1
192 ; DEBUG-FORCED: LV: Checking a loop in 'main_vf_vscale_x_2'
193 ; DEBUG-FORCED: LEV: Epilogue vectorization factor is forced.
194 ; DEBUG-FORCED: Create Skeleton for epilogue vectorized loop (first pass)
195 ; DEBUG-FORCED: Main Loop VF:vscale x 2, Main Loop UF:2, Epilogue Loop VF:8, Epilogue Loop UF:1
197 ; When the vector.body uses VF=vscale x 1 (or VF=vscale x 2 because
198 ; that's the minimum supported VF by SVE), we could still use a wide
199 ; fixed-width VF=8 for the epilogue if the vectors are known to be
200 ; sufficiently wide. This information can be deduced from vscale_range or
201 ; VScaleForTuning (set by mcpu/mtune).
202 define void @main_vf_vscale_x_2(ptr %A) #0 vscale_range(8, 8) {
203 ; CHECK-LABEL: @main_vf_vscale_x_2(
204 ; CHECK-NEXT: iter.check:
205 ; CHECK-NEXT: br i1 false, label [[VEC_EPILOG_SCALAR_PH:%.*]], label [[VECTOR_MAIN_LOOP_ITER_CHECK:%.*]]
206 ; CHECK: vector.main.loop.iter.check:
207 ; CHECK-NEXT: [[TMP0:%.*]] = call i64 @llvm.vscale.i64()
208 ; CHECK-NEXT: [[TMP1:%.*]] = mul i64 [[TMP0]], 4
209 ; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 1024, [[TMP1]]
210 ; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[VEC_EPILOG_PH:%.*]], label [[VECTOR_PH:%.*]]
212 ; CHECK-NEXT: [[TMP2:%.*]] = call i64 @llvm.vscale.i64()
213 ; CHECK-NEXT: [[TMP3:%.*]] = mul i64 [[TMP2]], 4
214 ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 1024, [[TMP3]]
215 ; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 1024, [[N_MOD_VF]]
216 ; CHECK-NEXT: [[TMP4:%.*]] = call i64 @llvm.vscale.i64()
217 ; CHECK-NEXT: [[TMP5:%.*]] = mul i64 [[TMP4]], 4
218 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
219 ; CHECK: vector.body:
220 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
221 ; CHECK-NEXT: [[TMP6:%.*]] = add i64 [[INDEX]], 0
222 ; CHECK-NEXT: [[TMP7:%.*]] = call i64 @llvm.vscale.i64()
223 ; CHECK-NEXT: [[TMP8:%.*]] = mul i64 [[TMP7]], 2
224 ; CHECK-NEXT: [[TMP9:%.*]] = add i64 [[TMP8]], 0
225 ; CHECK-NEXT: [[TMP10:%.*]] = mul i64 [[TMP9]], 1
226 ; CHECK-NEXT: [[TMP11:%.*]] = add i64 [[INDEX]], [[TMP10]]
227 ; CHECK-NEXT: [[TMP12:%.*]] = getelementptr inbounds i64, ptr [[A:%.*]], i64 [[TMP6]]
228 ; CHECK-NEXT: [[TMP13:%.*]] = getelementptr inbounds i64, ptr [[A]], i64 [[TMP11]]
229 ; CHECK-NEXT: [[TMP14:%.*]] = getelementptr inbounds i64, ptr [[TMP12]], i32 0
230 ; CHECK-NEXT: [[TMP15:%.*]] = call i64 @llvm.vscale.i64()
231 ; CHECK-NEXT: [[TMP16:%.*]] = mul i64 [[TMP15]], 2
232 ; CHECK-NEXT: [[TMP17:%.*]] = getelementptr inbounds i64, ptr [[TMP12]], i64 [[TMP16]]
233 ; CHECK-NEXT: store <vscale x 2 x i64> shufflevector (<vscale x 2 x i64> insertelement (<vscale x 2 x i64> poison, i64 1, i64 0), <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer), ptr [[TMP14]], align 1
234 ; CHECK-NEXT: store <vscale x 2 x i64> shufflevector (<vscale x 2 x i64> insertelement (<vscale x 2 x i64> poison, i64 1, i64 0), <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer), ptr [[TMP17]], align 1
235 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], [[TMP5]]
236 ; CHECK-NEXT: [[TMP18:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
237 ; CHECK-NEXT: br i1 [[TMP18]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP5:![0-9]+]]
238 ; CHECK: middle.block:
239 ; CHECK-NEXT: [[CMP_N:%.*]] = icmp eq i64 1024, [[N_VEC]]
240 ; CHECK-NEXT: br i1 [[CMP_N]], label [[EXIT:%.*]], label [[VEC_EPILOG_ITER_CHECK:%.*]]
241 ; CHECK: vec.epilog.iter.check:
242 ; CHECK-NEXT: [[N_VEC_REMAINING:%.*]] = sub i64 1024, [[N_VEC]]
243 ; CHECK-NEXT: [[MIN_EPILOG_ITERS_CHECK:%.*]] = icmp ult i64 [[N_VEC_REMAINING]], 8
244 ; CHECK-NEXT: br i1 [[MIN_EPILOG_ITERS_CHECK]], label [[VEC_EPILOG_SCALAR_PH]], label [[VEC_EPILOG_PH]]
245 ; CHECK: vec.epilog.ph:
246 ; CHECK-NEXT: [[VEC_EPILOG_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], [[VEC_EPILOG_ITER_CHECK]] ], [ 0, [[VECTOR_MAIN_LOOP_ITER_CHECK]] ]
247 ; CHECK-NEXT: br label [[VEC_EPILOG_VECTOR_BODY:%.*]]
248 ; CHECK: vec.epilog.vector.body:
249 ; CHECK-NEXT: [[INDEX2:%.*]] = phi i64 [ [[VEC_EPILOG_RESUME_VAL]], [[VEC_EPILOG_PH]] ], [ [[INDEX_NEXT3:%.*]], [[VEC_EPILOG_VECTOR_BODY]] ]
250 ; CHECK-NEXT: [[TMP19:%.*]] = add i64 [[INDEX2]], 0
251 ; CHECK-NEXT: [[TMP20:%.*]] = getelementptr inbounds i64, ptr [[A]], i64 [[TMP19]]
252 ; CHECK-NEXT: [[TMP21:%.*]] = getelementptr inbounds i64, ptr [[TMP20]], i32 0
253 ; CHECK-NEXT: store <8 x i64> <i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1>, ptr [[TMP21]], align 1
254 ; CHECK-NEXT: [[INDEX_NEXT3]] = add nuw i64 [[INDEX2]], 8
255 ; CHECK-NEXT: [[TMP22:%.*]] = icmp eq i64 [[INDEX_NEXT3]], 1024
256 ; CHECK-NEXT: br i1 [[TMP22]], label [[VEC_EPILOG_MIDDLE_BLOCK:%.*]], label [[VEC_EPILOG_VECTOR_BODY]], !llvm.loop [[LOOP6:![0-9]+]]
257 ; CHECK: vec.epilog.middle.block:
258 ; CHECK-NEXT: br i1 true, label [[EXIT]], label [[VEC_EPILOG_SCALAR_PH]]
259 ; CHECK: vec.epilog.scalar.ph:
260 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 1024, [[VEC_EPILOG_MIDDLE_BLOCK]] ], [ [[N_VEC]], [[VEC_EPILOG_ITER_CHECK]] ], [ 0, [[ITER_CHECK:%.*]] ]
261 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
263 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], [[VEC_EPILOG_SCALAR_PH]] ], [ [[IV_NEXT:%.*]], [[FOR_BODY]] ]
264 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i64, ptr [[A]], i64 [[IV]]
265 ; CHECK-NEXT: store i64 1, ptr [[ARRAYIDX]], align 1
266 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
267 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[IV_NEXT]], 1024
268 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[FOR_BODY]], label [[EXIT]], !llvm.loop [[LOOP7:![0-9]+]]
270 ; CHECK-NEXT: ret void
272 ; CHECK-VF8-LABEL: @main_vf_vscale_x_2(
273 ; CHECK-VF8-NEXT: iter.check:
274 ; CHECK-VF8-NEXT: br i1 false, label [[VEC_EPILOG_SCALAR_PH:%.*]], label [[VECTOR_MAIN_LOOP_ITER_CHECK:%.*]]
275 ; CHECK-VF8: vector.main.loop.iter.check:
276 ; CHECK-VF8-NEXT: [[TMP0:%.*]] = call i64 @llvm.vscale.i64()
277 ; CHECK-VF8-NEXT: [[TMP1:%.*]] = mul i64 [[TMP0]], 4
278 ; CHECK-VF8-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 1024, [[TMP1]]
279 ; CHECK-VF8-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[VEC_EPILOG_PH:%.*]], label [[VECTOR_PH:%.*]]
280 ; CHECK-VF8: vector.ph:
281 ; CHECK-VF8-NEXT: [[TMP2:%.*]] = call i64 @llvm.vscale.i64()
282 ; CHECK-VF8-NEXT: [[TMP3:%.*]] = mul i64 [[TMP2]], 4
283 ; CHECK-VF8-NEXT: [[N_MOD_VF:%.*]] = urem i64 1024, [[TMP3]]
284 ; CHECK-VF8-NEXT: [[N_VEC:%.*]] = sub i64 1024, [[N_MOD_VF]]
285 ; CHECK-VF8-NEXT: [[TMP4:%.*]] = call i64 @llvm.vscale.i64()
286 ; CHECK-VF8-NEXT: [[TMP5:%.*]] = mul i64 [[TMP4]], 4
287 ; CHECK-VF8-NEXT: br label [[VECTOR_BODY:%.*]]
288 ; CHECK-VF8: vector.body:
289 ; CHECK-VF8-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
290 ; CHECK-VF8-NEXT: [[TMP6:%.*]] = add i64 [[INDEX]], 0
291 ; CHECK-VF8-NEXT: [[TMP7:%.*]] = call i64 @llvm.vscale.i64()
292 ; CHECK-VF8-NEXT: [[TMP8:%.*]] = mul i64 [[TMP7]], 2
293 ; CHECK-VF8-NEXT: [[TMP9:%.*]] = add i64 [[TMP8]], 0
294 ; CHECK-VF8-NEXT: [[TMP10:%.*]] = mul i64 [[TMP9]], 1
295 ; CHECK-VF8-NEXT: [[TMP11:%.*]] = add i64 [[INDEX]], [[TMP10]]
296 ; CHECK-VF8-NEXT: [[TMP12:%.*]] = getelementptr inbounds i64, ptr [[A:%.*]], i64 [[TMP6]]
297 ; CHECK-VF8-NEXT: [[TMP13:%.*]] = getelementptr inbounds i64, ptr [[A]], i64 [[TMP11]]
298 ; CHECK-VF8-NEXT: [[TMP14:%.*]] = getelementptr inbounds i64, ptr [[TMP12]], i32 0
299 ; CHECK-VF8-NEXT: [[TMP15:%.*]] = call i64 @llvm.vscale.i64()
300 ; CHECK-VF8-NEXT: [[TMP16:%.*]] = mul i64 [[TMP15]], 2
301 ; CHECK-VF8-NEXT: [[TMP17:%.*]] = getelementptr inbounds i64, ptr [[TMP12]], i64 [[TMP16]]
302 ; CHECK-VF8-NEXT: store <vscale x 2 x i64> shufflevector (<vscale x 2 x i64> insertelement (<vscale x 2 x i64> poison, i64 1, i64 0), <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer), ptr [[TMP14]], align 1
303 ; CHECK-VF8-NEXT: store <vscale x 2 x i64> shufflevector (<vscale x 2 x i64> insertelement (<vscale x 2 x i64> poison, i64 1, i64 0), <vscale x 2 x i64> poison, <vscale x 2 x i32> zeroinitializer), ptr [[TMP17]], align 1
304 ; CHECK-VF8-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], [[TMP5]]
305 ; CHECK-VF8-NEXT: [[TMP18:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
306 ; CHECK-VF8-NEXT: br i1 [[TMP18]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP5:![0-9]+]]
307 ; CHECK-VF8: middle.block:
308 ; CHECK-VF8-NEXT: [[CMP_N:%.*]] = icmp eq i64 1024, [[N_VEC]]
309 ; CHECK-VF8-NEXT: br i1 [[CMP_N]], label [[EXIT:%.*]], label [[VEC_EPILOG_ITER_CHECK:%.*]]
310 ; CHECK-VF8: vec.epilog.iter.check:
311 ; CHECK-VF8-NEXT: [[N_VEC_REMAINING:%.*]] = sub i64 1024, [[N_VEC]]
312 ; CHECK-VF8-NEXT: [[MIN_EPILOG_ITERS_CHECK:%.*]] = icmp ult i64 [[N_VEC_REMAINING]], 8
313 ; CHECK-VF8-NEXT: br i1 [[MIN_EPILOG_ITERS_CHECK]], label [[VEC_EPILOG_SCALAR_PH]], label [[VEC_EPILOG_PH]]
314 ; CHECK-VF8: vec.epilog.ph:
315 ; CHECK-VF8-NEXT: [[VEC_EPILOG_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], [[VEC_EPILOG_ITER_CHECK]] ], [ 0, [[VECTOR_MAIN_LOOP_ITER_CHECK]] ]
316 ; CHECK-VF8-NEXT: br label [[VEC_EPILOG_VECTOR_BODY:%.*]]
317 ; CHECK-VF8: vec.epilog.vector.body:
318 ; CHECK-VF8-NEXT: [[INDEX2:%.*]] = phi i64 [ [[VEC_EPILOG_RESUME_VAL]], [[VEC_EPILOG_PH]] ], [ [[INDEX_NEXT3:%.*]], [[VEC_EPILOG_VECTOR_BODY]] ]
319 ; CHECK-VF8-NEXT: [[TMP19:%.*]] = add i64 [[INDEX2]], 0
320 ; CHECK-VF8-NEXT: [[TMP20:%.*]] = getelementptr inbounds i64, ptr [[A]], i64 [[TMP19]]
321 ; CHECK-VF8-NEXT: [[TMP21:%.*]] = getelementptr inbounds i64, ptr [[TMP20]], i32 0
322 ; CHECK-VF8-NEXT: store <8 x i64> <i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1, i64 1>, ptr [[TMP21]], align 1
323 ; CHECK-VF8-NEXT: [[INDEX_NEXT3]] = add nuw i64 [[INDEX2]], 8
324 ; CHECK-VF8-NEXT: [[TMP22:%.*]] = icmp eq i64 [[INDEX_NEXT3]], 1024
325 ; CHECK-VF8-NEXT: br i1 [[TMP22]], label [[VEC_EPILOG_MIDDLE_BLOCK:%.*]], label [[VEC_EPILOG_VECTOR_BODY]], !llvm.loop [[LOOP6:![0-9]+]]
326 ; CHECK-VF8: vec.epilog.middle.block:
327 ; CHECK-VF8-NEXT: br i1 true, label [[EXIT]], label [[VEC_EPILOG_SCALAR_PH]]
328 ; CHECK-VF8: vec.epilog.scalar.ph:
329 ; CHECK-VF8-NEXT: [[BC_RESUME_VAL:%.*]] = phi i64 [ 1024, [[VEC_EPILOG_MIDDLE_BLOCK]] ], [ [[N_VEC]], [[VEC_EPILOG_ITER_CHECK]] ], [ 0, [[ITER_CHECK:%.*]] ]
330 ; CHECK-VF8-NEXT: br label [[FOR_BODY:%.*]]
331 ; CHECK-VF8: for.body:
332 ; CHECK-VF8-NEXT: [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL]], [[VEC_EPILOG_SCALAR_PH]] ], [ [[IV_NEXT:%.*]], [[FOR_BODY]] ]
333 ; CHECK-VF8-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i64, ptr [[A]], i64 [[IV]]
334 ; CHECK-VF8-NEXT: store i64 1, ptr [[ARRAYIDX]], align 1
335 ; CHECK-VF8-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
336 ; CHECK-VF8-NEXT: [[EXITCOND:%.*]] = icmp ne i64 [[IV_NEXT]], 1024
337 ; CHECK-VF8-NEXT: br i1 [[EXITCOND]], label [[FOR_BODY]], label [[EXIT]], !llvm.loop [[LOOP7:![0-9]+]]
339 ; CHECK-VF8-NEXT: ret void
345 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
346 %arrayidx = getelementptr inbounds i64, ptr %A, i64 %iv
347 store i64 1, ptr %arrayidx, align 1
348 %iv.next = add nuw nsw i64 %iv, 1
349 %exitcond = icmp ne i64 %iv.next, 1024
350 br i1 %exitcond, label %for.body, label %exit
356 ; FIXME: The epilogue loop is currently miscompiled: the pointer induction
357 ; uses an incorrect resume value.
358 define void @test_pr57912_pointer_induction(ptr %start) #0 {
359 ; CHECK-LABEL: @test_pr57912_pointer_induction(
360 ; CHECK-NEXT: iter.check:
361 ; CHECK-NEXT: [[TMP0:%.*]] = call i64 @llvm.vscale.i64()
362 ; CHECK-NEXT: [[TMP1:%.*]] = mul i64 [[TMP0]], 8
363 ; CHECK-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 10000, [[TMP1]]
364 ; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[VEC_EPILOG_SCALAR_PH:%.*]], label [[VECTOR_MAIN_LOOP_ITER_CHECK:%.*]]
365 ; CHECK: vector.main.loop.iter.check:
366 ; CHECK-NEXT: [[TMP2:%.*]] = call i64 @llvm.vscale.i64()
367 ; CHECK-NEXT: [[TMP3:%.*]] = mul i64 [[TMP2]], 32
368 ; CHECK-NEXT: [[MIN_ITERS_CHECK1:%.*]] = icmp ult i64 10000, [[TMP3]]
369 ; CHECK-NEXT: br i1 [[MIN_ITERS_CHECK1]], label [[VEC_EPILOG_PH:%.*]], label [[VECTOR_PH:%.*]]
371 ; CHECK-NEXT: [[TMP4:%.*]] = call i64 @llvm.vscale.i64()
372 ; CHECK-NEXT: [[TMP5:%.*]] = mul i64 [[TMP4]], 32
373 ; CHECK-NEXT: [[N_MOD_VF:%.*]] = urem i64 10000, [[TMP5]]
374 ; CHECK-NEXT: [[N_VEC:%.*]] = sub i64 10000, [[N_MOD_VF]]
375 ; CHECK-NEXT: [[TMP6:%.*]] = call i64 @llvm.vscale.i64()
376 ; CHECK-NEXT: [[TMP7:%.*]] = mul i64 [[TMP6]], 32
377 ; CHECK-NEXT: [[IND_END:%.*]] = getelementptr i8, ptr [[START:%.*]], i64 [[N_VEC]]
378 ; CHECK-NEXT: br label [[VECTOR_BODY:%.*]]
379 ; CHECK: vector.body:
380 ; CHECK-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
381 ; CHECK-NEXT: [[TMP8:%.*]] = add i64 [[INDEX]], 0
382 ; CHECK-NEXT: [[NEXT_GEP:%.*]] = getelementptr i8, ptr [[START]], i64 [[TMP8]]
383 ; CHECK-NEXT: [[TMP9:%.*]] = call i64 @llvm.vscale.i64()
384 ; CHECK-NEXT: [[TMP10:%.*]] = mul i64 [[TMP9]], 16
385 ; CHECK-NEXT: [[TMP11:%.*]] = add i64 [[TMP10]], 0
386 ; CHECK-NEXT: [[TMP12:%.*]] = add i64 [[INDEX]], [[TMP11]]
387 ; CHECK-NEXT: [[NEXT_GEP2:%.*]] = getelementptr i8, ptr [[START]], i64 [[TMP12]]
388 ; CHECK-NEXT: [[TMP13:%.*]] = getelementptr i8, ptr [[NEXT_GEP]], i32 0
389 ; CHECK-NEXT: [[TMP14:%.*]] = call i64 @llvm.vscale.i64()
390 ; CHECK-NEXT: [[TMP15:%.*]] = mul i64 [[TMP14]], 16
391 ; CHECK-NEXT: [[TMP16:%.*]] = getelementptr i8, ptr [[NEXT_GEP]], i64 [[TMP15]]
392 ; CHECK-NEXT: store <vscale x 16 x i8> zeroinitializer, ptr [[TMP13]], align 1
393 ; CHECK-NEXT: store <vscale x 16 x i8> zeroinitializer, ptr [[TMP16]], align 1
394 ; CHECK-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], [[TMP7]]
395 ; CHECK-NEXT: [[TMP17:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
396 ; CHECK-NEXT: br i1 [[TMP17]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP8:![0-9]+]]
397 ; CHECK: middle.block:
398 ; CHECK-NEXT: [[CMP_N:%.*]] = icmp eq i64 10000, [[N_VEC]]
399 ; CHECK-NEXT: br i1 [[CMP_N]], label [[EXIT:%.*]], label [[VEC_EPILOG_ITER_CHECK:%.*]]
400 ; CHECK: vec.epilog.iter.check:
401 ; CHECK-NEXT: [[IND_END7:%.*]] = getelementptr i8, ptr [[START]], i64 [[N_VEC]]
402 ; CHECK-NEXT: [[N_VEC_REMAINING:%.*]] = sub i64 10000, [[N_VEC]]
403 ; CHECK-NEXT: [[TMP18:%.*]] = call i64 @llvm.vscale.i64()
404 ; CHECK-NEXT: [[TMP19:%.*]] = mul i64 [[TMP18]], 8
405 ; CHECK-NEXT: [[MIN_EPILOG_ITERS_CHECK:%.*]] = icmp ult i64 [[N_VEC_REMAINING]], [[TMP19]]
406 ; CHECK-NEXT: br i1 [[MIN_EPILOG_ITERS_CHECK]], label [[VEC_EPILOG_SCALAR_PH]], label [[VEC_EPILOG_PH]]
407 ; CHECK: vec.epilog.ph:
408 ; CHECK-NEXT: [[BC_RESUME_VAL:%.*]] = phi ptr [ [[IND_END]], [[VEC_EPILOG_ITER_CHECK]] ], [ [[START]], [[VECTOR_MAIN_LOOP_ITER_CHECK]] ]
409 ; CHECK-NEXT: [[VEC_EPILOG_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], [[VEC_EPILOG_ITER_CHECK]] ], [ 0, [[VECTOR_MAIN_LOOP_ITER_CHECK]] ]
410 ; CHECK-NEXT: [[TMP20:%.*]] = call i64 @llvm.vscale.i64()
411 ; CHECK-NEXT: [[TMP21:%.*]] = mul i64 [[TMP20]], 8
412 ; CHECK-NEXT: [[N_MOD_VF3:%.*]] = urem i64 10000, [[TMP21]]
413 ; CHECK-NEXT: [[N_VEC4:%.*]] = sub i64 10000, [[N_MOD_VF3]]
414 ; CHECK-NEXT: [[IND_END6:%.*]] = getelementptr i8, ptr [[START]], i64 [[N_VEC4]]
415 ; CHECK-NEXT: [[TMP22:%.*]] = call i64 @llvm.vscale.i64()
416 ; CHECK-NEXT: [[TMP23:%.*]] = mul i64 [[TMP22]], 8
417 ; CHECK-NEXT: br label [[VEC_EPILOG_VECTOR_BODY:%.*]]
418 ; CHECK: vec.epilog.vector.body:
419 ; CHECK-NEXT: [[INDEX10:%.*]] = phi i64 [ [[VEC_EPILOG_RESUME_VAL]], [[VEC_EPILOG_PH]] ], [ [[INDEX_NEXT12:%.*]], [[VEC_EPILOG_VECTOR_BODY]] ]
420 ; CHECK-NEXT: [[TMP24:%.*]] = add i64 [[INDEX10]], 0
421 ; CHECK-NEXT: [[NEXT_GEP11:%.*]] = getelementptr i8, ptr [[START]], i64 [[TMP24]]
422 ; CHECK-NEXT: [[TMP25:%.*]] = getelementptr i8, ptr [[NEXT_GEP11]], i32 0
423 ; CHECK-NEXT: store <vscale x 8 x i8> zeroinitializer, ptr [[TMP25]], align 1
424 ; CHECK-NEXT: [[INDEX_NEXT12]] = add nuw i64 [[INDEX10]], [[TMP23]]
425 ; CHECK-NEXT: [[TMP26:%.*]] = icmp eq i64 [[INDEX_NEXT12]], [[N_VEC4]]
426 ; CHECK-NEXT: br i1 [[TMP26]], label [[VEC_EPILOG_MIDDLE_BLOCK:%.*]], label [[VEC_EPILOG_VECTOR_BODY]], !llvm.loop [[LOOP9:![0-9]+]]
427 ; CHECK: vec.epilog.middle.block:
428 ; CHECK-NEXT: [[CMP_N9:%.*]] = icmp eq i64 10000, [[N_VEC4]]
429 ; CHECK-NEXT: br i1 [[CMP_N9]], label [[EXIT]], label [[VEC_EPILOG_SCALAR_PH]]
430 ; CHECK: vec.epilog.scalar.ph:
431 ; CHECK-NEXT: [[BC_RESUME_VAL5:%.*]] = phi i64 [ [[N_VEC4]], [[VEC_EPILOG_MIDDLE_BLOCK]] ], [ [[N_VEC]], [[VEC_EPILOG_ITER_CHECK]] ], [ 0, [[ITER_CHECK:%.*]] ]
432 ; CHECK-NEXT: [[BC_RESUME_VAL8:%.*]] = phi ptr [ [[IND_END6]], [[VEC_EPILOG_MIDDLE_BLOCK]] ], [ [[IND_END7]], [[VEC_EPILOG_ITER_CHECK]] ], [ [[START]], [[ITER_CHECK]] ]
433 ; CHECK-NEXT: br label [[LOOP:%.*]]
435 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL5]], [[VEC_EPILOG_SCALAR_PH]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
436 ; CHECK-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[BC_RESUME_VAL8]], [[VEC_EPILOG_SCALAR_PH]] ], [ [[PTR_IV_NEXT:%.*]], [[LOOP]] ]
437 ; CHECK-NEXT: store i8 0, ptr [[PTR_IV]], align 1
438 ; CHECK-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i8, ptr [[PTR_IV]], i64 1
439 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
440 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[IV_NEXT]], 10000
441 ; CHECK-NEXT: br i1 [[CMP]], label [[EXIT]], label [[LOOP]], !llvm.loop [[LOOP10:![0-9]+]]
443 ; CHECK-NEXT: ret void
445 ; CHECK-VF8-LABEL: @test_pr57912_pointer_induction(
446 ; CHECK-VF8-NEXT: iter.check:
447 ; CHECK-VF8-NEXT: br i1 false, label [[VEC_EPILOG_SCALAR_PH:%.*]], label [[VECTOR_MAIN_LOOP_ITER_CHECK:%.*]]
448 ; CHECK-VF8: vector.main.loop.iter.check:
449 ; CHECK-VF8-NEXT: [[TMP0:%.*]] = call i64 @llvm.vscale.i64()
450 ; CHECK-VF8-NEXT: [[TMP1:%.*]] = mul i64 [[TMP0]], 32
451 ; CHECK-VF8-NEXT: [[MIN_ITERS_CHECK:%.*]] = icmp ult i64 10000, [[TMP1]]
452 ; CHECK-VF8-NEXT: br i1 [[MIN_ITERS_CHECK]], label [[VEC_EPILOG_PH:%.*]], label [[VECTOR_PH:%.*]]
453 ; CHECK-VF8: vector.ph:
454 ; CHECK-VF8-NEXT: [[TMP2:%.*]] = call i64 @llvm.vscale.i64()
455 ; CHECK-VF8-NEXT: [[TMP3:%.*]] = mul i64 [[TMP2]], 32
456 ; CHECK-VF8-NEXT: [[N_MOD_VF:%.*]] = urem i64 10000, [[TMP3]]
457 ; CHECK-VF8-NEXT: [[N_VEC:%.*]] = sub i64 10000, [[N_MOD_VF]]
458 ; CHECK-VF8-NEXT: [[TMP4:%.*]] = call i64 @llvm.vscale.i64()
459 ; CHECK-VF8-NEXT: [[TMP5:%.*]] = mul i64 [[TMP4]], 32
460 ; CHECK-VF8-NEXT: [[IND_END:%.*]] = getelementptr i8, ptr [[START:%.*]], i64 [[N_VEC]]
461 ; CHECK-VF8-NEXT: br label [[VECTOR_BODY:%.*]]
462 ; CHECK-VF8: vector.body:
463 ; CHECK-VF8-NEXT: [[INDEX:%.*]] = phi i64 [ 0, [[VECTOR_PH]] ], [ [[INDEX_NEXT:%.*]], [[VECTOR_BODY]] ]
464 ; CHECK-VF8-NEXT: [[TMP6:%.*]] = add i64 [[INDEX]], 0
465 ; CHECK-VF8-NEXT: [[NEXT_GEP:%.*]] = getelementptr i8, ptr [[START]], i64 [[TMP6]]
466 ; CHECK-VF8-NEXT: [[TMP7:%.*]] = call i64 @llvm.vscale.i64()
467 ; CHECK-VF8-NEXT: [[TMP8:%.*]] = mul i64 [[TMP7]], 16
468 ; CHECK-VF8-NEXT: [[TMP9:%.*]] = add i64 [[TMP8]], 0
469 ; CHECK-VF8-NEXT: [[TMP10:%.*]] = add i64 [[INDEX]], [[TMP9]]
470 ; CHECK-VF8-NEXT: [[NEXT_GEP1:%.*]] = getelementptr i8, ptr [[START]], i64 [[TMP10]]
471 ; CHECK-VF8-NEXT: [[TMP11:%.*]] = getelementptr i8, ptr [[NEXT_GEP]], i32 0
472 ; CHECK-VF8-NEXT: [[TMP12:%.*]] = call i64 @llvm.vscale.i64()
473 ; CHECK-VF8-NEXT: [[TMP13:%.*]] = mul i64 [[TMP12]], 16
474 ; CHECK-VF8-NEXT: [[TMP14:%.*]] = getelementptr i8, ptr [[NEXT_GEP]], i64 [[TMP13]]
475 ; CHECK-VF8-NEXT: store <vscale x 16 x i8> zeroinitializer, ptr [[TMP11]], align 1
476 ; CHECK-VF8-NEXT: store <vscale x 16 x i8> zeroinitializer, ptr [[TMP14]], align 1
477 ; CHECK-VF8-NEXT: [[INDEX_NEXT]] = add nuw i64 [[INDEX]], [[TMP5]]
478 ; CHECK-VF8-NEXT: [[TMP15:%.*]] = icmp eq i64 [[INDEX_NEXT]], [[N_VEC]]
479 ; CHECK-VF8-NEXT: br i1 [[TMP15]], label [[MIDDLE_BLOCK:%.*]], label [[VECTOR_BODY]], !llvm.loop [[LOOP8:![0-9]+]]
480 ; CHECK-VF8: middle.block:
481 ; CHECK-VF8-NEXT: [[CMP_N:%.*]] = icmp eq i64 10000, [[N_VEC]]
482 ; CHECK-VF8-NEXT: br i1 [[CMP_N]], label [[EXIT:%.*]], label [[VEC_EPILOG_ITER_CHECK:%.*]]
483 ; CHECK-VF8: vec.epilog.iter.check:
484 ; CHECK-VF8-NEXT: [[IND_END4:%.*]] = getelementptr i8, ptr [[START]], i64 [[N_VEC]]
485 ; CHECK-VF8-NEXT: [[N_VEC_REMAINING:%.*]] = sub i64 10000, [[N_VEC]]
486 ; CHECK-VF8-NEXT: [[MIN_EPILOG_ITERS_CHECK:%.*]] = icmp ult i64 [[N_VEC_REMAINING]], 8
487 ; CHECK-VF8-NEXT: br i1 [[MIN_EPILOG_ITERS_CHECK]], label [[VEC_EPILOG_SCALAR_PH]], label [[VEC_EPILOG_PH]]
488 ; CHECK-VF8: vec.epilog.ph:
489 ; CHECK-VF8-NEXT: [[BC_RESUME_VAL:%.*]] = phi ptr [ [[IND_END]], [[VEC_EPILOG_ITER_CHECK]] ], [ [[START]], [[VECTOR_MAIN_LOOP_ITER_CHECK]] ]
490 ; CHECK-VF8-NEXT: [[VEC_EPILOG_RESUME_VAL:%.*]] = phi i64 [ [[N_VEC]], [[VEC_EPILOG_ITER_CHECK]] ], [ 0, [[VECTOR_MAIN_LOOP_ITER_CHECK]] ]
491 ; CHECK-VF8-NEXT: [[IND_END3:%.*]] = getelementptr i8, ptr [[START]], i64 10000
492 ; CHECK-VF8-NEXT: br label [[VEC_EPILOG_VECTOR_BODY:%.*]]
493 ; CHECK-VF8: vec.epilog.vector.body:
494 ; CHECK-VF8-NEXT: [[INDEX7:%.*]] = phi i64 [ [[VEC_EPILOG_RESUME_VAL]], [[VEC_EPILOG_PH]] ], [ [[INDEX_NEXT9:%.*]], [[VEC_EPILOG_VECTOR_BODY]] ]
495 ; CHECK-VF8-NEXT: [[TMP16:%.*]] = add i64 [[INDEX7]], 0
496 ; CHECK-VF8-NEXT: [[NEXT_GEP8:%.*]] = getelementptr i8, ptr [[START]], i64 [[TMP16]]
497 ; CHECK-VF8-NEXT: [[TMP17:%.*]] = getelementptr i8, ptr [[NEXT_GEP8]], i32 0
498 ; CHECK-VF8-NEXT: store <8 x i8> zeroinitializer, ptr [[TMP17]], align 1
499 ; CHECK-VF8-NEXT: [[INDEX_NEXT9]] = add nuw i64 [[INDEX7]], 8
500 ; CHECK-VF8-NEXT: [[TMP18:%.*]] = icmp eq i64 [[INDEX_NEXT9]], 10000
501 ; CHECK-VF8-NEXT: br i1 [[TMP18]], label [[VEC_EPILOG_MIDDLE_BLOCK:%.*]], label [[VEC_EPILOG_VECTOR_BODY]], !llvm.loop [[LOOP9:![0-9]+]]
502 ; CHECK-VF8: vec.epilog.middle.block:
503 ; CHECK-VF8-NEXT: br i1 true, label [[EXIT]], label [[VEC_EPILOG_SCALAR_PH]]
504 ; CHECK-VF8: vec.epilog.scalar.ph:
505 ; CHECK-VF8-NEXT: [[BC_RESUME_VAL2:%.*]] = phi i64 [ 10000, [[VEC_EPILOG_MIDDLE_BLOCK]] ], [ [[N_VEC]], [[VEC_EPILOG_ITER_CHECK]] ], [ 0, [[ITER_CHECK:%.*]] ]
506 ; CHECK-VF8-NEXT: [[BC_RESUME_VAL5:%.*]] = phi ptr [ [[IND_END3]], [[VEC_EPILOG_MIDDLE_BLOCK]] ], [ [[IND_END4]], [[VEC_EPILOG_ITER_CHECK]] ], [ [[START]], [[ITER_CHECK]] ]
507 ; CHECK-VF8-NEXT: br label [[LOOP:%.*]]
509 ; CHECK-VF8-NEXT: [[IV:%.*]] = phi i64 [ [[BC_RESUME_VAL2]], [[VEC_EPILOG_SCALAR_PH]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
510 ; CHECK-VF8-NEXT: [[PTR_IV:%.*]] = phi ptr [ [[BC_RESUME_VAL5]], [[VEC_EPILOG_SCALAR_PH]] ], [ [[PTR_IV_NEXT:%.*]], [[LOOP]] ]
511 ; CHECK-VF8-NEXT: store i8 0, ptr [[PTR_IV]], align 1
512 ; CHECK-VF8-NEXT: [[PTR_IV_NEXT]] = getelementptr inbounds i8, ptr [[PTR_IV]], i64 1
513 ; CHECK-VF8-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
514 ; CHECK-VF8-NEXT: [[CMP:%.*]] = icmp eq i64 [[IV_NEXT]], 10000
515 ; CHECK-VF8-NEXT: br i1 [[CMP]], label [[EXIT]], label [[LOOP]], !llvm.loop [[LOOP10:![0-9]+]]
517 ; CHECK-VF8-NEXT: ret void
523 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
524 %ptr.iv = phi ptr [ %start, %entry ], [ %ptr.iv.next, %loop ]
525 store i8 0, ptr %ptr.iv, align 1
526 %ptr.iv.next = getelementptr inbounds i8, ptr %ptr.iv, i64 1
527 %iv.next = add nuw nsw i64 %iv, 1
528 %cmp = icmp eq i64 %iv.next, 10000
529 br i1 %cmp, label %exit, label %loop
535 attributes #0 = { "target-features"="+sve" }