Update Transforms tests to use CHECK-LABEL for easier debugging. No functionality...
[oota-llvm.git] / test / Transforms / InstCombine / float-shrink-compare.ll
1 ; RUN: opt -S -instcombine < %s | FileCheck %s
2 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
3 target triple = "x86_64-apple-macosx10.8.0"
4
5 define i32 @test1(float %x, float %y) nounwind uwtable {
6   %1 = fpext float %x to double
7   %2 = call double @ceil(double %1) nounwind readnone
8   %3 = fpext float %y to double
9   %4 = fcmp oeq double %2, %3
10   %5 = zext i1 %4 to i32
11   ret i32 %5
12 ; CHECK-LABEL: @test1(
13 ; CHECK-NEXT: %ceilf = call float @ceilf(float %x)
14 ; CHECK-NEXT: fcmp oeq float %ceilf, %y
15 }
16
17 define i32 @test2(float %x, float %y) nounwind uwtable {
18   %1 = fpext float %x to double
19   %2 = call double @fabs(double %1) nounwind readnone
20   %3 = fpext float %y to double
21   %4 = fcmp oeq double %2, %3
22   %5 = zext i1 %4 to i32
23   ret i32 %5
24 ; CHECK-LABEL: @test2(
25 ; CHECK-NEXT: %fabsf = call float @fabsf(float %x)
26 ; CHECK-NEXT: fcmp oeq float %fabsf, %y
27 }
28
29 define i32 @test3(float %x, float %y) nounwind uwtable {
30   %1 = fpext float %x to double
31   %2 = call double @floor(double %1) nounwind readnone
32   %3 = fpext float %y to double
33   %4 = fcmp oeq double %2, %3
34   %5 = zext i1 %4 to i32
35   ret i32 %5
36 ; CHECK-LABEL: @test3(
37 ; CHECK-NEXT: %floorf = call float @floorf(float %x)
38 ; CHECK-NEXT: fcmp oeq float %floorf, %y
39 }
40
41 define i32 @test4(float %x, float %y) nounwind uwtable {
42   %1 = fpext float %x to double
43   %2 = call double @nearbyint(double %1) nounwind
44   %3 = fpext float %y to double
45   %4 = fcmp oeq double %2, %3
46   %5 = zext i1 %4 to i32
47   ret i32 %5
48 ; CHECK-LABEL: @test4(
49 ; CHECK-NEXT: %nearbyintf = call float @nearbyintf(float %x)
50 ; CHECK-NEXT: fcmp oeq float %nearbyintf, %y
51 }
52
53 define i32 @test5(float %x, float %y) nounwind uwtable {
54   %1 = fpext float %x to double
55   %2 = call double @rint(double %1) nounwind
56   %3 = fpext float %y to double
57   %4 = fcmp oeq double %2, %3
58   %5 = zext i1 %4 to i32
59   ret i32 %5
60 ; CHECK-LABEL: @test5(
61 ; CHECK-NEXT: %rintf = call float @rintf(float %x)
62 ; CHECK-NEXT: fcmp oeq float %rintf, %y
63 }
64
65 define i32 @test6(float %x, float %y) nounwind uwtable {
66   %1 = fpext float %x to double
67   %2 = call double @round(double %1) nounwind readnone
68   %3 = fpext float %y to double
69   %4 = fcmp oeq double %2, %3
70   %5 = zext i1 %4 to i32
71   ret i32 %5
72 ; CHECK-LABEL: @test6(
73 ; CHECK-NEXT: %roundf = call float @roundf(float %x)
74 ; CHECK-NEXT: fcmp oeq float %roundf, %y
75 }
76
77 define i32 @test7(float %x, float %y) nounwind uwtable {
78   %1 = fpext float %x to double
79   %2 = call double @trunc(double %1) nounwind
80   %3 = fpext float %y to double
81   %4 = fcmp oeq double %2, %3
82   %5 = zext i1 %4 to i32
83   ret i32 %5
84 ; CHECK-LABEL: @test7(
85 ; CHECK-NEXT: %truncf = call float @truncf(float %x)
86 ; CHECK-NEXT: fcmp oeq float %truncf, %y
87 }
88
89 define i32 @test8(float %x, float %y) nounwind uwtable {
90   %1 = fpext float %y to double
91   %2 = fpext float %x to double
92   %3 = call double @ceil(double %2) nounwind readnone
93   %4 = fcmp oeq double %1, %3
94   %5 = zext i1 %4 to i32
95   ret i32 %5
96 ; CHECK-LABEL: @test8(
97 ; CHECK-NEXT: %ceilf = call float @ceilf(float %x)
98 ; CHECK-NEXT: fcmp oeq float %ceilf, %y
99 }
100
101 define i32 @test9(float %x, float %y) nounwind uwtable {
102   %1 = fpext float %y to double
103   %2 = fpext float %x to double
104   %3 = call double @fabs(double %2) nounwind readnone
105   %4 = fcmp oeq double %1, %3
106   %5 = zext i1 %4 to i32
107   ret i32 %5
108 ; CHECK-LABEL: @test9(
109 ; CHECK-NEXT: %fabsf = call float @fabsf(float %x)
110 ; CHECK-NEXT: fcmp oeq float %fabsf, %y
111 }
112
113 define i32 @test10(float %x, float %y) nounwind uwtable {
114   %1 = fpext float %y to double
115   %2 = fpext float %x to double
116   %3 = call double @floor(double %2) nounwind readnone
117   %4 = fcmp oeq double %1, %3
118   %5 = zext i1 %4 to i32
119   ret i32 %5
120 ; CHECK-LABEL: @test10(
121 ; CHECK-NEXT: %floorf = call float @floorf(float %x)
122 ; CHECK-NEXT: fcmp oeq float %floorf, %y
123 }
124
125 define i32 @test11(float %x, float %y) nounwind uwtable {
126   %1 = fpext float %y to double
127   %2 = fpext float %x to double
128   %3 = call double @nearbyint(double %2) nounwind
129   %4 = fcmp oeq double %1, %3
130   %5 = zext i1 %4 to i32
131   ret i32 %5
132 ; CHECK-LABEL: @test11(
133 ; CHECK-NEXT: %nearbyintf = call float @nearbyintf(float %x)
134 ; CHECK-NEXT: fcmp oeq float %nearbyintf, %y
135 }
136
137 define i32 @test12(float %x, float %y) nounwind uwtable {
138   %1 = fpext float %y to double
139   %2 = fpext float %x to double
140   %3 = call double @rint(double %2) nounwind
141   %4 = fcmp oeq double %1, %3
142   %5 = zext i1 %4 to i32
143   ret i32 %5
144 ; CHECK-LABEL: @test12(
145 ; CHECK-NEXT: %rintf = call float @rintf(float %x)
146 ; CHECK-NEXT: fcmp oeq float %rintf, %y
147 }
148
149 define i32 @test13(float %x, float %y) nounwind uwtable {
150   %1 = fpext float %y to double
151   %2 = fpext float %x to double
152   %3 = call double @round(double %2) nounwind readnone
153   %4 = fcmp oeq double %1, %3
154   %5 = zext i1 %4 to i32
155   ret i32 %5
156 ; CHECK-LABEL: @test13(
157 ; CHECK-NEXT: %roundf = call float @roundf(float %x)
158 ; CHECK-NEXT: fcmp oeq float %roundf, %y
159 }
160
161 define i32 @test14(float %x, float %y) nounwind uwtable {
162   %1 = fpext float %y to double
163   %2 = fpext float %x to double
164   %3 = call double @trunc(double %2) nounwind
165   %4 = fcmp oeq double %1, %3
166   %5 = zext i1 %4 to i32
167   ret i32 %5
168 ; CHECK-LABEL: @test14(
169 ; CHECK-NEXT: %truncf = call float @truncf(float %x)
170 ; CHECK-NEXT: fcmp oeq float %truncf, %y
171 }
172
173 declare double @fabs(double) nounwind readnone
174 declare double @ceil(double) nounwind readnone
175 declare double @floor(double) nounwind readnone
176 declare double @nearbyint(double) nounwind readnone
177 declare double @rint(double) nounwind readnone
178 declare double @round(double) nounwind readnone
179 declare double @trunc(double) nounwind readnone