1 // RUN: %clang_cc1 %s -O0 -fno-experimental-new-pass-manager -emit-llvm -triple x86_64-unknown-unknown -o - | FileCheck %s --check-prefix=X86
2 // RUN: %clang_cc1 %s -O0 -fno-experimental-new-pass-manager -emit-llvm -triple x86_64-pc-win64 -o - | FileCheck %s --check-prefix=X86
3 // RUN: %clang_cc1 %s -O0 -fno-experimental-new-pass-manager -emit-llvm -triple i686-unknown-unknown -o - | FileCheck %s --check-prefix=X86
4 // RUN: %clang_cc1 %s -O0 -fno-experimental-new-pass-manager -emit-llvm -triple powerpc-unknown-unknown -o - | FileCheck %s --check-prefix=PPC
5 // RUN: %clang_cc1 %s -O0 -fno-experimental-new-pass-manager -emit-llvm -triple armv7-none-linux-gnueabi -o - | FileCheck %s --check-prefix=ARM
6 // RUN: %clang_cc1 %s -O0 -fno-experimental-new-pass-manager -emit-llvm -triple armv7-none-linux-gnueabihf -o - | FileCheck %s --check-prefix=ARMHF
7 // RUN: %clang_cc1 %s -O0 -fno-experimental-new-pass-manager -emit-llvm -triple thumbv7k-apple-watchos2.0 -o - -target-abi aapcs16 | FileCheck %s --check-prefix=ARM7K
8 // RUN: %clang_cc1 %s -O0 -fno-experimental-new-pass-manager -emit-llvm -triple aarch64-unknown-unknown -ffast-math -ffp-contract=fast -o - | FileCheck %s --check-prefix=AARCH64-FASTMATH
9
add_float_rr(float a,float b)10 float _Complex add_float_rr(float a, float b) {
11 // X86-LABEL: @add_float_rr(
12 // X86: fadd
13 // X86-NOT: fadd
14 // X86: ret
15 return a + b;
16 }
add_float_cr(float _Complex a,float b)17 float _Complex add_float_cr(float _Complex a, float b) {
18 // X86-LABEL: @add_float_cr(
19 // X86: fadd
20 // X86-NOT: fadd
21 // X86: ret
22 return a + b;
23 }
add_float_rc(float a,float _Complex b)24 float _Complex add_float_rc(float a, float _Complex b) {
25 // X86-LABEL: @add_float_rc(
26 // X86: fadd
27 // X86-NOT: fadd
28 // X86: ret
29 return a + b;
30 }
add_float_cc(float _Complex a,float _Complex b)31 float _Complex add_float_cc(float _Complex a, float _Complex b) {
32 // X86-LABEL: @add_float_cc(
33 // X86: fadd
34 // X86: fadd
35 // X86-NOT: fadd
36 // X86: ret
37 return a + b;
38 }
39
sub_float_rr(float a,float b)40 float _Complex sub_float_rr(float a, float b) {
41 // X86-LABEL: @sub_float_rr(
42 // X86: fsub
43 // X86-NOT: fsub
44 // X86: ret
45 return a - b;
46 }
sub_float_cr(float _Complex a,float b)47 float _Complex sub_float_cr(float _Complex a, float b) {
48 // X86-LABEL: @sub_float_cr(
49 // X86: fsub
50 // X86-NOT: fsub
51 // X86: ret
52 return a - b;
53 }
sub_float_rc(float a,float _Complex b)54 float _Complex sub_float_rc(float a, float _Complex b) {
55 // X86-LABEL: @sub_float_rc(
56 // X86: fsub
57 // X86: fneg
58 // X86-NOT: fsub
59 // X86: ret
60 return a - b;
61 }
sub_float_cc(float _Complex a,float _Complex b)62 float _Complex sub_float_cc(float _Complex a, float _Complex b) {
63 // X86-LABEL: @sub_float_cc(
64 // X86: fsub
65 // X86: fsub
66 // X86-NOT: fsub
67 // X86: ret
68 return a - b;
69 }
70
mul_float_rr(float a,float b)71 float _Complex mul_float_rr(float a, float b) {
72 // X86-LABEL: @mul_float_rr(
73 // X86: fmul
74 // X86-NOT: fmul
75 // X86: ret
76 return a * b;
77 }
mul_float_cr(float _Complex a,float b)78 float _Complex mul_float_cr(float _Complex a, float b) {
79 // X86-LABEL: @mul_float_cr(
80 // X86: fmul
81 // X86: fmul
82 // X86-NOT: fmul
83 // X86: ret
84 return a * b;
85 }
mul_float_rc(float a,float _Complex b)86 float _Complex mul_float_rc(float a, float _Complex b) {
87 // X86-LABEL: @mul_float_rc(
88 // X86: fmul
89 // X86: fmul
90 // X86-NOT: fmul
91 // X86: ret
92 return a * b;
93 }
94
mul_float_cc(float _Complex a,float _Complex b)95 float _Complex mul_float_cc(float _Complex a, float _Complex b) {
96 // X86-LABEL: @mul_float_cc(
97 // X86: %[[AC:[^ ]+]] = fmul
98 // X86: %[[BD:[^ ]+]] = fmul
99 // X86: %[[AD:[^ ]+]] = fmul
100 // X86: %[[BC:[^ ]+]] = fmul
101 // X86: %[[RR:[^ ]+]] = fsub
102 // X86: %[[RI:[^ ]+]] = fadd
103 // X86-DAG: %[[AD]]
104 // X86-DAG: ,
105 // X86-DAG: %[[BC]]
106 // X86: fcmp uno float %[[RR]]
107 // X86: fcmp uno float %[[RI]]
108 // X86: call {{.*}} @__mulsc3(
109 // X86: ret
110 return a * b;
111 }
112
div_float_rr(float a,float b)113 float _Complex div_float_rr(float a, float b) {
114 // X86-LABEL: @div_float_rr(
115 // X86: fdiv
116 // X86-NOT: fdiv
117 // X86: ret
118 return a / b;
119 }
div_float_cr(float _Complex a,float b)120 float _Complex div_float_cr(float _Complex a, float b) {
121 // X86-LABEL: @div_float_cr(
122 // X86: fdiv
123 // X86: fdiv
124 // X86-NOT: fdiv
125 // X86: ret
126 return a / b;
127 }
div_float_rc(float a,float _Complex b)128 float _Complex div_float_rc(float a, float _Complex b) {
129 // X86-LABEL: @div_float_rc(
130 // X86-NOT: fdiv
131 // X86: call {{.*}} @__divsc3(
132 // X86: ret
133
134 // a / b = (A+iB) / (C+iD) = ((AC+BD)/(CC+DD)) + i((BC-AD)/(CC+DD))
135 // AARCH64-FASTMATH-LABEL: @div_float_rc(float %a, [2 x float] %b.coerce)
136 // A = a
137 // B = 0
138 //
139 // AARCH64-FASTMATH: [[AC:%.*]] = fmul fast float
140 // BD = 0
141 // ACpBD = AC
142 //
143 // AARCH64-FASTMATH: [[CC:%.*]] = fmul fast float
144 // AARCH64-FASTMATH: [[DD:%.*]] = fmul fast float
145 // AARCH64-FASTMATH: [[CCpDD:%.*]] = fadd fast float
146 //
147 // BC = 0
148 // AARCH64-FASTMATH: [[AD:%.*]] = fmul fast float
149 //
150 // AARCH64-FASTMATH: fdiv fast float
151 // AARCH64-FASTMATH: fdiv fast float
152 // AARCH64-FASTMATH: ret
153 return a / b;
154 }
div_float_cc(float _Complex a,float _Complex b)155 float _Complex div_float_cc(float _Complex a, float _Complex b) {
156 // X86-LABEL: @div_float_cc(
157 // X86-NOT: fdiv
158 // X86: call {{.*}} @__divsc3(
159 // X86: ret
160
161 // a / b = (A+iB) / (C+iD) = ((AC+BD)/(CC+DD)) + i((BC-AD)/(CC+DD))
162 // AARCH64-FASTMATH-LABEL: @div_float_cc([2 x float] %a.coerce, [2 x float] %b.coerce)
163 //
164 // AARCH64-FASTMATH: [[AC:%.*]] = fmul fast float
165 // AARCH64-FASTMATH: [[BD:%.*]] = fmul fast float
166 // AARCH64-FASTMATH: [[ACpBD:%.*]] = fadd fast float
167 //
168 // AARCH64-FASTMATH: [[CC:%.*]] = fmul fast float
169 // AARCH64-FASTMATH: [[DD:%.*]] = fmul fast float
170 // AARCH64-FASTMATH: [[CCpDD:%.*]] = fadd fast float
171 //
172 // AARCH64-FASTMATH: [[BC:%.*]] = fmul fast float
173 // AARCH64-FASTMATH: [[AD:%.*]] = fmul fast float
174 // AARCH64-FASTMATH: [[BCmAD:%.*]] = fsub fast float
175 //
176 // AARCH64-FASTMATH: fdiv fast float
177 // AARCH64-FASTMATH: fdiv fast float
178 // AARCH64-FASTMATH: ret
179 return a / b;
180 }
181
add_double_rr(double a,double b)182 double _Complex add_double_rr(double a, double b) {
183 // X86-LABEL: @add_double_rr(
184 // X86: fadd
185 // X86-NOT: fadd
186 // X86: ret
187 return a + b;
188 }
add_double_cr(double _Complex a,double b)189 double _Complex add_double_cr(double _Complex a, double b) {
190 // X86-LABEL: @add_double_cr(
191 // X86: fadd
192 // X86-NOT: fadd
193 // X86: ret
194 return a + b;
195 }
add_double_rc(double a,double _Complex b)196 double _Complex add_double_rc(double a, double _Complex b) {
197 // X86-LABEL: @add_double_rc(
198 // X86: fadd
199 // X86-NOT: fadd
200 // X86: ret
201 return a + b;
202 }
add_double_cc(double _Complex a,double _Complex b)203 double _Complex add_double_cc(double _Complex a, double _Complex b) {
204 // X86-LABEL: @add_double_cc(
205 // X86: fadd
206 // X86: fadd
207 // X86-NOT: fadd
208 // X86: ret
209 return a + b;
210 }
211
sub_double_rr(double a,double b)212 double _Complex sub_double_rr(double a, double b) {
213 // X86-LABEL: @sub_double_rr(
214 // X86: fsub
215 // X86-NOT: fsub
216 // X86: ret
217 return a - b;
218 }
sub_double_cr(double _Complex a,double b)219 double _Complex sub_double_cr(double _Complex a, double b) {
220 // X86-LABEL: @sub_double_cr(
221 // X86: fsub
222 // X86-NOT: fsub
223 // X86: ret
224 return a - b;
225 }
sub_double_rc(double a,double _Complex b)226 double _Complex sub_double_rc(double a, double _Complex b) {
227 // X86-LABEL: @sub_double_rc(
228 // X86: fsub
229 // X86: fneg
230 // X86-NOT: fsub
231 // X86: ret
232 return a - b;
233 }
sub_double_cc(double _Complex a,double _Complex b)234 double _Complex sub_double_cc(double _Complex a, double _Complex b) {
235 // X86-LABEL: @sub_double_cc(
236 // X86: fsub
237 // X86: fsub
238 // X86-NOT: fsub
239 // X86: ret
240 return a - b;
241 }
242
mul_double_rr(double a,double b)243 double _Complex mul_double_rr(double a, double b) {
244 // X86-LABEL: @mul_double_rr(
245 // X86: fmul
246 // X86-NOT: fmul
247 // X86: ret
248 return a * b;
249 }
mul_double_cr(double _Complex a,double b)250 double _Complex mul_double_cr(double _Complex a, double b) {
251 // X86-LABEL: @mul_double_cr(
252 // X86: fmul
253 // X86: fmul
254 // X86-NOT: fmul
255 // X86: ret
256 return a * b;
257 }
mul_double_rc(double a,double _Complex b)258 double _Complex mul_double_rc(double a, double _Complex b) {
259 // X86-LABEL: @mul_double_rc(
260 // X86: fmul
261 // X86: fmul
262 // X86-NOT: fmul
263 // X86: ret
264 return a * b;
265 }
mul_double_cc(double _Complex a,double _Complex b)266 double _Complex mul_double_cc(double _Complex a, double _Complex b) {
267 // X86-LABEL: @mul_double_cc(
268 // X86: %[[AC:[^ ]+]] = fmul
269 // X86: %[[BD:[^ ]+]] = fmul
270 // X86: %[[AD:[^ ]+]] = fmul
271 // X86: %[[BC:[^ ]+]] = fmul
272 // X86: %[[RR:[^ ]+]] = fsub double %[[AC]], %[[BD]]
273 // X86: %[[RI:[^ ]+]] = fadd double
274 // X86-DAG: %[[AD]]
275 // X86-DAG: ,
276 // X86-DAG: %[[BC]]
277 // X86: fcmp uno double %[[RR]]
278 // X86: fcmp uno double %[[RI]]
279 // X86: call {{.*}} @__muldc3(
280 // X86: ret
281 return a * b;
282 }
283
div_double_rr(double a,double b)284 double _Complex div_double_rr(double a, double b) {
285 // X86-LABEL: @div_double_rr(
286 // X86: fdiv
287 // X86-NOT: fdiv
288 // X86: ret
289 return a / b;
290 }
div_double_cr(double _Complex a,double b)291 double _Complex div_double_cr(double _Complex a, double b) {
292 // X86-LABEL: @div_double_cr(
293 // X86: fdiv
294 // X86: fdiv
295 // X86-NOT: fdiv
296 // X86: ret
297 return a / b;
298 }
div_double_rc(double a,double _Complex b)299 double _Complex div_double_rc(double a, double _Complex b) {
300 // X86-LABEL: @div_double_rc(
301 // X86-NOT: fdiv
302 // X86: call {{.*}} @__divdc3(
303 // X86: ret
304
305 // a / b = (A+iB) / (C+iD) = ((AC+BD)/(CC+DD)) + i((BC-AD)/(CC+DD))
306 // AARCH64-FASTMATH-LABEL: @div_double_rc(double %a, [2 x double] %b.coerce)
307 // A = a
308 // B = 0
309 //
310 // AARCH64-FASTMATH: [[AC:%.*]] = fmul fast double
311 // BD = 0
312 // ACpBD = AC
313 //
314 // AARCH64-FASTMATH: [[CC:%.*]] = fmul fast double
315 // AARCH64-FASTMATH: [[DD:%.*]] = fmul fast double
316 // AARCH64-FASTMATH: [[CCpDD:%.*]] = fadd fast double
317 //
318 // BC = 0
319 // AARCH64-FASTMATH: [[AD:%.*]] = fmul fast double
320 //
321 // AARCH64-FASTMATH: fdiv fast double
322 // AARCH64-FASTMATH: fdiv fast double
323 // AARCH64-FASTMATH: ret
324 return a / b;
325 }
div_double_cc(double _Complex a,double _Complex b)326 double _Complex div_double_cc(double _Complex a, double _Complex b) {
327 // X86-LABEL: @div_double_cc(
328 // X86-NOT: fdiv
329 // X86: call {{.*}} @__divdc3(
330 // X86: ret
331
332 // a / b = (A+iB) / (C+iD) = ((AC+BD)/(CC+DD)) + i((BC-AD)/(CC+DD))
333 // AARCH64-FASTMATH-LABEL: @div_double_cc([2 x double] %a.coerce, [2 x double] %b.coerce)
334 //
335 // AARCH64-FASTMATH: [[AC:%.*]] = fmul fast double
336 // AARCH64-FASTMATH: [[BD:%.*]] = fmul fast double
337 // AARCH64-FASTMATH: [[ACpBD:%.*]] = fadd fast double
338 //
339 // AARCH64-FASTMATH: [[CC:%.*]] = fmul fast double
340 // AARCH64-FASTMATH: [[DD:%.*]] = fmul fast double
341 // AARCH64-FASTMATH: [[CCpDD:%.*]] = fadd fast double
342 //
343 // AARCH64-FASTMATH: [[BC:%.*]] = fmul fast double
344 // AARCH64-FASTMATH: [[AD:%.*]] = fmul fast double
345 // AARCH64-FASTMATH: [[BCmAD:%.*]] = fsub fast double
346 //
347 // AARCH64-FASTMATH: fdiv fast double
348 // AARCH64-FASTMATH: fdiv fast double
349 // AARCH64-FASTMATH: ret
350 return a / b;
351 }
352
add_long_double_rr(long double a,long double b)353 long double _Complex add_long_double_rr(long double a, long double b) {
354 // X86-LABEL: @add_long_double_rr(
355 // X86: fadd
356 // X86-NOT: fadd
357 // X86: ret
358 return a + b;
359 }
add_long_double_cr(long double _Complex a,long double b)360 long double _Complex add_long_double_cr(long double _Complex a, long double b) {
361 // X86-LABEL: @add_long_double_cr(
362 // X86: fadd
363 // X86-NOT: fadd
364 // X86: ret
365 return a + b;
366 }
add_long_double_rc(long double a,long double _Complex b)367 long double _Complex add_long_double_rc(long double a, long double _Complex b) {
368 // X86-LABEL: @add_long_double_rc(
369 // X86: fadd
370 // X86-NOT: fadd
371 // X86: ret
372 return a + b;
373 }
add_long_double_cc(long double _Complex a,long double _Complex b)374 long double _Complex add_long_double_cc(long double _Complex a, long double _Complex b) {
375 // X86-LABEL: @add_long_double_cc(
376 // X86: fadd
377 // X86: fadd
378 // X86-NOT: fadd
379 // X86: ret
380 return a + b;
381 }
382
sub_long_double_rr(long double a,long double b)383 long double _Complex sub_long_double_rr(long double a, long double b) {
384 // X86-LABEL: @sub_long_double_rr(
385 // X86: fsub
386 // X86-NOT: fsub
387 // X86: ret
388 return a - b;
389 }
sub_long_double_cr(long double _Complex a,long double b)390 long double _Complex sub_long_double_cr(long double _Complex a, long double b) {
391 // X86-LABEL: @sub_long_double_cr(
392 // X86: fsub
393 // X86-NOT: fsub
394 // X86: ret
395 return a - b;
396 }
sub_long_double_rc(long double a,long double _Complex b)397 long double _Complex sub_long_double_rc(long double a, long double _Complex b) {
398 // X86-LABEL: @sub_long_double_rc(
399 // X86: fsub
400 // X86: fneg
401 // X86-NOT: fsub
402 // X86: ret
403 return a - b;
404 }
sub_long_double_cc(long double _Complex a,long double _Complex b)405 long double _Complex sub_long_double_cc(long double _Complex a, long double _Complex b) {
406 // X86-LABEL: @sub_long_double_cc(
407 // X86: fsub
408 // X86: fsub
409 // X86-NOT: fsub
410 // X86: ret
411 return a - b;
412 }
413
mul_long_double_rr(long double a,long double b)414 long double _Complex mul_long_double_rr(long double a, long double b) {
415 // X86-LABEL: @mul_long_double_rr(
416 // X86: fmul
417 // X86-NOT: fmul
418 // X86: ret
419 return a * b;
420 }
mul_long_double_cr(long double _Complex a,long double b)421 long double _Complex mul_long_double_cr(long double _Complex a, long double b) {
422 // X86-LABEL: @mul_long_double_cr(
423 // X86: fmul
424 // X86: fmul
425 // X86-NOT: fmul
426 // X86: ret
427 return a * b;
428 }
mul_long_double_rc(long double a,long double _Complex b)429 long double _Complex mul_long_double_rc(long double a, long double _Complex b) {
430 // X86-LABEL: @mul_long_double_rc(
431 // X86: fmul
432 // X86: fmul
433 // X86-NOT: fmul
434 // X86: ret
435 return a * b;
436 }
mul_long_double_cc(long double _Complex a,long double _Complex b)437 long double _Complex mul_long_double_cc(long double _Complex a, long double _Complex b) {
438 // X86-LABEL: @mul_long_double_cc(
439 // X86: %[[AC:[^ ]+]] = fmul
440 // X86: %[[BD:[^ ]+]] = fmul
441 // X86: %[[AD:[^ ]+]] = fmul
442 // X86: %[[BC:[^ ]+]] = fmul
443 // X86: %[[RR:[^ ]+]] = fsub x86_fp80 %[[AC]], %[[BD]]
444 // X86: %[[RI:[^ ]+]] = fadd x86_fp80
445 // X86-DAG: %[[AD]]
446 // X86-DAG: ,
447 // X86-DAG: %[[BC]]
448 // X86: fcmp uno x86_fp80 %[[RR]]
449 // X86: fcmp uno x86_fp80 %[[RI]]
450 // X86: call {{.*}} @__mulxc3(
451 // X86: ret
452 // PPC-LABEL: @mul_long_double_cc(
453 // PPC: %[[AC:[^ ]+]] = fmul
454 // PPC: %[[BD:[^ ]+]] = fmul
455 // PPC: %[[AD:[^ ]+]] = fmul
456 // PPC: %[[BC:[^ ]+]] = fmul
457 // PPC: %[[RR:[^ ]+]] = fsub ppc_fp128 %[[AC]], %[[BD]]
458 // PPC: %[[RI:[^ ]+]] = fadd ppc_fp128
459 // PPC-DAG: %[[AD]]
460 // PPC-DAG: ,
461 // PPC-DAG: %[[BC]]
462 // PPC: fcmp uno ppc_fp128 %[[RR]]
463 // PPC: fcmp uno ppc_fp128 %[[RI]]
464 // PPC: call {{.*}} @__multc3(
465 // PPC: ret
466 return a * b;
467 }
468
div_long_double_rr(long double a,long double b)469 long double _Complex div_long_double_rr(long double a, long double b) {
470 // X86-LABEL: @div_long_double_rr(
471 // X86: fdiv
472 // X86-NOT: fdiv
473 // X86: ret
474 return a / b;
475 }
div_long_double_cr(long double _Complex a,long double b)476 long double _Complex div_long_double_cr(long double _Complex a, long double b) {
477 // X86-LABEL: @div_long_double_cr(
478 // X86: fdiv
479 // X86: fdiv
480 // X86-NOT: fdiv
481 // X86: ret
482 return a / b;
483 }
div_long_double_rc(long double a,long double _Complex b)484 long double _Complex div_long_double_rc(long double a, long double _Complex b) {
485 // X86-LABEL: @div_long_double_rc(
486 // X86-NOT: fdiv
487 // X86: call {{.*}} @__divxc3(
488 // X86: ret
489 // PPC-LABEL: @div_long_double_rc(
490 // PPC-NOT: fdiv
491 // PPC: call {{.*}} @__divtc3(
492 // PPC: ret
493
494 // a / b = (A+iB) / (C+iD) = ((AC+BD)/(CC+DD)) + i((BC-AD)/(CC+DD))
495 // AARCH64-FASTMATH-LABEL: @div_long_double_rc(fp128 %a, [2 x fp128] %b.coerce)
496 // A = a
497 // B = 0
498 //
499 // AARCH64-FASTMATH: [[AC:%.*]] = fmul fast fp128
500 // BD = 0
501 // ACpBD = AC
502 //
503 // AARCH64-FASTMATH: [[CC:%.*]] = fmul fast fp128
504 // AARCH64-FASTMATH: [[DD:%.*]] = fmul fast fp128
505 // AARCH64-FASTMATH: [[CCpDD:%.*]] = fadd fast fp128
506 //
507 // BC = 0
508 // AARCH64-FASTMATH: [[AD:%.*]] = fmul fast fp128
509 //
510 // AARCH64-FASTMATH: fdiv fast fp128
511 // AARCH64-FASTMATH: fdiv fast fp128
512 // AARCH64-FASTMATH: ret
513 return a / b;
514 }
div_long_double_cc(long double _Complex a,long double _Complex b)515 long double _Complex div_long_double_cc(long double _Complex a, long double _Complex b) {
516 // X86-LABEL: @div_long_double_cc(
517 // X86-NOT: fdiv
518 // X86: call {{.*}} @__divxc3(
519 // X86: ret
520 // PPC-LABEL: @div_long_double_cc(
521 // PPC-NOT: fdiv
522 // PPC: call {{.*}} @__divtc3(
523 // PPC: ret
524
525 // a / b = (A+iB) / (C+iD) = ((AC+BD)/(CC+DD)) + i((BC-AD)/(CC+DD))
526 // AARCH64-FASTMATH-LABEL: @div_long_double_cc([2 x fp128] %a.coerce, [2 x fp128] %b.coerce)
527 //
528 // AARCH64-FASTMATH: [[AC:%.*]] = fmul fast fp128
529 // AARCH64-FASTMATH: [[BD:%.*]] = fmul fast fp128
530 // AARCH64-FASTMATH: [[ACpBD:%.*]] = fadd fast fp128
531 //
532 // AARCH64-FASTMATH: [[CC:%.*]] = fmul fast fp128
533 // AARCH64-FASTMATH: [[DD:%.*]] = fmul fast fp128
534 // AARCH64-FASTMATH: [[CCpDD:%.*]] = fadd fast fp128
535 //
536 // AARCH64-FASTMATH: [[BC:%.*]] = fmul fast fp128
537 // AARCH64-FASTMATH: [[AD:%.*]] = fmul fast fp128
538 // AARCH64-FASTMATH: [[BCmAD:%.*]] = fsub fast fp128
539 //
540 // AARCH64-FASTMATH: fdiv fast fp128
541 // AARCH64-FASTMATH: fdiv fast fp128
542 // AARCH64-FASTMATH: ret
543 return a / b;
544 }
545
546 // Comparison operators don't rely on library calls or have interseting math
547 // properties, but test that mixed types work correctly here.
eq_float_cr(float _Complex a,float b)548 _Bool eq_float_cr(float _Complex a, float b) {
549 // X86-LABEL: @eq_float_cr(
550 // X86: fcmp oeq
551 // X86: fcmp oeq
552 // X86: and i1
553 // X86: ret
554 return a == b;
555 }
eq_float_rc(float a,float _Complex b)556 _Bool eq_float_rc(float a, float _Complex b) {
557 // X86-LABEL: @eq_float_rc(
558 // X86: fcmp oeq
559 // X86: fcmp oeq
560 // X86: and i1
561 // X86: ret
562 return a == b;
563 }
eq_float_cc(float _Complex a,float _Complex b)564 _Bool eq_float_cc(float _Complex a, float _Complex b) {
565 // X86-LABEL: @eq_float_cc(
566 // X86: fcmp oeq
567 // X86: fcmp oeq
568 // X86: and i1
569 // X86: ret
570 return a == b;
571 }
ne_float_cr(float _Complex a,float b)572 _Bool ne_float_cr(float _Complex a, float b) {
573 // X86-LABEL: @ne_float_cr(
574 // X86: fcmp une
575 // X86: fcmp une
576 // X86: or i1
577 // X86: ret
578 return a != b;
579 }
ne_float_rc(float a,float _Complex b)580 _Bool ne_float_rc(float a, float _Complex b) {
581 // X86-LABEL: @ne_float_rc(
582 // X86: fcmp une
583 // X86: fcmp une
584 // X86: or i1
585 // X86: ret
586 return a != b;
587 }
ne_float_cc(float _Complex a,float _Complex b)588 _Bool ne_float_cc(float _Complex a, float _Complex b) {
589 // X86-LABEL: @ne_float_cc(
590 // X86: fcmp une
591 // X86: fcmp une
592 // X86: or i1
593 // X86: ret
594 return a != b;
595 }
596
597 // Check that the libcall will obtain proper calling convention on ARM
foo(_Complex double a,_Complex double b)598 _Complex double foo(_Complex double a, _Complex double b) {
599 // These functions are not defined as floating point helper functions in
600 // Run-time ABI for the ARM architecture document so they must not always
601 // use the base AAPCS.
602
603 // ARM-LABEL: @foo(
604 // ARM: call void @__muldc3
605
606 // ARMHF-LABEL: @foo(
607 // ARMHF: call { double, double } @__muldc3
608
609 // ARM7K-LABEL: @foo(
610 // ARM7K: call { double, double } @__muldc3
611 return a*b;
612 }
613