• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -loop-reduce -S -mtriple=x86_64-unknown-unknown | grep "phi double" | count 1
2
3; Provide legal integer types.
4target datalayout = "n8:16:32:64"
5
6
7define void @foobar(i32 %n) nounwind {
8entry:
9	icmp eq i32 %n, 0		; <i1>:0 [#uses=2]
10	br i1 %0, label %return, label %bb.nph
11
12bb.nph:		; preds = %entry
13	%umax = select i1 %0, i32 1, i32 %n		; <i32> [#uses=1]
14	br label %bb
15
16bb:		; 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
24
25return:		; preds = %bb, %entry
26	ret void
27}
28
29; Unable to eliminate cast because the mantissa bits for double are not enough
30; to hold all of i64 IV bits.
31define void @foobar2(i64 %n) nounwind {
32entry:
33	icmp eq i64 %n, 0		; <i1>:0 [#uses=2]
34	br i1 %0, label %return, label %bb.nph
35
36bb.nph:		; preds = %entry
37	%umax = select i1 %0, i64 1, i64 %n		; <i64> [#uses=1]
38	br label %bb
39
40bb:		; 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
49
50return:		; preds = %bb, %entry
51	ret void
52}
53
54; Unable to eliminate cast due to potentional overflow.
55define void @foobar3() nounwind {
56entry:
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
60
61bb:		; 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
70
71return:		; preds = %bb, %entry
72	ret void
73}
74
75; Unable to eliminate cast due to overflow.
76define void @foobar4() nounwind {
77entry:
78	br label %bb.nph
79
80bb.nph:		; preds = %entry
81	br label %bb
82
83bb:		; 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
93
94return:		; preds = %bb, %entry
95	ret void
96}
97
98declare void @bar(i32)
99
100declare void @foo(double)
101
102declare i32 @nn(...)
103
104