1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -codegenprepare -cgp-optimize-phi-types %s -S | FileCheck %s
4 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
5 target triple = "aarch64--linux-gnu"
7 define float @convphi1(i32 *%s, i32 *%d, i32 %n) {
8 ; CHECK-LABEL: @convphi1(
10 ; CHECK-NEXT: [[CMP15:%.*]] = icmp sgt i32 [[N:%.*]], 0
11 ; CHECK-NEXT: br i1 [[CMP15]], label [[THEN:%.*]], label [[ELSE:%.*]]
13 ; CHECK-NEXT: [[LS:%.*]] = load i32, i32* [[S:%.*]], align 4
14 ; CHECK-NEXT: [[LS_BC:%.*]] = bitcast i32 [[LS]] to float
15 ; CHECK-NEXT: br label [[END:%.*]]
17 ; CHECK-NEXT: [[LD:%.*]] = load i32, i32* [[D:%.*]], align 4
18 ; CHECK-NEXT: [[LD_BC:%.*]] = bitcast i32 [[LD]] to float
19 ; CHECK-NEXT: br label [[END]]
21 ; CHECK-NEXT: [[PHI_TC:%.*]] = phi float [ [[LS_BC]], [[THEN]] ], [ [[LD_BC]], [[ELSE]] ]
22 ; CHECK-NEXT: ret float [[PHI_TC]]
25 %cmp15 = icmp sgt i32 %n, 0
26 br i1 %cmp15, label %then, label %else
29 %ls = load i32, i32* %s, align 4
33 %ld = load i32, i32* %d, align 4
37 %phi = phi i32 [ %ls, %then ], [ %ld, %else ]
38 %b = bitcast i32 %phi to float
42 define float @convphi2(i32 *%s, i32 *%d, i32 %n) {
43 ; CHECK-LABEL: @convphi2(
45 ; CHECK-NEXT: [[CMP15:%.*]] = icmp sgt i32 [[N:%.*]], 0
46 ; CHECK-NEXT: br i1 [[CMP15]], label [[THEN:%.*]], label [[END:%.*]]
48 ; CHECK-NEXT: [[LS:%.*]] = load i32, i32* [[S:%.*]], align 4
49 ; CHECK-NEXT: [[LS_BC:%.*]] = bitcast i32 [[LS]] to float
50 ; CHECK-NEXT: br label [[END]]
52 ; CHECK-NEXT: [[PHI_TC:%.*]] = phi float [ [[LS_BC]], [[THEN]] ], [ undef, [[ENTRY:%.*]] ]
53 ; CHECK-NEXT: ret float [[PHI_TC]]
56 %cmp15 = icmp sgt i32 %n, 0
57 br i1 %cmp15, label %then, label %end
60 %ls = load i32, i32* %s, align 4
64 %phi = phi i32 [ %ls, %then ], [ undef, %entry ]
65 %b = bitcast i32 %phi to float
69 define float @convphi3(i32 *%s, i32 *%d, i32 %n, float %f) {
70 ; CHECK-LABEL: @convphi3(
72 ; CHECK-NEXT: [[CMP15:%.*]] = icmp sgt i32 [[N:%.*]], 0
73 ; CHECK-NEXT: br i1 [[CMP15]], label [[THEN:%.*]], label [[END:%.*]]
75 ; CHECK-NEXT: [[LS:%.*]] = load i32, i32* [[S:%.*]], align 4
76 ; CHECK-NEXT: [[LS_BC:%.*]] = bitcast i32 [[LS]] to float
77 ; CHECK-NEXT: br label [[END]]
79 ; CHECK-NEXT: [[PHI_TC:%.*]] = phi float [ [[LS_BC]], [[THEN]] ], [ [[F:%.*]], [[ENTRY:%.*]] ]
80 ; CHECK-NEXT: ret float [[PHI_TC]]
83 %cmp15 = icmp sgt i32 %n, 0
84 %fb = bitcast float %f to i32
85 br i1 %cmp15, label %then, label %end
88 %ls = load i32, i32* %s, align 4
92 %phi = phi i32 [ %ls, %then ], [ %fb, %entry ]
93 %b = bitcast i32 %phi to float
97 define void @convphi4(i32 *%s, i32 *%d, i32 %n, float %f) {
98 ; CHECK-LABEL: @convphi4(
100 ; CHECK-NEXT: [[CMP15:%.*]] = icmp sgt i32 [[N:%.*]], 0
101 ; CHECK-NEXT: br i1 [[CMP15]], label [[THEN:%.*]], label [[END:%.*]]
103 ; CHECK-NEXT: [[LS:%.*]] = load i32, i32* [[S:%.*]], align 4
104 ; CHECK-NEXT: [[LS_BC:%.*]] = bitcast i32 [[LS]] to float
105 ; CHECK-NEXT: br label [[END]]
107 ; CHECK-NEXT: [[PHI_TC:%.*]] = phi float [ [[LS_BC]], [[THEN]] ], [ [[F:%.*]], [[ENTRY:%.*]] ]
108 ; CHECK-NEXT: [[BC:%.*]] = bitcast float [[PHI_TC]] to i32
109 ; CHECK-NEXT: store i32 [[BC]], i32* [[D:%.*]], align 4
110 ; CHECK-NEXT: ret void
113 %cmp15 = icmp sgt i32 %n, 0
114 %fb = bitcast float %f to i32
115 br i1 %cmp15, label %then, label %end
118 %ls = load i32, i32* %s, align 4
122 %phi = phi i32 [ %ls, %then ], [ %fb, %entry ]
123 store i32 %phi, i32 *%d
127 define i64 @convphi_d2i(double *%s, double *%d, i32 %n) {
128 ; CHECK-LABEL: @convphi_d2i(
130 ; CHECK-NEXT: [[CMP15:%.*]] = icmp sgt i32 [[N:%.*]], 0
131 ; CHECK-NEXT: br i1 [[CMP15]], label [[THEN:%.*]], label [[ELSE:%.*]]
133 ; CHECK-NEXT: [[LS:%.*]] = load double, double* [[S:%.*]], align 4
134 ; CHECK-NEXT: [[LS_BC:%.*]] = bitcast double [[LS]] to i64
135 ; CHECK-NEXT: br label [[END:%.*]]
137 ; CHECK-NEXT: [[LD:%.*]] = load double, double* [[D:%.*]], align 4
138 ; CHECK-NEXT: [[LD_BC:%.*]] = bitcast double [[LD]] to i64
139 ; CHECK-NEXT: br label [[END]]
141 ; CHECK-NEXT: [[PHI_TC:%.*]] = phi i64 [ [[LS_BC]], [[THEN]] ], [ [[LD_BC]], [[ELSE]] ]
142 ; CHECK-NEXT: ret i64 [[PHI_TC]]
145 %cmp15 = icmp sgt i32 %n, 0
146 br i1 %cmp15, label %then, label %else
149 %ls = load double, double* %s, align 4
153 %ld = load double, double* %d, align 4
157 %phi = phi double [ %ls, %then ], [ %ld, %else ]
158 %b = bitcast double %phi to i64
162 define i32 @convphi_f2i(float *%s, float *%d, i32 %n) {
163 ; CHECK-LABEL: @convphi_f2i(
165 ; CHECK-NEXT: [[CMP15:%.*]] = icmp sgt i32 [[N:%.*]], 0
166 ; CHECK-NEXT: br i1 [[CMP15]], label [[THEN:%.*]], label [[ELSE:%.*]]
168 ; CHECK-NEXT: [[LS:%.*]] = load float, float* [[S:%.*]], align 4
169 ; CHECK-NEXT: [[LS_BC:%.*]] = bitcast float [[LS]] to i32
170 ; CHECK-NEXT: br label [[END:%.*]]
172 ; CHECK-NEXT: [[LD:%.*]] = load float, float* [[D:%.*]], align 4
173 ; CHECK-NEXT: [[LD_BC:%.*]] = bitcast float [[LD]] to i32
174 ; CHECK-NEXT: br label [[END]]
176 ; CHECK-NEXT: [[PHI_TC:%.*]] = phi i32 [ [[LS_BC]], [[THEN]] ], [ [[LD_BC]], [[ELSE]] ]
177 ; CHECK-NEXT: ret i32 [[PHI_TC]]
180 %cmp15 = icmp sgt i32 %n, 0
181 br i1 %cmp15, label %then, label %else
184 %ls = load float, float* %s, align 4
188 %ld = load float, float* %d, align 4
192 %phi = phi float [ %ls, %then ], [ %ld, %else ]
193 %b = bitcast float %phi to i32
197 define i16 @convphi_h2i(half *%s, half *%d, i32 %n) {
198 ; CHECK-LABEL: @convphi_h2i(
200 ; CHECK-NEXT: [[CMP15:%.*]] = icmp sgt i32 [[N:%.*]], 0
201 ; CHECK-NEXT: br i1 [[CMP15]], label [[THEN:%.*]], label [[ELSE:%.*]]
203 ; CHECK-NEXT: [[LS:%.*]] = load half, half* [[S:%.*]], align 4
204 ; CHECK-NEXT: [[LS_BC:%.*]] = bitcast half [[LS]] to i16
205 ; CHECK-NEXT: br label [[END:%.*]]
207 ; CHECK-NEXT: [[LD:%.*]] = load half, half* [[D:%.*]], align 4
208 ; CHECK-NEXT: [[LD_BC:%.*]] = bitcast half [[LD]] to i16
209 ; CHECK-NEXT: br label [[END]]
211 ; CHECK-NEXT: [[PHI_TC:%.*]] = phi i16 [ [[LS_BC]], [[THEN]] ], [ [[LD_BC]], [[ELSE]] ]
212 ; CHECK-NEXT: ret i16 [[PHI_TC]]
215 %cmp15 = icmp sgt i32 %n, 0
216 br i1 %cmp15, label %then, label %else
219 %ls = load half, half* %s, align 4
223 %ld = load half, half* %d, align 4
227 %phi = phi half [ %ls, %then ], [ %ld, %else ]
228 %b = bitcast half %phi to i16
232 define i128 @convphi_ld2i(fp128 *%s, fp128 *%d, i32 %n) {
233 ; CHECK-LABEL: @convphi_ld2i(
235 ; CHECK-NEXT: [[CMP15:%.*]] = icmp sgt i32 [[N:%.*]], 0
236 ; CHECK-NEXT: br i1 [[CMP15]], label [[THEN:%.*]], label [[ELSE:%.*]]
238 ; CHECK-NEXT: [[LS:%.*]] = load fp128, fp128* [[S:%.*]], align 4
239 ; CHECK-NEXT: [[LS_BC:%.*]] = bitcast fp128 [[LS]] to i128
240 ; CHECK-NEXT: br label [[END:%.*]]
242 ; CHECK-NEXT: [[LD:%.*]] = load fp128, fp128* [[D:%.*]], align 4
243 ; CHECK-NEXT: [[LD_BC:%.*]] = bitcast fp128 [[LD]] to i128
244 ; CHECK-NEXT: br label [[END]]
246 ; CHECK-NEXT: [[PHI_TC:%.*]] = phi i128 [ [[LS_BC]], [[THEN]] ], [ [[LD_BC]], [[ELSE]] ]
247 ; CHECK-NEXT: ret i128 [[PHI_TC]]
250 %cmp15 = icmp sgt i32 %n, 0
251 br i1 %cmp15, label %then, label %else
254 %ls = load fp128, fp128* %s, align 4
258 %ld = load fp128, fp128* %d, align 4
262 %phi = phi fp128 [ %ls, %then ], [ %ld, %else ]
263 %b = bitcast fp128 %phi to i128
267 define <4 x i32> @convphi_4xf2i(<4 x float> *%s, <4 x float> *%d, i32 %n) {
268 ; CHECK-LABEL: @convphi_4xf2i(
270 ; CHECK-NEXT: [[CMP15:%.*]] = icmp sgt i32 [[N:%.*]], 0
271 ; CHECK-NEXT: br i1 [[CMP15]], label [[THEN:%.*]], label [[ELSE:%.*]]
273 ; CHECK-NEXT: [[LS:%.*]] = load <4 x float>, <4 x float>* [[S:%.*]], align 4
274 ; CHECK-NEXT: br label [[END:%.*]]
276 ; CHECK-NEXT: [[LD:%.*]] = load <4 x float>, <4 x float>* [[D:%.*]], align 4
277 ; CHECK-NEXT: br label [[END]]
279 ; CHECK-NEXT: [[PHI:%.*]] = phi <4 x float> [ [[LS]], [[THEN]] ], [ [[LD]], [[ELSE]] ]
280 ; CHECK-NEXT: [[B:%.*]] = bitcast <4 x float> [[PHI]] to <4 x i32>
281 ; CHECK-NEXT: ret <4 x i32> [[B]]
284 %cmp15 = icmp sgt i32 %n, 0
285 br i1 %cmp15, label %then, label %else
288 %ls = load <4 x float>, <4 x float>* %s, align 4
292 %ld = load <4 x float>, <4 x float>* %d, align 4
296 %phi = phi <4 x float> [ %ls, %then ], [ %ld, %else ]
297 %b = bitcast <4 x float> %phi to <4 x i32>
301 define float @convphi_loop(i32 *%s, i32 *%d, i64 %n) {
302 ; CHECK-LABEL: @convphi_loop(
304 ; CHECK-NEXT: [[CMP15:%.*]] = icmp sgt i64 [[N:%.*]], 0
305 ; CHECK-NEXT: [[LS:%.*]] = load i32, i32* [[S:%.*]], align 4
306 ; CHECK-NEXT: [[LS_BC:%.*]] = bitcast i32 [[LS]] to float
307 ; CHECK-NEXT: br i1 [[CMP15]], label [[LOOP:%.*]], label [[END:%.*]]
309 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
310 ; CHECK-NEXT: [[LPHI_TC:%.*]] = phi float [ [[LS_BC]], [[ENTRY]] ], [ [[LD_BC:%.*]], [[LOOP]] ]
311 ; CHECK-NEXT: [[LD:%.*]] = load i32, i32* [[D:%.*]], align 4
312 ; CHECK-NEXT: [[LD_BC]] = bitcast i32 [[LD]] to float
313 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
314 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[IV_NEXT]], [[N]]
315 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[END]], label [[LOOP]]
317 ; CHECK-NEXT: [[PHI_TC:%.*]] = phi float [ undef, [[ENTRY]] ], [ [[LPHI_TC]], [[LOOP]] ]
318 ; CHECK-NEXT: ret float [[PHI_TC]]
321 %cmp15 = icmp sgt i64 %n, 0
322 %ls = load i32, i32* %s, align 4
323 br i1 %cmp15, label %loop, label %end
326 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
327 %lphi = phi i32 [ %ls, %entry ], [ %ld, %loop ]
328 %ld = load i32, i32* %d, align 4
329 %iv.next = add nuw nsw i64 %iv, 1
330 %exitcond = icmp eq i64 %iv.next, %n
331 br i1 %exitcond, label %end, label %loop
334 %phi = phi i32 [ undef, %entry ], [ %lphi, %loop ]
335 %b = bitcast i32 %phi to float
339 define float @convphi_loopdelayed(i32 *%s, i32 *%d, i64 %n) {
340 ; CHECK-LABEL: @convphi_loopdelayed(
342 ; CHECK-NEXT: [[CMP15:%.*]] = icmp sgt i64 [[N:%.*]], 0
343 ; CHECK-NEXT: [[LS:%.*]] = load i32, i32* [[S:%.*]], align 4
344 ; CHECK-NEXT: br i1 [[CMP15]], label [[LOOP:%.*]], label [[END:%.*]]
346 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
347 ; CHECK-NEXT: [[LD:%.*]] = load i32, i32* [[D:%.*]], align 4
348 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
349 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[IV_NEXT]], [[N]]
350 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[END]], label [[LOOP]]
352 ; CHECK-NEXT: [[B:%.*]] = bitcast i32 [[LS]] to float
353 ; CHECK-NEXT: ret float [[B]]
356 %cmp15 = icmp sgt i64 %n, 0
357 %ls = load i32, i32* %s, align 4
358 br i1 %cmp15, label %loop, label %end
361 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
362 %lphi = phi i32 [ %ls, %entry ], [ %lphi, %loop ]
363 %ld = load i32, i32* %d, align 4
364 %iv.next = add nuw nsw i64 %iv, 1
365 %exitcond = icmp eq i64 %iv.next, %n
366 br i1 %exitcond, label %end, label %loop
369 %phi = phi i32 [ undef, %entry ], [ %lphi, %loop ]
370 %b = bitcast i32 %phi to float
374 define float @convphi_loopdelayed2(i32 *%s, i32 *%d, i64 %n) {
375 ; CHECK-LABEL: @convphi_loopdelayed2(
377 ; CHECK-NEXT: [[CMP15:%.*]] = icmp sgt i64 [[N:%.*]], 0
378 ; CHECK-NEXT: [[LS:%.*]] = load i32, i32* [[S:%.*]], align 4
379 ; CHECK-NEXT: [[LS_BC:%.*]] = bitcast i32 [[LS]] to float
380 ; CHECK-NEXT: br i1 [[CMP15]], label [[LOOP:%.*]], label [[END:%.*]]
382 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[ENTRY:%.*]] ], [ [[IV_NEXT:%.*]], [[LOOP]] ]
383 ; CHECK-NEXT: [[LPHI_TC:%.*]] = phi float [ [[LS_BC]], [[ENTRY]] ], [ [[LD_BC:%.*]], [[LOOP]] ]
384 ; CHECK-NEXT: [[LPHI2_TC:%.*]] = phi float [ undef, [[ENTRY]] ], [ [[LPHI_TC]], [[LOOP]] ]
385 ; CHECK-NEXT: [[LD:%.*]] = load i32, i32* [[D:%.*]], align 4
386 ; CHECK-NEXT: [[LD_BC]] = bitcast i32 [[LD]] to float
387 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
388 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[IV_NEXT]], [[N]]
389 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[END]], label [[LOOP]]
391 ; CHECK-NEXT: [[PHI_TC:%.*]] = phi float [ undef, [[ENTRY]] ], [ [[LPHI2_TC]], [[LOOP]] ]
392 ; CHECK-NEXT: ret float [[PHI_TC]]
395 %cmp15 = icmp sgt i64 %n, 0
396 %ls = load i32, i32* %s, align 4
397 br i1 %cmp15, label %loop, label %end
400 %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
401 %lphi = phi i32 [ %ls, %entry ], [ %ld, %loop ]
402 %lphi2 = phi i32 [ undef, %entry ], [ %lphi, %loop ]
403 %ld = load i32, i32* %d, align 4
404 %iv.next = add nuw nsw i64 %iv, 1
405 %exitcond = icmp eq i64 %iv.next, %n
406 br i1 %exitcond, label %end, label %loop
409 %phi = phi i32 [ undef, %entry ], [ %lphi2, %loop ]
410 %b = bitcast i32 %phi to float
414 define float @convphi_loopmore(i32 *%s, i32 *%d, i64 %n) {
415 ; CHECK-LABEL: @convphi_loopmore(
417 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[N:%.*]], 1
418 ; CHECK-NEXT: [[LS:%.*]] = load i32, i32* [[S:%.*]], align 4
419 ; CHECK-NEXT: [[LS_BC:%.*]] = bitcast i32 [[LS]] to float
420 ; CHECK-NEXT: br i1 [[CMP]], label [[THEN:%.*]], label [[IFEND:%.*]]
422 ; CHECK-NEXT: [[LD:%.*]] = load i32, i32* [[D:%.*]], align 4
423 ; CHECK-NEXT: [[LD_BC:%.*]] = bitcast i32 [[LD]] to float
424 ; CHECK-NEXT: br label [[IFEND]]
426 ; CHECK-NEXT: [[PHI1_TC:%.*]] = phi float [ [[LD_BC]], [[THEN]] ], [ [[LS_BC]], [[ENTRY:%.*]] ]
427 ; CHECK-NEXT: [[CMP15:%.*]] = icmp sgt i64 [[N]], 0
428 ; CHECK-NEXT: br i1 [[CMP15]], label [[LOOP:%.*]], label [[END:%.*]]
430 ; CHECK-NEXT: [[IV:%.*]] = phi i64 [ 0, [[IFEND]] ], [ [[IV_NEXT:%.*]], [[LOOPEND:%.*]] ]
431 ; CHECK-NEXT: [[PHI2_TC:%.*]] = phi float [ [[PHI1_TC]], [[IFEND]] ], [ [[PHI3_TC:%.*]], [[LOOPEND]] ]
432 ; CHECK-NEXT: [[TMP0:%.*]] = icmp eq i64 [[N]], 1
433 ; CHECK-NEXT: br i1 [[TMP0]], label [[LOOPTHEN:%.*]], label [[LOOPEND]]
435 ; CHECK-NEXT: [[LL:%.*]] = load i32, i32* [[D]], align 4
436 ; CHECK-NEXT: [[LL_BC:%.*]] = bitcast i32 [[LL]] to float
437 ; CHECK-NEXT: br label [[LOOPEND]]
439 ; CHECK-NEXT: [[PHI3_TC]] = phi float [ [[LL_BC]], [[LOOPTHEN]] ], [ [[PHI2_TC]], [[LOOP]] ]
440 ; CHECK-NEXT: [[IV_NEXT]] = add nuw nsw i64 [[IV]], 1
441 ; CHECK-NEXT: [[EXITCOND:%.*]] = icmp eq i64 [[IV_NEXT]], [[N]]
442 ; CHECK-NEXT: br i1 [[EXITCOND]], label [[END]], label [[LOOP]]
444 ; CHECK-NEXT: [[PHI_TC:%.*]] = phi float [ [[PHI1_TC]], [[IFEND]] ], [ [[PHI3_TC]], [[LOOPEND]] ]
445 ; CHECK-NEXT: ret float [[PHI_TC]]
448 %cmp = icmp eq i64 %n, 1
449 %ls = load i32, i32* %s, align 4
450 br i1 %cmp, label %then, label %ifend
453 %ld = load i32, i32* %d, align 4
457 %phi1 = phi i32 [ %ld, %then ], [ %ls, %entry ]
458 %cmp15 = icmp sgt i64 %n, 0
459 br i1 %cmp15, label %loop, label %end
462 %iv = phi i64 [ 0, %ifend ], [ %iv.next, %loopend ]
463 %phi2 = phi i32 [ %phi1, %ifend ], [ %phi3, %loopend ]
464 br i1 %cmp, label %loopthen, label %loopend
467 %ll = load i32, i32* %d, align 4
471 %phi3 = phi i32 [ %ll, %loopthen ], [ %phi2, %loop ]
472 %iv.next = add nuw nsw i64 %iv, 1
473 %exitcond = icmp eq i64 %iv.next, %n
474 br i1 %exitcond, label %end, label %loop
477 %phi = phi i32 [ %phi1, %ifend ], [ %phi3, %loopend ]
478 %b = bitcast i32 %phi to float
482 define void @convphi_stop(i32 *%s, i32 *%d, float *%e, i32 %n) {
483 ; CHECK-LABEL: @convphi_stop(
485 ; CHECK-NEXT: [[CMP15:%.*]] = icmp sgt i32 [[N:%.*]], 0
486 ; CHECK-NEXT: br i1 [[CMP15]], label [[THEN:%.*]], label [[ELSE:%.*]]
488 ; CHECK-NEXT: [[LS:%.*]] = load i32, i32* [[S:%.*]], align 4
489 ; CHECK-NEXT: br label [[END:%.*]]
491 ; CHECK-NEXT: [[LD:%.*]] = load i32, i32* [[D:%.*]], align 4
492 ; CHECK-NEXT: br label [[END]]
494 ; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[LS]], [[THEN]] ], [ [[LD]], [[ELSE]] ]
495 ; CHECK-NEXT: [[B:%.*]] = bitcast i32 [[PHI]] to float
496 ; CHECK-NEXT: store float [[B]], float* [[E:%.*]], align 4
497 ; CHECK-NEXT: ret void
500 %cmp15 = icmp sgt i32 %n, 0
501 br i1 %cmp15, label %then, label %else
504 %ls = load i32, i32* %s, align 4
508 %ld = load i32, i32* %d, align 4
512 %phi = phi i32 [ %ls, %then ], [ %ld, %else ]
513 %b = bitcast i32 %phi to float
514 store float %b, float* %e, align 4
518 define void @convphi_stop2(i32 *%s, i32 *%d, float *%e, i32 %n) {
519 ; CHECK-LABEL: @convphi_stop2(
521 ; CHECK-NEXT: [[CMP15:%.*]] = icmp sgt i32 [[N:%.*]], 0
522 ; CHECK-NEXT: br i1 [[CMP15]], label [[THEN:%.*]], label [[ELSE:%.*]]
524 ; CHECK-NEXT: [[LS:%.*]] = load i32, i32* [[S:%.*]], align 4
525 ; CHECK-NEXT: [[LSB:%.*]] = bitcast i32 [[LS]] to float
526 ; CHECK-NEXT: br label [[END:%.*]]
528 ; CHECK-NEXT: [[LD:%.*]] = load i32, i32* [[D:%.*]], align 4
529 ; CHECK-NEXT: [[LDB:%.*]] = bitcast i32 [[LD]] to float
530 ; CHECK-NEXT: br label [[END]]
532 ; CHECK-NEXT: [[PHI:%.*]] = phi float [ [[LSB]], [[THEN]] ], [ [[LDB]], [[ELSE]] ]
533 ; CHECK-NEXT: store float [[PHI]], float* [[E:%.*]], align 4
534 ; CHECK-NEXT: ret void
537 %cmp15 = icmp sgt i32 %n, 0
538 br i1 %cmp15, label %then, label %else
541 %ls = load i32, i32* %s, align 4
542 %lsb = bitcast i32 %ls to float
546 %ld = load i32, i32* %d, align 4
547 %ldb = bitcast i32 %ld to float
551 %phi = phi float [ %lsb, %then ], [ %ldb, %else ]
552 store float %phi, float* %e, align 4
556 define float @convphi_stop3(i32 *%s, i32 *%d, float *%e, i32 %n) {
557 ; CHECK-LABEL: @convphi_stop3(
559 ; CHECK-NEXT: [[CMP15:%.*]] = icmp sgt i32 [[N:%.*]], 0
560 ; CHECK-NEXT: br i1 [[CMP15]], label [[THEN:%.*]], label [[ELSE:%.*]]
562 ; CHECK-NEXT: [[LS:%.*]] = load i32, i32* [[S:%.*]], align 4
563 ; CHECK-NEXT: [[LS_BC:%.*]] = bitcast i32 [[LS]] to float
564 ; CHECK-NEXT: br label [[END:%.*]]
566 ; CHECK-NEXT: [[LD:%.*]] = load i32, i32* [[D:%.*]], align 4
567 ; CHECK-NEXT: [[LD_BC:%.*]] = bitcast i32 [[LD]] to float
568 ; CHECK-NEXT: br label [[END]]
570 ; CHECK-NEXT: [[PHI_TC:%.*]] = phi float [ [[LS_BC]], [[THEN]] ], [ [[LD_BC]], [[ELSE]] ]
571 ; CHECK-NEXT: store float [[PHI_TC]], float* [[E:%.*]], align 4
572 ; CHECK-NEXT: ret float [[PHI_TC]]
575 %cmp15 = icmp sgt i32 %n, 0
576 br i1 %cmp15, label %then, label %else
579 %ls = load i32, i32* %s, align 4
583 %ld = load i32, i32* %d, align 4
587 %phi = phi i32 [ %ls, %then ], [ %ld, %else ]
588 %b = bitcast i32 %phi to float
589 store float %b, float* %e, align 4
593 define void @convphi_stop4(i32 *%s, i32 *%d, float *%e, i32 %n) {
594 ; CHECK-LABEL: @convphi_stop4(
596 ; CHECK-NEXT: [[CMP15:%.*]] = icmp sgt i32 [[N:%.*]], 0
597 ; CHECK-NEXT: [[LD:%.*]] = load i32, i32* [[D:%.*]], align 4
598 ; CHECK-NEXT: [[LD_BC:%.*]] = bitcast i32 [[LD]] to float
599 ; CHECK-NEXT: br i1 [[CMP15]], label [[THEN:%.*]], label [[END:%.*]]
601 ; CHECK-NEXT: [[LS:%.*]] = load i32, i32* [[S:%.*]], align 4
602 ; CHECK-NEXT: [[LS_BC:%.*]] = bitcast i32 [[LS]] to float
603 ; CHECK-NEXT: br label [[END]]
605 ; CHECK-NEXT: [[PHI_TC:%.*]] = phi float [ [[LS_BC]], [[THEN]] ], [ [[LD_BC]], [[ENTRY:%.*]] ]
606 ; CHECK-NEXT: [[TMP0:%.*]] = icmp sgt i32 [[N]], 0
607 ; CHECK-NEXT: [[BC:%.*]] = bitcast float [[PHI_TC]] to i32
608 ; CHECK-NEXT: store i32 [[BC]], i32* [[S]], align 4
609 ; CHECK-NEXT: br i1 [[TMP0]], label [[THEN2:%.*]], label [[END2:%.*]]
611 ; CHECK-NEXT: [[LF:%.*]] = load float, float* [[E:%.*]], align 4
612 ; CHECK-NEXT: br label [[END2]]
614 ; CHECK-NEXT: [[PHI2:%.*]] = phi float [ [[PHI_TC]], [[END]] ], [ [[LF]], [[THEN2]] ]
615 ; CHECK-NEXT: store float [[PHI2]], float* [[E]], align 4
616 ; CHECK-NEXT: ret void
619 %cmp15 = icmp sgt i32 %n, 0
620 %ld = load i32, i32* %d, align 4
621 br i1 %cmp15, label %then, label %end
624 %ls = load i32, i32* %s, align 4
628 %phi = phi i32 [ %ls, %then ], [ %ld, %entry ]
629 %phib = bitcast i32 %phi to float
630 store i32 %phi, i32* %s, align 4
631 br i1 %cmp15, label %then2, label %end2
634 %lf = load float, float* %e, align 4
638 %phi2 = phi float [ %phib, %end ], [ %lf, %then2 ]
639 store float %phi2, float* %e, align 4
643 define float @multiuse(i32 *%s, i32 *%d, i32 %n) {
644 ; CHECK-LABEL: @multiuse(
646 ; CHECK-NEXT: [[CMP15:%.*]] = icmp sgt i32 [[N:%.*]], 0
647 ; CHECK-NEXT: br i1 [[CMP15]], label [[THEN:%.*]], label [[ELSE:%.*]]
649 ; CHECK-NEXT: [[LS:%.*]] = load i32, i32* [[S:%.*]], align 4
650 ; CHECK-NEXT: [[A:%.*]] = add i32 [[LS]], 2
651 ; CHECK-NEXT: store i32 [[A]], i32* [[D:%.*]], align 4
652 ; CHECK-NEXT: br label [[END:%.*]]
654 ; CHECK-NEXT: [[LD:%.*]] = load i32, i32* [[D]], align 4
655 ; CHECK-NEXT: br label [[END]]
657 ; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[LS]], [[THEN]] ], [ [[LD]], [[ELSE]] ]
658 ; CHECK-NEXT: [[B:%.*]] = bitcast i32 [[PHI]] to float
659 ; CHECK-NEXT: ret float [[B]]
662 %cmp15 = icmp sgt i32 %n, 0
663 br i1 %cmp15, label %then, label %else
666 %ls = load i32, i32* %s, align 4
668 store i32 %a, i32* %d, align 4
672 %ld = load i32, i32* %d, align 4
676 %phi = phi i32 [ %ls, %then ], [ %ld, %else ]
677 %b = bitcast i32 %phi to float
681 define float @convphi_volatile(i32 *%s, i32 *%d, i32 %n) {
682 ; CHECK-LABEL: @convphi_volatile(
684 ; CHECK-NEXT: [[CMP15:%.*]] = icmp sgt i32 [[N:%.*]], 0
685 ; CHECK-NEXT: br i1 [[CMP15]], label [[THEN:%.*]], label [[ELSE:%.*]]
687 ; CHECK-NEXT: [[LS:%.*]] = load volatile i32, i32* [[S:%.*]], align 4
688 ; CHECK-NEXT: br label [[END:%.*]]
690 ; CHECK-NEXT: [[LD:%.*]] = load i32, i32* [[D:%.*]], align 4
691 ; CHECK-NEXT: br label [[END]]
693 ; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[LS]], [[THEN]] ], [ [[LD]], [[ELSE]] ]
694 ; CHECK-NEXT: [[B:%.*]] = bitcast i32 [[PHI]] to float
695 ; CHECK-NEXT: ret float [[B]]
697 ; DEBUG-LABEL: @convphi_volatile(
699 ; DEBUG-NEXT: [[CMP15:%.*]] = icmp sgt i32 [[N:%.*]], 0, !dbg !358
700 ; DEBUG-NEXT: call void @llvm.dbg.value(metadata i1 [[CMP15]], metadata !353, metadata !DIExpression()), !dbg !358
701 ; DEBUG-NEXT: br i1 [[CMP15]], label [[THEN:%.*]], label [[ELSE:%.*]], !dbg !359
703 ; DEBUG-NEXT: [[LS:%.*]] = load volatile i32, i32* [[S:%.*]], align 4, !dbg !360
704 ; DEBUG-NEXT: call void @llvm.dbg.value(metadata i32 [[LS]], metadata !354, metadata !DIExpression()), !dbg !360
705 ; DEBUG-NEXT: br label [[END:%.*]], !dbg !361
707 ; DEBUG-NEXT: [[LD:%.*]] = load i32, i32* [[D:%.*]], align 4, !dbg !362
708 ; DEBUG-NEXT: call void @llvm.dbg.value(metadata i32 [[LD]], metadata !355, metadata !DIExpression()), !dbg !362
709 ; DEBUG-NEXT: br label [[END]], !dbg !363
711 ; DEBUG-NEXT: [[PHI:%.*]] = phi i32 [ [[LS]], [[THEN]] ], [ [[LD]], [[ELSE]] ], !dbg !364
712 ; DEBUG-NEXT: call void @llvm.dbg.value(metadata i32 [[PHI]], metadata !356, metadata !DIExpression()), !dbg !364
713 ; DEBUG-NEXT: [[B:%.*]] = bitcast i32 [[PHI]] to float, !dbg !365
714 ; DEBUG-NEXT: call void @llvm.dbg.value(metadata float [[B]], metadata !357, metadata !DIExpression()), !dbg !365
715 ; DEBUG-NEXT: ret float [[B]], !dbg !366
718 %cmp15 = icmp sgt i32 %n, 0
719 br i1 %cmp15, label %then, label %else
722 %ls = load volatile i32, i32* %s, align 4
726 %ld = load i32, i32* %d, align 4
730 %phi = phi i32 [ %ls, %then ], [ %ld, %else ]
731 %b = bitcast i32 %phi to float
735 define void @convphi_volatile2(i32 *%s, i32 *%d, i32 %n, float %f) {
736 ; CHECK-LABEL: @convphi_volatile2(
738 ; CHECK-NEXT: [[CMP15:%.*]] = icmp sgt i32 [[N:%.*]], 0
739 ; CHECK-NEXT: [[FB:%.*]] = bitcast float [[F:%.*]] to i32
740 ; CHECK-NEXT: br i1 [[CMP15]], label [[THEN:%.*]], label [[END:%.*]]
742 ; CHECK-NEXT: [[LS:%.*]] = load i32, i32* [[S:%.*]], align 4
743 ; CHECK-NEXT: br label [[END]]
745 ; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[LS]], [[THEN]] ], [ [[FB]], [[ENTRY:%.*]] ]
746 ; CHECK-NEXT: store volatile i32 [[PHI]], i32* [[D:%.*]], align 4
747 ; CHECK-NEXT: ret void
749 ; DEBUG-LABEL: @convphi_volatile2(
751 ; DEBUG-NEXT: [[CMP15:%.*]] = icmp sgt i32 [[N:%.*]], 0, !dbg !373
752 ; DEBUG-NEXT: call void @llvm.dbg.value(metadata i1 [[CMP15]], metadata !369, metadata !DIExpression()), !dbg !373
753 ; DEBUG-NEXT: [[FB:%.*]] = bitcast float [[F:%.*]] to i32, !dbg !374
754 ; DEBUG-NEXT: call void @llvm.dbg.value(metadata i32 [[FB]], metadata !370, metadata !DIExpression()), !dbg !374
755 ; DEBUG-NEXT: br i1 [[CMP15]], label [[THEN:%.*]], label [[END:%.*]], !dbg !375
757 ; DEBUG-NEXT: [[LS:%.*]] = load i32, i32* [[S:%.*]], align 4, !dbg !376
758 ; DEBUG-NEXT: call void @llvm.dbg.value(metadata i32 [[LS]], metadata !371, metadata !DIExpression()), !dbg !376
759 ; DEBUG-NEXT: br label [[END]], !dbg !377
761 ; DEBUG-NEXT: [[PHI:%.*]] = phi i32 [ [[LS]], [[THEN]] ], [ [[FB]], [[ENTRY:%.*]] ], !dbg !378
762 ; DEBUG-NEXT: call void @llvm.dbg.value(metadata i32 [[PHI]], metadata !372, metadata !DIExpression()), !dbg !378
763 ; DEBUG-NEXT: store volatile i32 [[PHI]], i32* [[D:%.*]], align 4, !dbg !379
764 ; DEBUG-NEXT: ret void, !dbg !380
767 %cmp15 = icmp sgt i32 %n, 0
768 %fb = bitcast float %f to i32
769 br i1 %cmp15, label %then, label %end
772 %ls = load i32, i32* %s, align 4
776 %phi = phi i32 [ %ls, %then ], [ %fb, %entry ]
777 store volatile i32 %phi, i32 *%d
781 define float @convphi_atomic(i32 *%s, i32 *%d, i32 %n) {
782 ; CHECK-LABEL: @convphi_atomic(
784 ; CHECK-NEXT: [[CMP15:%.*]] = icmp sgt i32 [[N:%.*]], 0
785 ; CHECK-NEXT: br i1 [[CMP15]], label [[THEN:%.*]], label [[ELSE:%.*]]
787 ; CHECK-NEXT: [[LS:%.*]] = load atomic i32, i32* [[S:%.*]] acquire, align 4
788 ; CHECK-NEXT: br label [[END:%.*]]
790 ; CHECK-NEXT: [[LD:%.*]] = load i32, i32* [[D:%.*]], align 4
791 ; CHECK-NEXT: br label [[END]]
793 ; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[LS]], [[THEN]] ], [ [[LD]], [[ELSE]] ]
794 ; CHECK-NEXT: [[B:%.*]] = bitcast i32 [[PHI]] to float
795 ; CHECK-NEXT: ret float [[B]]
797 ; DEBUG-LABEL: @convphi_atomic(
799 ; DEBUG-NEXT: [[CMP15:%.*]] = icmp sgt i32 [[N:%.*]], 0, !dbg !388
800 ; DEBUG-NEXT: call void @llvm.dbg.value(metadata i1 [[CMP15]], metadata !383, metadata !DIExpression()), !dbg !388
801 ; DEBUG-NEXT: br i1 [[CMP15]], label [[THEN:%.*]], label [[ELSE:%.*]], !dbg !389
803 ; DEBUG-NEXT: [[LS:%.*]] = load atomic i32, i32* [[S:%.*]] acquire, align 4, !dbg !390
804 ; DEBUG-NEXT: call void @llvm.dbg.value(metadata i32 [[LS]], metadata !384, metadata !DIExpression()), !dbg !390
805 ; DEBUG-NEXT: br label [[END:%.*]], !dbg !391
807 ; DEBUG-NEXT: [[LD:%.*]] = load i32, i32* [[D:%.*]], align 4, !dbg !392
808 ; DEBUG-NEXT: call void @llvm.dbg.value(metadata i32 [[LD]], metadata !385, metadata !DIExpression()), !dbg !392
809 ; DEBUG-NEXT: br label [[END]], !dbg !393
811 ; DEBUG-NEXT: [[PHI:%.*]] = phi i32 [ [[LS]], [[THEN]] ], [ [[LD]], [[ELSE]] ], !dbg !394
812 ; DEBUG-NEXT: call void @llvm.dbg.value(metadata i32 [[PHI]], metadata !386, metadata !DIExpression()), !dbg !394
813 ; DEBUG-NEXT: [[B:%.*]] = bitcast i32 [[PHI]] to float, !dbg !395
814 ; DEBUG-NEXT: call void @llvm.dbg.value(metadata float [[B]], metadata !387, metadata !DIExpression()), !dbg !395
815 ; DEBUG-NEXT: ret float [[B]], !dbg !396
818 %cmp15 = icmp sgt i32 %n, 0
819 br i1 %cmp15, label %then, label %else
822 %ls = load atomic i32, i32* %s acquire, align 4
826 %ld = load i32, i32* %d, align 4
830 %phi = phi i32 [ %ls, %then ], [ %ld, %else ]
831 %b = bitcast i32 %phi to float
835 define void @convphi_atomic2(i32 *%s, i32 *%d, i32 %n, float %f) {
836 ; CHECK-LABEL: @convphi_atomic2(
838 ; CHECK-NEXT: [[CMP15:%.*]] = icmp sgt i32 [[N:%.*]], 0
839 ; CHECK-NEXT: [[FB:%.*]] = bitcast float [[F:%.*]] to i32
840 ; CHECK-NEXT: br i1 [[CMP15]], label [[THEN:%.*]], label [[END:%.*]]
842 ; CHECK-NEXT: [[LS:%.*]] = load i32, i32* [[S:%.*]], align 4
843 ; CHECK-NEXT: br label [[END]]
845 ; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[LS]], [[THEN]] ], [ [[FB]], [[ENTRY:%.*]] ]
846 ; CHECK-NEXT: store atomic i32 [[PHI]], i32* [[D:%.*]] release, align 4
847 ; CHECK-NEXT: ret void
849 ; DEBUG-LABEL: @convphi_atomic2(
851 ; DEBUG-NEXT: [[CMP15:%.*]] = icmp sgt i32 [[N:%.*]], 0, !dbg !403
852 ; DEBUG-NEXT: call void @llvm.dbg.value(metadata i1 [[CMP15]], metadata !399, metadata !DIExpression()), !dbg !403
853 ; DEBUG-NEXT: [[FB:%.*]] = bitcast float [[F:%.*]] to i32, !dbg !404
854 ; DEBUG-NEXT: call void @llvm.dbg.value(metadata i32 [[FB]], metadata !400, metadata !DIExpression()), !dbg !404
855 ; DEBUG-NEXT: br i1 [[CMP15]], label [[THEN:%.*]], label [[END:%.*]], !dbg !405
857 ; DEBUG-NEXT: [[LS:%.*]] = load i32, i32* [[S:%.*]], align 4, !dbg !406
858 ; DEBUG-NEXT: call void @llvm.dbg.value(metadata i32 [[LS]], metadata !401, metadata !DIExpression()), !dbg !406
859 ; DEBUG-NEXT: br label [[END]], !dbg !407
861 ; DEBUG-NEXT: [[PHI:%.*]] = phi i32 [ [[LS]], [[THEN]] ], [ [[FB]], [[ENTRY:%.*]] ], !dbg !408
862 ; DEBUG-NEXT: call void @llvm.dbg.value(metadata i32 [[PHI]], metadata !402, metadata !DIExpression()), !dbg !408
863 ; DEBUG-NEXT: store atomic i32 [[PHI]], i32* [[D:%.*]] release, align 4, !dbg !409
864 ; DEBUG-NEXT: ret void, !dbg !410
867 %cmp15 = icmp sgt i32 %n, 0
868 %fb = bitcast float %f to i32
869 br i1 %cmp15, label %then, label %end
872 %ls = load i32, i32* %s, align 4
876 %phi = phi i32 [ %ls, %then ], [ %fb, %entry ]
877 store atomic i32 %phi, i32 *%d release, align 4