1 ; RUN: llc -mtriple=mips64el-unknown-unknown -mcpu=mips4 -mattr=+soft-float -O1 \
2 ; RUN: -disable-mips-delay-filler -relocation-model=pic < %s | FileCheck \
3 ; RUN: %s -check-prefixes=ALL,C_CC_FMT,PRER6,NOT-R2R6
4 ; RUN: llc -mtriple=mips64el-unknown-unknown -mcpu=mips64 -mattr=+soft-float -O1 \
5 ; RUN: -disable-mips-delay-filler -relocation-model=pic < %s | FileCheck \
6 ; RUN: %s -check-prefixes=ALL,C_CC_FMT,PRER6,NOT-R2R6
7 ; RUN: llc -mtriple=mips64el-unknown-unknown -mcpu=mips64r2 -mattr=+soft-float \
8 ; RUN: -O1 -disable-mips-delay-filler -relocation-model=pic < %s | FileCheck \
9 ; RUN: %s -check-prefixes=ALL,C_CC_FMT,PRER6,R2R6
10 ; RUN: llc -mtriple=mips64el-unknown-unknown -mcpu=mips64r6 -mattr=+soft-float \
11 ; RUN: -O1 -disable-mips-delay-filler -relocation-model=pic < %s | FileCheck \
12 ; RUN: %s -check-prefixes=ALL,CMP_CC_FMT,R6,R2R6
14 @gld0 = external global fp128
15 @gld1 = external global fp128
16 @gld2 = external global fp128
17 @gf1 = external global float
18 @gd1 = external global double
21 ; ALL: ld $25, %call16(__addtf3)
23 define fp128 @addLD() {
25 %0 = load fp128, fp128* @gld0, align 16
26 %1 = load fp128, fp128* @gld1, align 16
27 %add = fadd fp128 %0, %1
32 ; ALL: ld $25, %call16(__subtf3)
34 define fp128 @subLD() {
36 %0 = load fp128, fp128* @gld0, align 16
37 %1 = load fp128, fp128* @gld1, align 16
38 %sub = fsub fp128 %0, %1
43 ; ALL: ld $25, %call16(__multf3)
45 define fp128 @mulLD() {
47 %0 = load fp128, fp128* @gld0, align 16
48 %1 = load fp128, fp128* @gld1, align 16
49 %mul = fmul fp128 %0, %1
54 ; ALL: ld $25, %call16(__divtf3)
56 define fp128 @divLD() {
58 %0 = load fp128, fp128* @gld0, align 16
59 %1 = load fp128, fp128* @gld1, align 16
60 %div = fdiv fp128 %0, %1
64 ; ALL-LABEL: conv_LD_char:
65 ; ALL: ld $25, %call16(__floatsitf)
67 define fp128 @conv_LD_char(i8 signext %a) {
69 %conv = sitofp i8 %a to fp128
73 ; ALL-LABEL: conv_LD_short:
74 ; ALL: ld $25, %call16(__floatsitf)
76 define fp128 @conv_LD_short(i16 signext %a) {
78 %conv = sitofp i16 %a to fp128
82 ; ALL-LABEL: conv_LD_int:
83 ; ALL: ld $25, %call16(__floatsitf)
85 define fp128 @conv_LD_int(i32 %a) {
87 %conv = sitofp i32 %a to fp128
91 ; ALL-LABEL: conv_LD_LL:
92 ; ALL: ld $25, %call16(__floatditf)
94 define fp128 @conv_LD_LL(i64 %a) {
96 %conv = sitofp i64 %a to fp128
100 ; ALL-LABEL: conv_LD_UChar:
101 ; ALL: ld $25, %call16(__floatunsitf)
103 define fp128 @conv_LD_UChar(i8 zeroext %a) {
105 %conv = uitofp i8 %a to fp128
109 ; ALL-LABEL: conv_LD_UShort:
110 ; ALL: ld $25, %call16(__floatunsitf)
112 define fp128 @conv_LD_UShort(i16 zeroext %a) {
114 %conv = uitofp i16 %a to fp128
118 ; ALL-LABEL: conv_LD_UInt:
119 ; ALL: ld $25, %call16(__floatunsitf)
121 define fp128 @conv_LD_UInt(i32 signext %a) {
123 %conv = uitofp i32 %a to fp128
127 ; ALL-LABEL: conv_LD_ULL:
128 ; ALL: ld $25, %call16(__floatunditf)
130 define fp128 @conv_LD_ULL(i64 %a) {
132 %conv = uitofp i64 %a to fp128
136 ; ALL-LABEL: conv_char_LD:
137 ; ALL: ld $25, %call16(__fixtfsi)
139 define signext i8 @conv_char_LD(fp128 %a) {
141 %conv = fptosi fp128 %a to i8
145 ; ALL-LABEL: conv_short_LD:
146 ; ALL: ld $25, %call16(__fixtfsi)
148 define signext i16 @conv_short_LD(fp128 %a) {
150 %conv = fptosi fp128 %a to i16
154 ; ALL-LABEL: conv_int_LD:
155 ; ALL: ld $25, %call16(__fixtfsi)
157 define i32 @conv_int_LD(fp128 %a) {
159 %conv = fptosi fp128 %a to i32
163 ; ALL-LABEL: conv_LL_LD:
164 ; ALL: ld $25, %call16(__fixtfdi)
166 define i64 @conv_LL_LD(fp128 %a) {
168 %conv = fptosi fp128 %a to i64
172 ; ALL-LABEL: conv_UChar_LD:
173 ; ALL: ld $25, %call16(__fixtfsi)
175 define zeroext i8 @conv_UChar_LD(fp128 %a) {
177 %conv = fptoui fp128 %a to i8
181 ; ALL-LABEL: conv_UShort_LD:
182 ; ALL: ld $25, %call16(__fixtfsi)
184 define zeroext i16 @conv_UShort_LD(fp128 %a) {
186 %conv = fptoui fp128 %a to i16
190 ; ALL-LABEL: conv_UInt_LD:
191 ; ALL: ld $25, %call16(__fixunstfsi)
193 define i32 @conv_UInt_LD(fp128 %a) {
195 %conv = fptoui fp128 %a to i32
199 ; ALL-LABEL: conv_ULL_LD:
200 ; ALL: ld $25, %call16(__fixunstfdi)
202 define i64 @conv_ULL_LD(fp128 %a) {
204 %conv = fptoui fp128 %a to i64
208 ; ALL-LABEL: conv_LD_float:
209 ; ALL: ld $25, %call16(__extendsftf2)
211 define fp128 @conv_LD_float(float %a) {
213 %conv = fpext float %a to fp128
217 ; ALL-LABEL: conv_LD_double:
218 ; ALL: ld $25, %call16(__extenddftf2)
220 define fp128 @conv_LD_double(double %a) {
222 %conv = fpext double %a to fp128
226 ; ALL-LABEL: conv_float_LD:
227 ; ALL: ld $25, %call16(__trunctfsf2)
229 define float @conv_float_LD(fp128 %a) {
231 %conv = fptrunc fp128 %a to float
235 ; ALL-LABEL: conv_double_LD:
236 ; ALL: ld $25, %call16(__trunctfdf2)
238 define double @conv_double_LD(fp128 %a) {
240 %conv = fptrunc fp128 %a to double
244 ; ALL-LABEL: libcall1_fabsl:
245 ; NOT-R2R6-DAG: ld $[[R0:[0-9]+]], 8($[[R4:[0-9]+]])
246 ; NOT-R2R6-DAG: daddiu $[[R1:[0-9]+]], $zero, 1
247 ; NOT-R2R6-DAG: dsll $[[R2:[0-9]+]], $[[R1]], 63
248 ; NOT-R2R6-DAG: daddiu $[[R3:[0-9]+]], $[[R2]], -1
249 ; NOT-R2R6-DAG: and $4, $[[R0]], $[[R3]]
250 ; NOT-R2R6-DAG: ld $2, 0($[[R4]])
252 ; R2R6-DAG: ld $[[R0:[0-9]+]], 0($[[R3:[0-9]+]])
253 ; R2R6-DAG: ld $[[R1:[0-9]+]], 8($[[R3]])
254 ; R2R6-DAG: dextm $[[R2:[0-9]+]], $[[R1]], 0, 63
256 define fp128 @libcall1_fabsl() {
258 %0 = load fp128, fp128* @gld0, align 16
259 %call = tail call fp128 @fabsl(fp128 %0) nounwind readnone
263 declare fp128 @fabsl(fp128) #1
265 ; ALL-LABEL: libcall1_ceill:
266 ; ALL: ld $25, %call16(ceill)
268 define fp128 @libcall1_ceill() {
270 %0 = load fp128, fp128* @gld0, align 16
271 %call = tail call fp128 @ceill(fp128 %0) nounwind readnone
275 declare fp128 @ceill(fp128) #1
277 ; ALL-LABEL: libcall1_sinl:
278 ; ALL: ld $25, %call16(sinl)
280 define fp128 @libcall1_sinl() {
282 %0 = load fp128, fp128* @gld0, align 16
283 %call = tail call fp128 @sinl(fp128 %0) nounwind
287 declare fp128 @sinl(fp128) #2
289 ; ALL-LABEL: libcall1_cosl:
290 ; ALL: ld $25, %call16(cosl)
292 define fp128 @libcall1_cosl() {
294 %0 = load fp128, fp128* @gld0, align 16
295 %call = tail call fp128 @cosl(fp128 %0) nounwind
299 declare fp128 @cosl(fp128) #2
301 ; ALL-LABEL: libcall1_expl:
302 ; ALL: ld $25, %call16(expl)
304 define fp128 @libcall1_expl() {
306 %0 = load fp128, fp128* @gld0, align 16
307 %call = tail call fp128 @expl(fp128 %0) nounwind
311 declare fp128 @expl(fp128) #2
313 ; ALL-LABEL: libcall1_exp2l:
314 ; ALL: ld $25, %call16(exp2l)
316 define fp128 @libcall1_exp2l() {
318 %0 = load fp128, fp128* @gld0, align 16
319 %call = tail call fp128 @exp2l(fp128 %0) nounwind
323 declare fp128 @exp2l(fp128) #2
325 ; ALL-LABEL: libcall1_logl:
326 ; ALL: ld $25, %call16(logl)
328 define fp128 @libcall1_logl() {
330 %0 = load fp128, fp128* @gld0, align 16
331 %call = tail call fp128 @logl(fp128 %0) nounwind
335 declare fp128 @logl(fp128) #2
337 ; ALL-LABEL: libcall1_log2l:
338 ; ALL: ld $25, %call16(log2l)
340 define fp128 @libcall1_log2l() {
342 %0 = load fp128, fp128* @gld0, align 16
343 %call = tail call fp128 @log2l(fp128 %0) nounwind
347 declare fp128 @log2l(fp128) #2
349 ; ALL-LABEL: libcall1_log10l:
350 ; ALL: ld $25, %call16(log10l)
352 define fp128 @libcall1_log10l() {
354 %0 = load fp128, fp128* @gld0, align 16
355 %call = tail call fp128 @log10l(fp128 %0) nounwind
359 declare fp128 @log10l(fp128) #2
361 ; ALL-LABEL: libcall1_nearbyintl:
362 ; ALL: ld $25, %call16(nearbyintl)
364 define fp128 @libcall1_nearbyintl() {
366 %0 = load fp128, fp128* @gld0, align 16
367 %call = tail call fp128 @nearbyintl(fp128 %0) nounwind readnone
371 declare fp128 @nearbyintl(fp128) #1
373 ; ALL-LABEL: libcall1_floorl:
374 ; ALL: ld $25, %call16(floorl)
376 define fp128 @libcall1_floorl() {
378 %0 = load fp128, fp128* @gld0, align 16
379 %call = tail call fp128 @floorl(fp128 %0) nounwind readnone
383 declare fp128 @floorl(fp128) #1
385 ; ALL-LABEL: libcall1_sqrtl:
386 ; ALL: ld $25, %call16(sqrtl)
388 define fp128 @libcall1_sqrtl() {
390 %0 = load fp128, fp128* @gld0, align 16
391 %call = tail call fp128 @sqrtl(fp128 %0) nounwind
395 declare fp128 @sqrtl(fp128) #2
397 ; ALL-LABEL: libcall1_rintl:
398 ; ALL: ld $25, %call16(rintl)
400 define fp128 @libcall1_rintl() {
402 %0 = load fp128, fp128* @gld0, align 16
403 %call = tail call fp128 @rintl(fp128 %0) nounwind readnone
407 declare fp128 @rintl(fp128) #1
409 ; ALL-LABEL: libcall_powil:
410 ; ALL: ld $25, %call16(__powitf2)
412 define fp128 @libcall_powil(fp128 %a, i32 %b) {
414 %0 = tail call fp128 @llvm.powi.f128(fp128 %a, i32 %b)
418 declare fp128 @llvm.powi.f128(fp128, i32) #3
420 ; ALL-LABEL: libcall2_copysignl:
421 ; NOT-R2R6-DAG: daddiu $[[R2:[0-9]+]], $zero, 1
422 ; NOT-R2R6-DAG: dsll $[[R3:[0-9]+]], $[[R2]], 63
423 ; ALL-DAG: ld $[[R0:[0-9]+]], %got_disp(gld1)
424 ; ALL-DAG: ld $[[R1:[0-9]+]], 8($[[R0]])
425 ; NOT-R2R6-DAG: and $[[R4:[0-9]+]], $[[R1]], $[[R3]]
426 ; ALL-DAG: ld $[[R5:[0-9]+]], %got_disp(gld0)
427 ; ALL-DAG: ld $[[R6:[0-9]+]], 8($[[R5]])
428 ; R2R6: dinsu $[[R0:[0-9]+]], $[[R1:[0-9]+]], 63, 1
429 ; NOT-R2R6-DAG: daddiu $[[R7:[0-9]+]], $[[R3]], -1
430 ; NOT-R2R6-DAG: and $[[R8:[0-9]+]], $[[R6]], $[[R7]]
431 ; NOT-R2R6-DAG: or $4, $[[R8]], $[[R4]]
432 ; ALL-DAG: ld $2, 0($[[R5]])
434 define fp128 @libcall2_copysignl() {
436 %0 = load fp128, fp128* @gld0, align 16
437 %1 = load fp128, fp128* @gld1, align 16
438 %call = tail call fp128 @copysignl(fp128 %0, fp128 %1) nounwind readnone
442 declare fp128 @copysignl(fp128, fp128) #1
444 ; ALL-LABEL: libcall2_powl:
445 ; ALL: ld $25, %call16(powl)
447 define fp128 @libcall2_powl() {
449 %0 = load fp128, fp128* @gld0, align 16
450 %1 = load fp128, fp128* @gld1, align 16
451 %call = tail call fp128 @powl(fp128 %0, fp128 %1) nounwind
455 declare fp128 @powl(fp128, fp128) #2
457 ; ALL-LABEL: libcall2_fmodl:
458 ; ALL: ld $25, %call16(fmodl)
460 define fp128 @libcall2_fmodl() {
462 %0 = load fp128, fp128* @gld0, align 16
463 %1 = load fp128, fp128* @gld1, align 16
464 %call = tail call fp128 @fmodl(fp128 %0, fp128 %1) nounwind
468 declare fp128 @fmodl(fp128, fp128) #2
470 ; ALL-LABEL: libcall3_fmal:
471 ; ALL: ld $25, %call16(fmal)
473 define fp128 @libcall3_fmal() {
475 %0 = load fp128, fp128* @gld0, align 16
476 %1 = load fp128, fp128* @gld2, align 16
477 %2 = load fp128, fp128* @gld1, align 16
478 %3 = tail call fp128 @llvm.fma.f128(fp128 %0, fp128 %2, fp128 %1)
482 declare fp128 @llvm.fma.f128(fp128, fp128, fp128) #4
485 ; ALL: ld $25, %call16(__lttf2)
487 define i32 @cmp_lt(fp128 %a, fp128 %b) {
489 %cmp = fcmp olt fp128 %a, %b
490 %conv = zext i1 %cmp to i32
495 ; ALL: ld $25, %call16(__letf2)
497 define i32 @cmp_le(fp128 %a, fp128 %b) {
499 %cmp = fcmp ole fp128 %a, %b
500 %conv = zext i1 %cmp to i32
505 ; ALL: ld $25, %call16(__gttf2)
507 define i32 @cmp_gt(fp128 %a, fp128 %b) {
509 %cmp = fcmp ogt fp128 %a, %b
510 %conv = zext i1 %cmp to i32
515 ; ALL: ld $25, %call16(__getf2)
517 define i32 @cmp_ge(fp128 %a, fp128 %b) {
519 %cmp = fcmp oge fp128 %a, %b
520 %conv = zext i1 %cmp to i32
525 ; ALL: ld $25, %call16(__eqtf2)
527 define i32 @cmp_eq(fp128 %a, fp128 %b) {
529 %cmp = fcmp oeq fp128 %a, %b
530 %conv = zext i1 %cmp to i32
535 ; ALL: ld $25, %call16(__netf2)
537 define i32 @cmp_ne(fp128 %a, fp128 %b) {
539 %cmp = fcmp une fp128 %a, %b
540 %conv = zext i1 %cmp to i32
544 ; ALL-LABEL: load_LD_LD:
545 ; ALL: ld $[[R0:[0-9]+]], %got_disp(gld1)
546 ; ALL: ld $2, 0($[[R0]])
547 ; ALL: ld $4, 8($[[R0]])
549 define fp128 @load_LD_LD() {
551 %0 = load fp128, fp128* @gld1, align 16
555 ; ALL-LABEL: load_LD_float:
556 ; ALL: ld $[[R0:[0-9]+]], %got_disp(gf1)
557 ; ALL: lw $4, 0($[[R0]])
558 ; ALL: ld $25, %call16(__extendsftf2)
562 define fp128 @load_LD_float() {
564 %0 = load float, float* @gf1, align 4
565 %conv = fpext float %0 to fp128
569 ; ALL-LABEL: load_LD_double:
570 ; ALL: ld $[[R0:[0-9]+]], %got_disp(gd1)
571 ; ALL: ld $4, 0($[[R0]])
572 ; ALL: ld $25, %call16(__extenddftf2)
576 define fp128 @load_LD_double() {
578 %0 = load double, double* @gd1, align 8
579 %conv = fpext double %0 to fp128
583 ; ALL-LABEL: store_LD_LD:
584 ; ALL: ld $[[R0:[0-9]+]], %got_disp(gld1)
585 ; ALL: ld $[[R2:[0-9]+]], 8($[[R0]])
586 ; ALL: ld $[[R3:[0-9]+]], %got_disp(gld0)
587 ; ALL: sd $[[R2]], 8($[[R3]])
588 ; ALL: ld $[[R1:[0-9]+]], 0($[[R0]])
589 ; ALL: sd $[[R1]], 0($[[R3]])
591 define void @store_LD_LD() {
593 %0 = load fp128, fp128* @gld1, align 16
594 store fp128 %0, fp128* @gld0, align 16
598 ; ALL-LABEL: store_LD_float:
599 ; ALL: ld $[[R0:[0-9]+]], %got_disp(gld1)
600 ; ALL: ld $4, 0($[[R0]])
601 ; ALL: ld $5, 8($[[R0]])
602 ; ALL: ld $25, %call16(__trunctfsf2)
605 ; ALL: ld $[[R1:[0-9]+]], %got_disp(gf1)
606 ; ALL: sw $2, 0($[[R1]])
608 define void @store_LD_float() {
610 %0 = load fp128, fp128* @gld1, align 16
611 %conv = fptrunc fp128 %0 to float
612 store float %conv, float* @gf1, align 4
616 ; ALL-LABEL: store_LD_double:
617 ; ALL: ld $[[R0:[0-9]+]], %got_disp(gld1)
618 ; ALL: ld $4, 0($[[R0]])
619 ; ALL: ld $5, 8($[[R0]])
620 ; ALL: ld $25, %call16(__trunctfdf2)
623 ; ALL: ld $[[R1:[0-9]+]], %got_disp(gd1)
624 ; ALL: sd $2, 0($[[R1]])
626 define void @store_LD_double() {
628 %0 = load fp128, fp128* @gld1, align 16
629 %conv = fptrunc fp128 %0 to double
630 store double %conv, double* @gd1, align 8
634 ; ALL-LABEL: select_LD:
635 ; C_CC_FMT: movn $8, $6, $4
636 ; C_CC_FMT: movn $9, $7, $4
637 ; C_CC_FMT: move $2, $8
638 ; C_CC_FMT: move $4, $9
640 ; FIXME: This sll works around an implementation detail in the code generator
641 ; (setcc's result is i32 so bits 32-63 are undefined). It's not really
643 ; CMP_CC_FMT-DAG: sll $[[CC:[0-9]+]], $4, 0
644 ; CMP_CC_FMT-DAG: seleqz $[[EQ1:[0-9]+]], $8, $[[CC]]
645 ; CMP_CC_FMT-DAG: selnez $[[NE1:[0-9]+]], $6, $[[CC]]
646 ; CMP_CC_FMT-DAG: or $2, $[[NE1]], $[[EQ1]]
647 ; CMP_CC_FMT-DAG: seleqz $[[EQ2:[0-9]+]], $9, $[[CC]]
648 ; CMP_CC_FMT-DAG: selnez $[[NE2:[0-9]+]], $7, $[[CC]]
649 ; CMP_CC_FMT-DAG: or $4, $[[NE2]], $[[EQ2]]
651 define fp128 @select_LD(i32 signext %a, i64, fp128 %b, fp128 %c) {
653 %tobool = icmp ne i32 %a, 0
654 %cond = select i1 %tobool, fp128 %b, fp128 %c
658 ; ALL-LABEL: selectCC_LD:
659 ; ALL: move $[[R0:[0-9]+]], $11
660 ; ALL: move $[[R1:[0-9]+]], $10
661 ; ALL: move $[[R2:[0-9]+]], $9
662 ; ALL: move $[[R3:[0-9]+]], $8
663 ; ALL: ld $25, %call16(__gttf2)($gp)
667 ; C_CC_FMT: slti $[[CC:[0-9]+]], $2, 1
668 ; C_CC_FMT: movz $[[R1]], $[[R3]], $[[CC]]
669 ; C_CC_FMT: movz $[[R0]], $[[R2]], $[[CC]]
670 ; C_CC_FMT: move $2, $[[R1]]
671 ; C_CC_FMT: move $4, $[[R0]]
673 ; CMP_CC_FMT: slt $[[CC:[0-9]+]], $zero, $2
674 ; CMP_CC_FMT: seleqz $[[EQ1:[0-9]+]], $[[R1]], $[[CC]]
675 ; CMP_CC_FMT: selnez $[[NE1:[0-9]+]], $[[R3]], $[[CC]]
676 ; CMP_CC_FMT: or $2, $[[NE1]], $[[EQ1]]
677 ; CMP_CC_FMT: seleqz $[[EQ2:[0-9]+]], $[[R0]], $[[CC]]
678 ; CMP_CC_FMT: selnez $[[NE2:[0-9]+]], $[[R2]], $[[CC]]
679 ; CMP_CC_FMT: or $4, $[[NE2]], $[[EQ2]]
681 define fp128 @selectCC_LD(fp128 %a, fp128 %b, fp128 %c, fp128 %d) {
683 %cmp = fcmp ogt fp128 %a, %b
684 %cond = select i1 %cmp, fp128 %c, fp128 %d