1 ; RUN: llc -mtriple=mips64el-unknown-unknown -mcpu=mips4 -soft-float -O1 \
2 ; RUN: -disable-mips-delay-filler < %s | FileCheck %s -check-prefix=ALL -check-prefix=C_CC_FMT
3 ; RUN: llc -mtriple=mips64el-unknown-unknown -mcpu=mips64 -soft-float -O1 \
4 ; RUN: -disable-mips-delay-filler < %s | FileCheck %s -check-prefix=ALL -check-prefix=C_CC_FMT
5 ; RUN: llc -mtriple=mips64el-unknown-unknown -mcpu=mips64r2 -soft-float -O1 \
6 ; RUN: -disable-mips-delay-filler < %s | FileCheck %s -check-prefix=ALL -check-prefix=C_CC_FMT
7 ; RUN: llc -mtriple=mips64el-unknown-unknown -mcpu=mips64r6 -soft-float -O1 \
8 ; RUN: -disable-mips-delay-filler < %s | FileCheck %s -check-prefix=ALL -check-prefix=CMP_CC_FMT
10 @gld0 = external global fp128
11 @gld1 = external global fp128
12 @gld2 = external global fp128
13 @gf1 = external global float
14 @gd1 = external global double
17 ; ALL: ld $25, %call16(__addtf3)
19 define fp128 @addLD() {
21 %0 = load fp128* @gld0, align 16
22 %1 = load fp128* @gld1, align 16
23 %add = fadd fp128 %0, %1
28 ; ALL: ld $25, %call16(__subtf3)
30 define fp128 @subLD() {
32 %0 = load fp128* @gld0, align 16
33 %1 = load fp128* @gld1, align 16
34 %sub = fsub fp128 %0, %1
39 ; ALL: ld $25, %call16(__multf3)
41 define fp128 @mulLD() {
43 %0 = load fp128* @gld0, align 16
44 %1 = load fp128* @gld1, align 16
45 %mul = fmul fp128 %0, %1
50 ; ALL: ld $25, %call16(__divtf3)
52 define fp128 @divLD() {
54 %0 = load fp128* @gld0, align 16
55 %1 = load fp128* @gld1, align 16
56 %div = fdiv fp128 %0, %1
60 ; ALL-LABEL: conv_LD_char:
61 ; ALL: ld $25, %call16(__floatsitf)
63 define fp128 @conv_LD_char(i8 signext %a) {
65 %conv = sitofp i8 %a to fp128
69 ; ALL-LABEL: conv_LD_short:
70 ; ALL: ld $25, %call16(__floatsitf)
72 define fp128 @conv_LD_short(i16 signext %a) {
74 %conv = sitofp i16 %a to fp128
78 ; ALL-LABEL: conv_LD_int:
79 ; ALL: ld $25, %call16(__floatsitf)
81 define fp128 @conv_LD_int(i32 %a) {
83 %conv = sitofp i32 %a to fp128
87 ; ALL-LABEL: conv_LD_LL:
88 ; ALL: ld $25, %call16(__floatditf)
90 define fp128 @conv_LD_LL(i64 %a) {
92 %conv = sitofp i64 %a to fp128
96 ; ALL-LABEL: conv_LD_UChar:
97 ; ALL: ld $25, %call16(__floatunsitf)
99 define fp128 @conv_LD_UChar(i8 zeroext %a) {
101 %conv = uitofp i8 %a to fp128
105 ; ALL-LABEL: conv_LD_UShort:
106 ; ALL: ld $25, %call16(__floatunsitf)
108 define fp128 @conv_LD_UShort(i16 zeroext %a) {
110 %conv = uitofp i16 %a to fp128
114 ; ALL-LABEL: conv_LD_UInt:
115 ; ALL: ld $25, %call16(__floatunsitf)
117 define fp128 @conv_LD_UInt(i32 %a) {
119 %conv = uitofp i32 %a to fp128
123 ; ALL-LABEL: conv_LD_ULL:
124 ; ALL: ld $25, %call16(__floatunditf)
126 define fp128 @conv_LD_ULL(i64 %a) {
128 %conv = uitofp i64 %a to fp128
132 ; ALL-LABEL: conv_char_LD:
133 ; ALL: ld $25, %call16(__fixtfsi)
135 define signext i8 @conv_char_LD(fp128 %a) {
137 %conv = fptosi fp128 %a to i8
141 ; ALL-LABEL: conv_short_LD:
142 ; ALL: ld $25, %call16(__fixtfsi)
144 define signext i16 @conv_short_LD(fp128 %a) {
146 %conv = fptosi fp128 %a to i16
150 ; ALL-LABEL: conv_int_LD:
151 ; ALL: ld $25, %call16(__fixtfsi)
153 define i32 @conv_int_LD(fp128 %a) {
155 %conv = fptosi fp128 %a to i32
159 ; ALL-LABEL: conv_LL_LD:
160 ; ALL: ld $25, %call16(__fixtfdi)
162 define i64 @conv_LL_LD(fp128 %a) {
164 %conv = fptosi fp128 %a to i64
168 ; ALL-LABEL: conv_UChar_LD:
169 ; ALL: ld $25, %call16(__fixtfsi)
171 define zeroext i8 @conv_UChar_LD(fp128 %a) {
173 %conv = fptoui fp128 %a to i8
177 ; ALL-LABEL: conv_UShort_LD:
178 ; ALL: ld $25, %call16(__fixtfsi)
180 define zeroext i16 @conv_UShort_LD(fp128 %a) {
182 %conv = fptoui fp128 %a to i16
186 ; ALL-LABEL: conv_UInt_LD:
187 ; ALL: ld $25, %call16(__fixunstfsi)
189 define i32 @conv_UInt_LD(fp128 %a) {
191 %conv = fptoui fp128 %a to i32
195 ; ALL-LABEL: conv_ULL_LD:
196 ; ALL: ld $25, %call16(__fixunstfdi)
198 define i64 @conv_ULL_LD(fp128 %a) {
200 %conv = fptoui fp128 %a to i64
204 ; ALL-LABEL: conv_LD_float:
205 ; ALL: ld $25, %call16(__extendsftf2)
207 define fp128 @conv_LD_float(float %a) {
209 %conv = fpext float %a to fp128
213 ; ALL-LABEL: conv_LD_double:
214 ; ALL: ld $25, %call16(__extenddftf2)
216 define fp128 @conv_LD_double(double %a) {
218 %conv = fpext double %a to fp128
222 ; ALL-LABEL: conv_float_LD:
223 ; ALL: ld $25, %call16(__trunctfsf2)
225 define float @conv_float_LD(fp128 %a) {
227 %conv = fptrunc fp128 %a to float
231 ; ALL-LABEL: conv_double_LD:
232 ; ALL: ld $25, %call16(__trunctfdf2)
234 define double @conv_double_LD(fp128 %a) {
236 %conv = fptrunc fp128 %a to double
240 ; ALL-LABEL: libcall1_fabsl:
241 ; ALL-DAG: ld $[[R0:[0-9]+]], 8($[[R4:[0-9]+]])
242 ; ALL-DAG: daddiu $[[R1:[0-9]+]], $zero, 1
243 ; ALL-DAG: dsll $[[R2:[0-9]+]], $[[R1]], 63
244 ; ALL-DAG: daddiu $[[R3:[0-9]+]], $[[R2]], -1
245 ; ALL-DAG: and $4, $[[R0]], $[[R3]]
246 ; ALL-DAG: ld $2, 0($[[R4]])
248 define fp128 @libcall1_fabsl() {
250 %0 = load fp128* @gld0, align 16
251 %call = tail call fp128 @fabsl(fp128 %0) nounwind readnone
255 declare fp128 @fabsl(fp128) #1
257 ; ALL-LABEL: libcall1_ceill:
258 ; ALL: ld $25, %call16(ceill)
260 define fp128 @libcall1_ceill() {
262 %0 = load fp128* @gld0, align 16
263 %call = tail call fp128 @ceill(fp128 %0) nounwind readnone
267 declare fp128 @ceill(fp128) #1
269 ; ALL-LABEL: libcall1_sinl:
270 ; ALL: ld $25, %call16(sinl)
272 define fp128 @libcall1_sinl() {
274 %0 = load fp128* @gld0, align 16
275 %call = tail call fp128 @sinl(fp128 %0) nounwind
279 declare fp128 @sinl(fp128) #2
281 ; ALL-LABEL: libcall1_cosl:
282 ; ALL: ld $25, %call16(cosl)
284 define fp128 @libcall1_cosl() {
286 %0 = load fp128* @gld0, align 16
287 %call = tail call fp128 @cosl(fp128 %0) nounwind
291 declare fp128 @cosl(fp128) #2
293 ; ALL-LABEL: libcall1_expl:
294 ; ALL: ld $25, %call16(expl)
296 define fp128 @libcall1_expl() {
298 %0 = load fp128* @gld0, align 16
299 %call = tail call fp128 @expl(fp128 %0) nounwind
303 declare fp128 @expl(fp128) #2
305 ; ALL-LABEL: libcall1_exp2l:
306 ; ALL: ld $25, %call16(exp2l)
308 define fp128 @libcall1_exp2l() {
310 %0 = load fp128* @gld0, align 16
311 %call = tail call fp128 @exp2l(fp128 %0) nounwind
315 declare fp128 @exp2l(fp128) #2
317 ; ALL-LABEL: libcall1_logl:
318 ; ALL: ld $25, %call16(logl)
320 define fp128 @libcall1_logl() {
322 %0 = load fp128* @gld0, align 16
323 %call = tail call fp128 @logl(fp128 %0) nounwind
327 declare fp128 @logl(fp128) #2
329 ; ALL-LABEL: libcall1_log2l:
330 ; ALL: ld $25, %call16(log2l)
332 define fp128 @libcall1_log2l() {
334 %0 = load fp128* @gld0, align 16
335 %call = tail call fp128 @log2l(fp128 %0) nounwind
339 declare fp128 @log2l(fp128) #2
341 ; ALL-LABEL: libcall1_log10l:
342 ; ALL: ld $25, %call16(log10l)
344 define fp128 @libcall1_log10l() {
346 %0 = load fp128* @gld0, align 16
347 %call = tail call fp128 @log10l(fp128 %0) nounwind
351 declare fp128 @log10l(fp128) #2
353 ; ALL-LABEL: libcall1_nearbyintl:
354 ; ALL: ld $25, %call16(nearbyintl)
356 define fp128 @libcall1_nearbyintl() {
358 %0 = load fp128* @gld0, align 16
359 %call = tail call fp128 @nearbyintl(fp128 %0) nounwind readnone
363 declare fp128 @nearbyintl(fp128) #1
365 ; ALL-LABEL: libcall1_floorl:
366 ; ALL: ld $25, %call16(floorl)
368 define fp128 @libcall1_floorl() {
370 %0 = load fp128* @gld0, align 16
371 %call = tail call fp128 @floorl(fp128 %0) nounwind readnone
375 declare fp128 @floorl(fp128) #1
377 ; ALL-LABEL: libcall1_sqrtl:
378 ; ALL: ld $25, %call16(sqrtl)
380 define fp128 @libcall1_sqrtl() {
382 %0 = load fp128* @gld0, align 16
383 %call = tail call fp128 @sqrtl(fp128 %0) nounwind
387 declare fp128 @sqrtl(fp128) #2
389 ; ALL-LABEL: libcall1_rintl:
390 ; ALL: ld $25, %call16(rintl)
392 define fp128 @libcall1_rintl() {
394 %0 = load fp128* @gld0, align 16
395 %call = tail call fp128 @rintl(fp128 %0) nounwind readnone
399 declare fp128 @rintl(fp128) #1
401 ; ALL-LABEL: libcall_powil:
402 ; ALL: ld $25, %call16(__powitf2)
404 define fp128 @libcall_powil(fp128 %a, i32 %b) {
406 %0 = tail call fp128 @llvm.powi.f128(fp128 %a, i32 %b)
410 declare fp128 @llvm.powi.f128(fp128, i32) #3
412 ; ALL-LABEL: libcall2_copysignl:
413 ; ALL-DAG: daddiu $[[R2:[0-9]+]], $zero, 1
414 ; ALL-DAG: dsll $[[R3:[0-9]+]], $[[R2]], 63
415 ; ALL-DAG: ld $[[R0:[0-9]+]], %got_disp(gld1)
416 ; ALL-DAG: ld $[[R1:[0-9]+]], 8($[[R0]])
417 ; ALL-DAG: and $[[R4:[0-9]+]], $[[R1]], $[[R3]]
418 ; ALL-DAG: ld $[[R5:[0-9]+]], %got_disp(gld0)
419 ; ALL-DAG: ld $[[R6:[0-9]+]], 8($[[R5]])
420 ; ALL-DAG: daddiu $[[R7:[0-9]+]], $[[R3]], -1
421 ; ALL-DAG: and $[[R8:[0-9]+]], $[[R6]], $[[R7]]
422 ; ALL-DAG: or $4, $[[R8]], $[[R4]]
423 ; ALL-DAG: ld $2, 0($[[R5]])
425 define fp128 @libcall2_copysignl() {
427 %0 = load fp128* @gld0, align 16
428 %1 = load fp128* @gld1, align 16
429 %call = tail call fp128 @copysignl(fp128 %0, fp128 %1) nounwind readnone
433 declare fp128 @copysignl(fp128, fp128) #1
435 ; ALL-LABEL: libcall2_powl:
436 ; ALL: ld $25, %call16(powl)
438 define fp128 @libcall2_powl() {
440 %0 = load fp128* @gld0, align 16
441 %1 = load fp128* @gld1, align 16
442 %call = tail call fp128 @powl(fp128 %0, fp128 %1) nounwind
446 declare fp128 @powl(fp128, fp128) #2
448 ; ALL-LABEL: libcall2_fmodl:
449 ; ALL: ld $25, %call16(fmodl)
451 define fp128 @libcall2_fmodl() {
453 %0 = load fp128* @gld0, align 16
454 %1 = load fp128* @gld1, align 16
455 %call = tail call fp128 @fmodl(fp128 %0, fp128 %1) nounwind
459 declare fp128 @fmodl(fp128, fp128) #2
461 ; ALL-LABEL: libcall3_fmal:
462 ; ALL: ld $25, %call16(fmal)
464 define fp128 @libcall3_fmal() {
466 %0 = load fp128* @gld0, align 16
467 %1 = load fp128* @gld2, align 16
468 %2 = load fp128* @gld1, align 16
469 %3 = tail call fp128 @llvm.fma.f128(fp128 %0, fp128 %2, fp128 %1)
473 declare fp128 @llvm.fma.f128(fp128, fp128, fp128) #4
476 ; ALL: ld $25, %call16(__lttf2)
478 define i32 @cmp_lt(fp128 %a, fp128 %b) {
480 %cmp = fcmp olt fp128 %a, %b
481 %conv = zext i1 %cmp to i32
486 ; ALL: ld $25, %call16(__letf2)
488 define i32 @cmp_le(fp128 %a, fp128 %b) {
490 %cmp = fcmp ole fp128 %a, %b
491 %conv = zext i1 %cmp to i32
496 ; ALL: ld $25, %call16(__gttf2)
498 define i32 @cmp_gt(fp128 %a, fp128 %b) {
500 %cmp = fcmp ogt fp128 %a, %b
501 %conv = zext i1 %cmp to i32
506 ; ALL: ld $25, %call16(__getf2)
508 define i32 @cmp_ge(fp128 %a, fp128 %b) {
510 %cmp = fcmp oge fp128 %a, %b
511 %conv = zext i1 %cmp to i32
516 ; ALL: ld $25, %call16(__eqtf2)
518 define i32 @cmp_eq(fp128 %a, fp128 %b) {
520 %cmp = fcmp oeq fp128 %a, %b
521 %conv = zext i1 %cmp to i32
526 ; ALL: ld $25, %call16(__netf2)
528 define i32 @cmp_ne(fp128 %a, fp128 %b) {
530 %cmp = fcmp une fp128 %a, %b
531 %conv = zext i1 %cmp to i32
535 ; ALL-LABEL: load_LD_LD:
536 ; ALL: ld $[[R0:[0-9]+]], %got_disp(gld1)
537 ; ALL: ld $2, 0($[[R0]])
538 ; ALL: ld $4, 8($[[R0]])
540 define fp128 @load_LD_LD() {
542 %0 = load fp128* @gld1, align 16
546 ; ALL-LABEL: load_LD_float:
547 ; ALL: ld $[[R0:[0-9]+]], %got_disp(gf1)
548 ; ALL: lw $4, 0($[[R0]])
549 ; ALL: ld $25, %call16(__extendsftf2)
552 define fp128 @load_LD_float() {
554 %0 = load float* @gf1, align 4
555 %conv = fpext float %0 to fp128
559 ; ALL-LABEL: load_LD_double:
560 ; ALL: ld $[[R0:[0-9]+]], %got_disp(gd1)
561 ; ALL: ld $4, 0($[[R0]])
562 ; ALL: ld $25, %call16(__extenddftf2)
565 define fp128 @load_LD_double() {
567 %0 = load double* @gd1, align 8
568 %conv = fpext double %0 to fp128
572 ; ALL-LABEL: store_LD_LD:
573 ; ALL: ld $[[R0:[0-9]+]], %got_disp(gld1)
574 ; ALL: ld $[[R1:[0-9]+]], 0($[[R0]])
575 ; ALL: ld $[[R2:[0-9]+]], 8($[[R0]])
576 ; ALL: ld $[[R3:[0-9]+]], %got_disp(gld0)
577 ; ALL: sd $[[R2]], 8($[[R3]])
578 ; ALL: sd $[[R1]], 0($[[R3]])
580 define void @store_LD_LD() {
582 %0 = load fp128* @gld1, align 16
583 store fp128 %0, fp128* @gld0, align 16
587 ; ALL-LABEL: store_LD_float:
588 ; ALL: ld $[[R0:[0-9]+]], %got_disp(gld1)
589 ; ALL: ld $4, 0($[[R0]])
590 ; ALL: ld $5, 8($[[R0]])
591 ; ALL: ld $25, %call16(__trunctfsf2)
593 ; ALL: ld $[[R1:[0-9]+]], %got_disp(gf1)
594 ; ALL: sw $2, 0($[[R1]])
596 define void @store_LD_float() {
598 %0 = load fp128* @gld1, align 16
599 %conv = fptrunc fp128 %0 to float
600 store float %conv, float* @gf1, align 4
604 ; ALL-LABEL: store_LD_double:
605 ; ALL: ld $[[R0:[0-9]+]], %got_disp(gld1)
606 ; ALL: ld $4, 0($[[R0]])
607 ; ALL: ld $5, 8($[[R0]])
608 ; ALL: ld $25, %call16(__trunctfdf2)
610 ; ALL: ld $[[R1:[0-9]+]], %got_disp(gd1)
611 ; ALL: sd $2, 0($[[R1]])
613 define void @store_LD_double() {
615 %0 = load fp128* @gld1, align 16
616 %conv = fptrunc fp128 %0 to double
617 store double %conv, double* @gd1, align 8
621 ; ALL-LABEL: select_LD:
622 ; C_CC_FMT: movn $8, $6, $4
623 ; C_CC_FMT: movn $9, $7, $4
624 ; C_CC_FMT: move $2, $8
625 ; C_CC_FMT: move $4, $9
627 ; FIXME: This sll works around an implementation detail in the code generator
628 ; (setcc's result is i32 so bits 32-63 are undefined). It's not really
630 ; CMP_CC_FMT-DAG: sll $[[CC:[0-9]+]], $4, 0
631 ; CMP_CC_FMT-DAG: seleqz $[[EQ1:[0-9]+]], $8, $[[CC]]
632 ; CMP_CC_FMT-DAG: selnez $[[NE1:[0-9]+]], $6, $[[CC]]
633 ; CMP_CC_FMT-DAG: or $2, $[[NE1]], $[[EQ1]]
634 ; CMP_CC_FMT-DAG: seleqz $[[EQ2:[0-9]+]], $9, $[[CC]]
635 ; CMP_CC_FMT-DAG: selnez $[[NE2:[0-9]+]], $7, $[[CC]]
636 ; CMP_CC_FMT-DAG: or $4, $[[NE2]], $[[EQ2]]
638 define fp128 @select_LD(i32 %a, i64, fp128 %b, fp128 %c) {
640 %tobool = icmp ne i32 %a, 0
641 %cond = select i1 %tobool, fp128 %b, fp128 %c
645 ; ALL-LABEL: selectCC_LD:
646 ; ALL: move $[[R0:[0-9]+]], $11
647 ; ALL: move $[[R1:[0-9]+]], $10
648 ; ALL: move $[[R2:[0-9]+]], $9
649 ; ALL: move $[[R3:[0-9]+]], $8
650 ; ALL: ld $25, %call16(__gttf2)($gp)
653 ; C_CC_FMT: slti $[[CC:[0-9]+]], $2, 1
654 ; C_CC_FMT: movz $[[R1]], $[[R3]], $[[CC]]
655 ; C_CC_FMT: movz $[[R0]], $[[R2]], $[[CC]]
656 ; C_CC_FMT: move $2, $[[R1]]
657 ; C_CC_FMT: move $4, $[[R0]]
659 ; CMP_CC_FMT: slt $[[CC:[0-9]+]], $zero, $2
660 ; CMP_CC_FMT: seleqz $[[EQ1:[0-9]+]], $[[R1]], $[[CC]]
661 ; CMP_CC_FMT: selnez $[[NE1:[0-9]+]], $[[R3]], $[[CC]]
662 ; CMP_CC_FMT: or $2, $[[NE1]], $[[EQ1]]
663 ; CMP_CC_FMT: seleqz $[[EQ2:[0-9]+]], $[[R0]], $[[CC]]
664 ; CMP_CC_FMT: selnez $[[NE2:[0-9]+]], $[[R2]], $[[CC]]
665 ; CMP_CC_FMT: or $4, $[[NE2]], $[[EQ2]]
667 define fp128 @selectCC_LD(fp128 %a, fp128 %b, fp128 %c, fp128 %d) {
669 %cmp = fcmp ogt fp128 %a, %b
670 %cond = select i1 %cmp, fp128 %c, fp128 %d