xref: /llvm-project/clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-fp.c (revision 39db5e1ed87363a9ffea81e53520b542201b3262)
1 // REQUIRES: powerpc-registered-target
2 // RUN: %clang_cc1 -triple powerpc64le-unknown-linux-gnu \
3 // RUN:   -emit-llvm %s -o - -target-cpu pwr8 | FileCheck %s
4 // RUN: %clang_cc1 -triple powerpc64-unknown-aix \
5 // RUN:   -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
6 // RUN: %clang_cc1 -triple powerpc-unknown-aix \
7 // RUN:   -emit-llvm %s -o - -target-cpu pwr7 | FileCheck %s
8 
9 extern double a;
10 extern double b;
11 extern double c;
12 extern float d;
13 extern float e;
14 extern float f;
15 
16 // CHECK-LABEL: @test_fric(
17 // CHECK:    [[TMP0:%.*]] = load double, ptr @a, align 8
18 // CHECK-NEXT:    [[TMP1:%.*]] = call double @llvm.rint.f64(double [[TMP0]])
19 // CHECK-NEXT:    ret double [[TMP1]]
20 //
test_fric()21 double test_fric() {
22   return __fric(a);
23 }
24 
25 // CHECK-LABEL: @test_frim(
26 // CHECK:    [[TMP0:%.*]] = load double, ptr @a, align 8
27 // CHECK-NEXT:    [[TMP1:%.*]] = call double @llvm.floor.f64(double [[TMP0]])
28 // CHECK-NEXT:    ret double [[TMP1]]
29 //
test_frim()30 double test_frim() {
31   return __frim(a);
32 }
33 
34 // CHECK-LABEL: @test_frims(
35 // CHECK:    [[TMP0:%.*]] = load float, ptr @d, align 4
36 // CHECK-NEXT:    [[TMP1:%.*]] = call float @llvm.floor.f32(float [[TMP0]])
37 // CHECK-NEXT:    ret float [[TMP1]]
38 //
test_frims()39 float test_frims() {
40   return __frims(d);
41 }
42 
43 // CHECK-LABEL: @test_frin(
44 // CHECK:    [[TMP0:%.*]] = load double, ptr @a, align 8
45 // CHECK-NEXT:    [[TMP1:%.*]] = call double @llvm.round.f64(double [[TMP0]])
46 // CHECK-NEXT:    ret double [[TMP1]]
47 //
test_frin()48 double test_frin() {
49   return __frin(a);
50 }
51 
52 // CHECK-LABEL: @test_frins(
53 // CHECK:    [[TMP0:%.*]] = load float, ptr @d, align 4
54 // CHECK-NEXT:    [[TMP1:%.*]] = call float @llvm.round.f32(float [[TMP0]])
55 // CHECK-NEXT:    ret float [[TMP1]]
56 //
test_frins()57 float test_frins() {
58   return __frins(d);
59 }
60 
61 // CHECK-LABEL: @test_frip(
62 // CHECK:    [[TMP0:%.*]] = load double, ptr @a, align 8
63 // CHECK-NEXT:    [[TMP1:%.*]] = call double @llvm.ceil.f64(double [[TMP0]])
64 // CHECK-NEXT:    ret double [[TMP1]]
65 //
test_frip()66 double test_frip() {
67   return __frip(a);
68 }
69 
70 // CHECK-LABEL: @test_frips(
71 // CHECK:    [[TMP0:%.*]] = load float, ptr @d, align 4
72 // CHECK-NEXT:    [[TMP1:%.*]] = call float @llvm.ceil.f32(float [[TMP0]])
73 // CHECK-NEXT:    ret float [[TMP1]]
74 //
test_frips()75 float test_frips() {
76   return __frips(d);
77 }
78 
79 // CHECK-LABEL: @test_friz(
80 // CHECK:    [[TMP0:%.*]] = load double, ptr @a, align 8
81 // CHECK-NEXT:    [[TMP1:%.*]] = call double @llvm.trunc.f64(double [[TMP0]])
82 // CHECK-NEXT:    ret double [[TMP1]]
83 //
test_friz()84 double test_friz() {
85   return __friz(a);
86 }
87 
88 // CHECK-LABEL: @test_frizs(
89 // CHECK:    [[TMP0:%.*]] = load float, ptr @d, align 4
90 // CHECK-NEXT:    [[TMP1:%.*]] = call float @llvm.trunc.f32(float [[TMP0]])
91 // CHECK-NEXT:    ret float [[TMP1]]
92 //
test_frizs()93 float test_frizs() {
94   return __frizs(d);
95 }
96 
97 // CHECK-LABEL: @test_fsel(
98 // CHECK:    [[TMP0:%.*]] = load double, ptr @a, align 8
99 // CHECK-NEXT:    [[TMP1:%.*]] = load double, ptr @b, align 8
100 // CHECK-NEXT:    [[TMP2:%.*]] = load double, ptr @c, align 8
101 // CHECK-NEXT:    [[TMP3:%.*]] = call double @llvm.ppc.fsel(double [[TMP0]], double [[TMP1]], double [[TMP2]])
102 // CHECK-NEXT:    ret double [[TMP3]]
103 //
test_fsel()104 double test_fsel() {
105   return __fsel(a, b, c);
106 }
107 
108 // CHECK-LABEL: @test_fsels(
109 // CHECK:    [[TMP0:%.*]] = load float, ptr @d, align 4
110 // CHECK-NEXT:    [[TMP1:%.*]] = load float, ptr @e, align 4
111 // CHECK-NEXT:    [[TMP2:%.*]] = load float, ptr @f, align 4
112 // CHECK-NEXT:    [[TMP3:%.*]] = call float @llvm.ppc.fsels(float [[TMP0]], float [[TMP1]], float [[TMP2]])
113 // CHECK-NEXT:    ret float [[TMP3]]
114 //
test_fsels()115 float test_fsels() {
116   return __fsels(d, e, f);
117 }
118 
119 // CHECK-LABEL: @test_frsqrte(
120 // CHECK:    [[TMP0:%.*]] = load double, ptr @a, align 8
121 // CHECK-NEXT:    [[TMP1:%.*]] = call double @llvm.ppc.frsqrte(double [[TMP0]])
122 // CHECK-NEXT:    ret double [[TMP1]]
123 //
test_frsqrte()124 double test_frsqrte() {
125   return __frsqrte(a);
126 }
127 
128 // CHECK-LABEL: @test_frsqrtes(
129 // CHECK:    [[TMP0:%.*]] = load float, ptr @d, align 4
130 // CHECK-NEXT:    [[TMP1:%.*]] = call float @llvm.ppc.frsqrtes(float [[TMP0]])
131 // CHECK-NEXT:    ret float [[TMP1]]
132 //
test_frsqrtes()133 float test_frsqrtes() {
134   return __frsqrtes(d);
135 }
136 
137 // CHECK-LABEL: @test_fsqrt(
138 // CHECK:    [[TMP0:%.*]] = load double, ptr @a, align 8
139 // CHECK-NEXT:    [[TMP1:%.*]] = call double @llvm.sqrt.f64(double [[TMP0]])
140 // CHECK-NEXT:    ret double [[TMP1]]
141 //
test_fsqrt()142 double test_fsqrt() {
143   return __fsqrt(a);
144 }
145 
146 // CHECK-LABEL: @test_fsqrts(
147 // CHECK:    [[TMP0:%.*]] = load float, ptr @d, align 4
148 // CHECK-NEXT:    [[TMP1:%.*]] = call float @llvm.sqrt.f32(float [[TMP0]])
149 // CHECK-NEXT:    ret float [[TMP1]]
150 //
test_fsqrts()151 float test_fsqrts() {
152   return __fsqrts(d);
153 }
154 
155 // CHECK-LABEL: @test_builtin_ppc_fric(
156 // CHECK:    [[TMP0:%.*]] = load double, ptr @a, align 8
157 // CHECK-NEXT:    [[TMP1:%.*]] = call double @llvm.rint.f64(double [[TMP0]])
158 // CHECK-NEXT:    ret double [[TMP1]]
159 //
test_builtin_ppc_fric()160 double test_builtin_ppc_fric() {
161   return __builtin_ppc_fric(a);
162 }
163 
164 // CHECK-LABEL: @test_builtin_ppc_frim(
165 // CHECK:    [[TMP0:%.*]] = load double, ptr @a, align 8
166 // CHECK-NEXT:    [[TMP1:%.*]] = call double @llvm.floor.f64(double [[TMP0]])
167 // CHECK-NEXT:    ret double [[TMP1]]
168 //
test_builtin_ppc_frim()169 double test_builtin_ppc_frim() {
170   return __builtin_ppc_frim(a);
171 }
172 
173 // CHECK-LABEL: @test_builtin_ppc_frims(
174 // CHECK:    [[TMP0:%.*]] = load float, ptr @d, align 4
175 // CHECK-NEXT:    [[TMP1:%.*]] = call float @llvm.floor.f32(float [[TMP0]])
176 // CHECK-NEXT:    ret float [[TMP1]]
177 //
test_builtin_ppc_frims()178 float test_builtin_ppc_frims() {
179   return __builtin_ppc_frims(d);
180 }
181 
182 // CHECK-LABEL: @test_builtin_ppc_frin(
183 // CHECK:    [[TMP0:%.*]] = load double, ptr @a, align 8
184 // CHECK-NEXT:    [[TMP1:%.*]] = call double @llvm.round.f64(double [[TMP0]])
185 // CHECK-NEXT:    ret double [[TMP1]]
186 //
test_builtin_ppc_frin()187 double test_builtin_ppc_frin() {
188   return __builtin_ppc_frin(a);
189 }
190 
191 // CHECK-LABEL: @test_builtin_ppc_frins(
192 // CHECK:    [[TMP0:%.*]] = load float, ptr @d, align 4
193 // CHECK-NEXT:    [[TMP1:%.*]] = call float @llvm.round.f32(float [[TMP0]])
194 // CHECK-NEXT:    ret float [[TMP1]]
195 //
test_builtin_ppc_frins()196 float test_builtin_ppc_frins() {
197   return __builtin_ppc_frins(d);
198 }
199 
200 // CHECK-LABEL: @test_builtin_ppc_frip(
201 // CHECK:    [[TMP0:%.*]] = load double, ptr @a, align 8
202 // CHECK-NEXT:    [[TMP1:%.*]] = call double @llvm.ceil.f64(double [[TMP0]])
203 // CHECK-NEXT:    ret double [[TMP1]]
204 //
test_builtin_ppc_frip()205 double test_builtin_ppc_frip() {
206   return __builtin_ppc_frip(a);
207 }
208 
209 // CHECK-LABEL: @test_builtin_ppc_frips(
210 // CHECK:    [[TMP0:%.*]] = load float, ptr @d, align 4
211 // CHECK-NEXT:    [[TMP1:%.*]] = call float @llvm.ceil.f32(float [[TMP0]])
212 // CHECK-NEXT:    ret float [[TMP1]]
213 //
test_builtin_ppc_frips()214 float test_builtin_ppc_frips() {
215   return __builtin_ppc_frips(d);
216 }
217 
218 // CHECK-LABEL: @test_builtin_ppc_friz(
219 // CHECK:    [[TMP0:%.*]] = load double, ptr @a, align 8
220 // CHECK-NEXT:    [[TMP1:%.*]] = call double @llvm.trunc.f64(double [[TMP0]])
221 // CHECK-NEXT:    ret double [[TMP1]]
222 //
test_builtin_ppc_friz()223 double test_builtin_ppc_friz() {
224   return __builtin_ppc_friz(a);
225 }
226 
227 // CHECK-LABEL: @test_builtin_ppc_frizs(
228 // CHECK:    [[TMP0:%.*]] = load float, ptr @d, align 4
229 // CHECK-NEXT:    [[TMP1:%.*]] = call float @llvm.trunc.f32(float [[TMP0]])
230 // CHECK-NEXT:    ret float [[TMP1]]
231 //
test_builtin_ppc_frizs()232 float test_builtin_ppc_frizs() {
233   return __builtin_ppc_frizs(d);
234 }
235 
236 // CHECK-LABEL: @test_builtin_ppc_fsel(
237 // CHECK:    [[TMP0:%.*]] = load double, ptr @a, align 8
238 // CHECK-NEXT:    [[TMP1:%.*]] = load double, ptr @b, align 8
239 // CHECK-NEXT:    [[TMP2:%.*]] = load double, ptr @c, align 8
240 // CHECK-NEXT:    [[TMP3:%.*]] = call double @llvm.ppc.fsel(double [[TMP0]], double [[TMP1]], double [[TMP2]])
241 // CHECK-NEXT:    ret double [[TMP3]]
242 //
test_builtin_ppc_fsel()243 double test_builtin_ppc_fsel() {
244   return __builtin_ppc_fsel(a, b, c);
245 }
246 
247 // CHECK-LABEL: @test_builtin_ppc_fsels(
248 // CHECK:    [[TMP0:%.*]] = load float, ptr @d, align 4
249 // CHECK-NEXT:    [[TMP1:%.*]] = load float, ptr @e, align 4
250 // CHECK-NEXT:    [[TMP2:%.*]] = load float, ptr @f, align 4
251 // CHECK-NEXT:    [[TMP3:%.*]] = call float @llvm.ppc.fsels(float [[TMP0]], float [[TMP1]], float [[TMP2]])
252 // CHECK-NEXT:    ret float [[TMP3]]
253 //
test_builtin_ppc_fsels()254 float test_builtin_ppc_fsels() {
255   return __builtin_ppc_fsels(d, e, f);
256 }
257 
258 // CHECK-LABEL: @test_builtin_ppc_frsqrte(
259 // CHECK:    [[TMP0:%.*]] = load double, ptr @a, align 8
260 // CHECK-NEXT:    [[TMP1:%.*]] = call double @llvm.ppc.frsqrte(double [[TMP0]])
261 // CHECK-NEXT:    ret double [[TMP1]]
262 //
test_builtin_ppc_frsqrte()263 double test_builtin_ppc_frsqrte() {
264   return __builtin_ppc_frsqrte(a);
265 }
266 
267 // CHECK-LABEL: @test_builtin_ppc_frsqrtes(
268 // CHECK:    [[TMP0:%.*]] = load float, ptr @d, align 4
269 // CHECK-NEXT:    [[TMP1:%.*]] = call float @llvm.ppc.frsqrtes(float [[TMP0]])
270 // CHECK-NEXT:    ret float [[TMP1]]
271 //
test_builtin_ppc_frsqrtes()272 float test_builtin_ppc_frsqrtes() {
273   return __builtin_ppc_frsqrtes(d);
274 }
275 
276 // CHECK-LABEL: @test_builtin_ppc_fsqrt(
277 // CHECK:    [[TMP0:%.*]] = load double, ptr @a, align 8
278 // CHECK-NEXT:    [[TMP1:%.*]] = call double @llvm.sqrt.f64(double [[TMP0]])
279 // CHECK-NEXT:    ret double [[TMP1]]
280 //
test_builtin_ppc_fsqrt()281 double test_builtin_ppc_fsqrt() {
282   return __builtin_ppc_fsqrt(a);
283 }
284 
285 // CHECK-LABEL: @test_builtin_ppc_fsqrts(
286 // CHECK:    [[TMP0:%.*]] = load float, ptr @d, align 4
287 // CHECK-NEXT:    [[TMP1:%.*]] = call float @llvm.sqrt.f32(float [[TMP0]])
288 // CHECK-NEXT:    ret float [[TMP1]]
289 //
test_builtin_ppc_fsqrts()290 float test_builtin_ppc_fsqrts() {
291   return __builtin_ppc_fsqrts(d);
292 }
293