• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -loop-reduce -S | grep "phi double" | count 1
2
3define void @foobar(i32 %n) nounwind {
4entry:
5	icmp eq i32 %n, 0		; <i1>:0 [#uses=2]
6	br i1 %0, label %return, label %bb.nph
7
8bb.nph:		; preds = %entry
9	%umax = select i1 %0, i32 1, i32 %n		; <i32> [#uses=1]
10	br label %bb
11
12bb:		; 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
20
21return:		; preds = %bb, %entry
22	ret void
23}
24
25; Unable to eliminate cast because the mantissa bits for double are not enough
26; to hold all of i64 IV bits.
27define void @foobar2(i64 %n) nounwind {
28entry:
29	icmp eq i64 %n, 0		; <i1>:0 [#uses=2]
30	br i1 %0, label %return, label %bb.nph
31
32bb.nph:		; preds = %entry
33	%umax = select i1 %0, i64 1, i64 %n		; <i64> [#uses=1]
34	br label %bb
35
36bb:		; 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
45
46return:		; preds = %bb, %entry
47	ret void
48}
49
50; Unable to eliminate cast due to potentional overflow.
51define void @foobar3() nounwind {
52entry:
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
56
57bb:		; 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
66
67return:		; preds = %bb, %entry
68	ret void
69}
70
71; Unable to eliminate cast due to overflow.
72define void @foobar4() nounwind {
73entry:
74	br label %bb.nph
75
76bb.nph:		; preds = %entry
77	br label %bb
78
79bb:		; 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
89
90return:		; preds = %bb, %entry
91	ret void
92}
93
94declare void @bar(i32)
95
96declare void @foo(double)
97
98declare i32 @nn(...)
99
100