XFAIL this test for now.
[oota-llvm.git] / test / Transforms / LoopStrengthReduce / 2008-08-14-ShadowIV.ll
1 ; RUN: llvm-as < %s | opt -loop-reduce | llvm-dis | grep "phi double" | count 1
2 ; XFAIL: *
3
4 define void @foobar(i32 %n) nounwind {
5 entry:
6         icmp eq i32 %n, 0               ; <i1>:0 [#uses=2]
7         br i1 %0, label %return, label %bb.nph
8
9 bb.nph:         ; preds = %entry
10         %umax = select i1 %0, i32 1, i32 %n             ; <i32> [#uses=1]
11         br label %bb
12
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
21
22 return:         ; preds = %bb, %entry
23         ret void
24 }
25
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 {
29 entry:
30         icmp eq i64 %n, 0               ; <i1>:0 [#uses=2]
31         br i1 %0, label %return, label %bb.nph
32
33 bb.nph:         ; preds = %entry
34         %umax = select i1 %0, i64 1, i64 %n             ; <i64> [#uses=1]
35         br label %bb
36
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
46
47 return:         ; preds = %bb, %entry
48         ret void
49 }
50
51 ; Unable to eliminate cast due to potentional overflow.
52 define void @foobar3() nounwind {
53 entry:
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
57
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
67
68 return:         ; preds = %bb, %entry
69         ret void
70 }
71
72 ; Unable to eliminate cast due to overflow.
73 define void @foobar4() nounwind {
74 entry:
75         br label %bb.nph
76
77 bb.nph:         ; preds = %entry
78         br label %bb
79
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
90
91 return:         ; preds = %bb, %entry
92         ret void
93 }
94
95 declare void @bar(i32)
96
97 declare void @foo(double)
98
99 declare i32 @nn(...)
100