1 ; RUN: opt < %s -loop-reduce -S -mtriple=x86_64-unknown-unknown | grep "phi double" | count 1
3 ; Provide legal integer types.
4 target datalayout = "n8:16:32:64"
7 define void @foobar(i32 %n) nounwind {
9 icmp eq i32 %n, 0 ; <i1>:0 [#uses=2]
10 br i1 %0, label %return, label %bb.nph
12 bb.nph: ; preds = %entry
13 %umax = select i1 %0, i32 1, i32 %n ; <i32> [#uses=1]
16 bb: ; preds = %bb, %bb.nph
17 %i.03 = phi i32 [ 0, %bb.nph ], [ %indvar.next, %bb ] ; <i32> [#uses=3]
18 tail call void @bar( i32 %i.03 ) nounwind
19 uitofp i32 %i.03 to double ; <double>:1 [#uses=1]
20 tail call void @foo( double %1 ) nounwind
21 %indvar.next = add i32 %i.03, 1 ; <i32> [#uses=2]
22 %exitcond = icmp eq i32 %indvar.next, %umax ; <i1> [#uses=1]
23 br i1 %exitcond, label %return, label %bb
25 return: ; preds = %bb, %entry
29 ; Unable to eliminate cast because the mantissa bits for double are not enough
30 ; to hold all of i64 IV bits.
31 define void @foobar2(i64 %n) nounwind {
33 icmp eq i64 %n, 0 ; <i1>:0 [#uses=2]
34 br i1 %0, label %return, label %bb.nph
36 bb.nph: ; preds = %entry
37 %umax = select i1 %0, i64 1, i64 %n ; <i64> [#uses=1]
40 bb: ; preds = %bb, %bb.nph
41 %i.03 = phi i64 [ 0, %bb.nph ], [ %indvar.next, %bb ] ; <i64> [#uses=3]
42 trunc i64 %i.03 to i32 ; <i32>:1 [#uses=1]
43 tail call void @bar( i32 %1 ) nounwind
44 uitofp i64 %i.03 to double ; <double>:2 [#uses=1]
45 tail call void @foo( double %2 ) nounwind
46 %indvar.next = add i64 %i.03, 1 ; <i64> [#uses=2]
47 %exitcond = icmp eq i64 %indvar.next, %umax ; <i1> [#uses=1]
48 br i1 %exitcond, label %return, label %bb
50 return: ; preds = %bb, %entry
54 ; Unable to eliminate cast due to potentional overflow.
55 define void @foobar3() nounwind {
57 tail call i32 (...) @nn( ) nounwind ; <i32>:0 [#uses=1]
58 icmp eq i32 %0, 0 ; <i1>:1 [#uses=1]
59 br i1 %1, label %return, label %bb
61 bb: ; preds = %bb, %entry
62 %i.03 = phi i32 [ 0, %entry ], [ %3, %bb ] ; <i32> [#uses=3]
63 tail call void @bar( i32 %i.03 ) nounwind
64 uitofp i32 %i.03 to double ; <double>:2 [#uses=1]
65 tail call void @foo( double %2 ) nounwind
66 add i32 %i.03, 1 ; <i32>:3 [#uses=2]
67 tail call i32 (...) @nn( ) nounwind ; <i32>:4 [#uses=1]
68 icmp ugt i32 %4, %3 ; <i1>:5 [#uses=1]
69 br i1 %5, label %bb, label %return
71 return: ; preds = %bb, %entry
75 ; Unable to eliminate cast due to overflow.
76 define void @foobar4() nounwind {
80 bb.nph: ; preds = %entry
83 bb: ; preds = %bb, %bb.nph
84 %i.03 = phi i8 [ 0, %bb.nph ], [ %indvar.next, %bb ] ; <i32> [#uses=3]
85 %tmp2 = sext i8 %i.03 to i32 ; <i32>:0 [#uses=1]
86 tail call void @bar( i32 %tmp2 ) nounwind
87 %tmp3 = uitofp i8 %i.03 to double ; <double>:1 [#uses=1]
88 tail call void @foo( double %tmp3 ) nounwind
89 %indvar.next = add i8 %i.03, 1 ; <i32> [#uses=2]
90 %tmp = sext i8 %indvar.next to i32
91 %exitcond = icmp eq i32 %tmp, 32767 ; <i1> [#uses=1]
92 br i1 %exitcond, label %return, label %bb
94 return: ; preds = %bb, %entry
98 declare void @bar(i32)
100 declare void @foo(double)