1 ; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | grep "phi double" | count 1
4 define void @foobar(i32 %n) nounwind {
6 icmp eq i32 %n, 0 ; <i1>:0 [#uses=2]
7 br i1 %0, label %return, label %bb.nph
9 bb.nph: ; preds = %entry
10 %umax = select i1 %0, i32 1, i32 %n ; <i32> [#uses=1]
13 bb: ; preds = %bb, %bb.nph
14 %i.03 = phi i32 [ 0, %bb.nph ], [ %indvar.next, %bb ] ; <i32> [#uses=3]
15 tail call void @bar( i32 %i.03 ) nounwind
16 uitofp i32 %i.03 to double ; <double>:1 [#uses=1]
17 tail call void @foo( double %1 ) nounwind
18 %indvar.next = add i32 %i.03, 1 ; <i32> [#uses=2]
19 %exitcond = icmp eq i32 %indvar.next, %umax ; <i1> [#uses=1]
20 br i1 %exitcond, label %return, label %bb
22 return: ; preds = %bb, %entry
26 ; Unable to eliminate cast because the mantissa bits for double are not enough
27 ; to hold all of i64 IV bits.
28 define void @foobar2(i64 %n) nounwind {
30 icmp eq i64 %n, 0 ; <i1>:0 [#uses=2]
31 br i1 %0, label %return, label %bb.nph
33 bb.nph: ; preds = %entry
34 %umax = select i1 %0, i64 1, i64 %n ; <i64> [#uses=1]
37 bb: ; preds = %bb, %bb.nph
38 %i.03 = phi i64 [ 0, %bb.nph ], [ %indvar.next, %bb ] ; <i64> [#uses=3]
39 trunc i64 %i.03 to i32 ; <i32>:1 [#uses=1]
40 tail call void @bar( i32 %1 ) nounwind
41 uitofp i64 %i.03 to double ; <double>:2 [#uses=1]
42 tail call void @foo( double %2 ) nounwind
43 %indvar.next = add i64 %i.03, 1 ; <i64> [#uses=2]
44 %exitcond = icmp eq i64 %indvar.next, %umax ; <i1> [#uses=1]
45 br i1 %exitcond, label %return, label %bb
47 return: ; preds = %bb, %entry
51 ; Unable to eliminate cast due to potentional overflow.
52 define void @foobar3() nounwind {
54 tail call i32 (...)* @nn( ) nounwind ; <i32>:0 [#uses=1]
55 icmp eq i32 %0, 0 ; <i1>:1 [#uses=1]
56 br i1 %1, label %return, label %bb
58 bb: ; preds = %bb, %entry
59 %i.03 = phi i32 [ 0, %entry ], [ %3, %bb ] ; <i32> [#uses=3]
60 tail call void @bar( i32 %i.03 ) nounwind
61 uitofp i32 %i.03 to double ; <double>:2 [#uses=1]
62 tail call void @foo( double %2 ) nounwind
63 add i32 %i.03, 1 ; <i32>:3 [#uses=2]
64 tail call i32 (...)* @nn( ) nounwind ; <i32>:4 [#uses=1]
65 icmp ugt i32 %4, %3 ; <i1>:5 [#uses=1]
66 br i1 %5, label %bb, label %return
68 return: ; preds = %bb, %entry
72 ; Unable to eliminate cast due to overflow.
73 define void @foobar4() nounwind {
77 bb.nph: ; preds = %entry
80 bb: ; preds = %bb, %bb.nph
81 %i.03 = phi i8 [ 0, %bb.nph ], [ %indvar.next, %bb ] ; <i32> [#uses=3]
82 %tmp2 = sext i8 %i.03 to i32 ; <i32>:0 [#uses=1]
83 tail call void @bar( i32 %tmp2 ) nounwind
84 %tmp3 = uitofp i8 %i.03 to double ; <double>:1 [#uses=1]
85 tail call void @foo( double %tmp3 ) nounwind
86 %indvar.next = add i8 %i.03, 1 ; <i32> [#uses=2]
87 %tmp = sext i8 %indvar.next to i32
88 %exitcond = icmp eq i32 %tmp, 32767 ; <i1> [#uses=1]
89 br i1 %exitcond, label %return, label %bb
91 return: ; preds = %bb, %entry
95 declare void @bar(i32)
97 declare void @foo(double)