1 ; RUN: opt < %s -loop-reduce -S | grep "phi double" | count 1
3 define void @foobar(i32 %n) nounwind {
5 icmp eq i32 %n, 0 ; <i1>:0 [#uses=2]
6 br i1 %0, label %return, label %bb.nph
8 bb.nph: ; preds = %entry
9 %umax = select i1 %0, i32 1, i32 %n ; <i32> [#uses=1]
12 bb: ; preds = %bb, %bb.nph
13 %i.03 = phi i32 [ 0, %bb.nph ], [ %indvar.next, %bb ] ; <i32> [#uses=3]
14 tail call void @bar( i32 %i.03 ) nounwind
15 uitofp i32 %i.03 to double ; <double>:1 [#uses=1]
16 tail call void @foo( double %1 ) nounwind
17 %indvar.next = add i32 %i.03, 1 ; <i32> [#uses=2]
18 %exitcond = icmp eq i32 %indvar.next, %umax ; <i1> [#uses=1]
19 br i1 %exitcond, label %return, label %bb
21 return: ; preds = %bb, %entry
25 ; Unable to eliminate cast because the mantissa bits for double are not enough
26 ; to hold all of i64 IV bits.
27 define void @foobar2(i64 %n) nounwind {
29 icmp eq i64 %n, 0 ; <i1>:0 [#uses=2]
30 br i1 %0, label %return, label %bb.nph
32 bb.nph: ; preds = %entry
33 %umax = select i1 %0, i64 1, i64 %n ; <i64> [#uses=1]
36 bb: ; preds = %bb, %bb.nph
37 %i.03 = phi i64 [ 0, %bb.nph ], [ %indvar.next, %bb ] ; <i64> [#uses=3]
38 trunc i64 %i.03 to i32 ; <i32>:1 [#uses=1]
39 tail call void @bar( i32 %1 ) nounwind
40 uitofp i64 %i.03 to double ; <double>:2 [#uses=1]
41 tail call void @foo( double %2 ) nounwind
42 %indvar.next = add i64 %i.03, 1 ; <i64> [#uses=2]
43 %exitcond = icmp eq i64 %indvar.next, %umax ; <i1> [#uses=1]
44 br i1 %exitcond, label %return, label %bb
46 return: ; preds = %bb, %entry
50 ; Unable to eliminate cast due to potentional overflow.
51 define void @foobar3() nounwind {
53 tail call i32 (...)* @nn( ) nounwind ; <i32>:0 [#uses=1]
54 icmp eq i32 %0, 0 ; <i1>:1 [#uses=1]
55 br i1 %1, label %return, label %bb
57 bb: ; preds = %bb, %entry
58 %i.03 = phi i32 [ 0, %entry ], [ %3, %bb ] ; <i32> [#uses=3]
59 tail call void @bar( i32 %i.03 ) nounwind
60 uitofp i32 %i.03 to double ; <double>:2 [#uses=1]
61 tail call void @foo( double %2 ) nounwind
62 add i32 %i.03, 1 ; <i32>:3 [#uses=2]
63 tail call i32 (...)* @nn( ) nounwind ; <i32>:4 [#uses=1]
64 icmp ugt i32 %4, %3 ; <i1>:5 [#uses=1]
65 br i1 %5, label %bb, label %return
67 return: ; preds = %bb, %entry
71 ; Unable to eliminate cast due to overflow.
72 define void @foobar4() nounwind {
76 bb.nph: ; preds = %entry
79 bb: ; preds = %bb, %bb.nph
80 %i.03 = phi i8 [ 0, %bb.nph ], [ %indvar.next, %bb ] ; <i32> [#uses=3]
81 %tmp2 = sext i8 %i.03 to i32 ; <i32>:0 [#uses=1]
82 tail call void @bar( i32 %tmp2 ) nounwind
83 %tmp3 = uitofp i8 %i.03 to double ; <double>:1 [#uses=1]
84 tail call void @foo( double %tmp3 ) nounwind
85 %indvar.next = add i8 %i.03, 1 ; <i32> [#uses=2]
86 %tmp = sext i8 %indvar.next to i32
87 %exitcond = icmp eq i32 %tmp, 32767 ; <i1> [#uses=1]
88 br i1 %exitcond, label %return, label %bb
90 return: ; preds = %bb, %entry
94 declare void @bar(i32)
96 declare void @foo(double)