From 8cd348c96a845e4afb3e924355e98b5558683d01 Mon Sep 17 00:00:00 2001 From: Davide <39653004+Tazdevil971@users.noreply.github.com> Date: Tue, 19 Nov 2024 10:23:32 +0100 Subject: [PATCH] [MIPS] Updated MIPS N calling conventions so that fp16 arguments no longer cause a crash (#116569) This PR fixes a bug introduced by #110199, which causes any half float argument to crash the compiler on MIPS64. Currently compiling this bit of code with `llc -mtriple=mips64`: ``` define void @half_args(half %a) nounwind { entry: ret void } ``` Crashes with the following log: ``` LLVM ERROR: unable to allocate function argument #0 PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace. Stack dump: 0. Program arguments: llc -mtriple=mips64 1. Running pass 'Function Pass Manager' on module ''. 2. Running pass 'MIPS DAG->DAG Pattern Instruction Selection' on function '@half_args' #0 0x000055a3a4013df8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/davide/Ps2/rps2-tools/prefix/bin/llc+0x32d0df8) #1 0x000055a3a401199e llvm::sys::RunSignalHandlers() (/home/davide/Ps2/rps2-tools/prefix/bin/llc+0x32ce99e) #2 0x000055a3a40144a8 SignalHandler(int) Signals.cpp:0:0 #3 0x00007f00bde558c0 __restore_rt libc_sigaction.c:0:0 #4 0x00007f00bdea462c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76 #5 0x00007f00bde55822 gsignal ./signal/../sysdeps/posix/raise.c:27:6 #6 0x00007f00bde3e4af abort ./stdlib/abort.c:81:7 #7 0x000055a3a3f80e3c llvm::report_fatal_error(llvm::Twine const&, bool) (/home/davide/Ps2/rps2-tools/prefix/bin/llc+0x323de3c) #8 0x000055a3a2e20dfa (/home/davide/Ps2/rps2-tools/prefix/bin/llc+0x20dddfa) #9 0x000055a3a2a34e20 llvm::MipsTargetLowering::LowerFormalArguments(llvm::SDValue, unsigned int, bool, llvm::SmallVectorImpl const&, llvm::SDLoc const&, llvm::SelectionDAG&, llvm::SmallVectorImpl&) const MipsISelLowering.cpp:0:0 #10 0x000055a3a3d896a9 llvm::SelectionDAGISel::LowerArguments(llvm::Function const&) (/home/davide/Ps2/rps2-tools/prefix/bin/llc+0x30466a9) #11 0x000055a3a3e0b3ec llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/home/davide/Ps2/rps2-tools/prefix/bin/llc+0x30c83ec) #12 0x000055a3a3e09e21 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/home/davide/Ps2/rps2-tools/prefix/bin/llc+0x30c6e21) #13 0x000055a3a2aae1ca llvm::MipsDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) MipsISelDAGToDAG.cpp:0:0 #14 0x000055a3a3e07706 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/home/davide/Ps2/rps2-tools/prefix/bin/llc+0x30c4706) #15 0x000055a3a3051ed6 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/home/davide/Ps2/rps2-tools/prefix/bin/llc+0x230eed6) #16 0x000055a3a35a3ec9 llvm::FPPassManager::runOnFunction(llvm::Function&) (/home/davide/Ps2/rps2-tools/prefix/bin/llc+0x2860ec9) #17 0x000055a3a35ac3b2 llvm::FPPassManager::runOnModule(llvm::Module&) (/home/davide/Ps2/rps2-tools/prefix/bin/llc+0x28693b2) #18 0x000055a3a35a499c llvm::legacy::PassManagerImpl::run(llvm::Module&) (/home/davide/Ps2/rps2-tools/prefix/bin/llc+0x286199c) #19 0x000055a3a262abbb main (/home/davide/Ps2/rps2-tools/prefix/bin/llc+0x18e7bbb) #20 0x00007f00bde3fc4c __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3 #21 0x00007f00bde3fd05 call_init ./csu/../csu/libc-start.c:128:20 #22 0x00007f00bde3fd05 __libc_start_main@GLIBC_2.2.5 ./csu/../csu/libc-start.c:347:5 #23 0x000055a3a2624921 _start /builddir/glibc-2.39/csu/../sysdeps/x86_64/start.S:117:0 ``` This is caused by the fact that after the change, `f16`s are no longer lowered as `f32`s in calls. Two possible fixes are available: - Update calling conventions to properly support passing `f16` as integers. - Update `useFPRegsForHalfType()` to return `true` so that `f16` are still kept in `f32` registers, as before #110199. This PR implements the first solution to not introduce any more ABI changes as #110199 already did. As of what is the correct ABI for halfs, I don't think there is a correct answer. GCC doesn't support halfs on MIPS, and I couldn't find any information on old MIPS ABI manuals either. --- llvm/lib/Target/Mips/MipsCallingConv.td | 15 +- llvm/test/CodeGen/Mips/fp16-promote.ll | 734 ++++++++++++++++-------- 2 files changed, 503 insertions(+), 246 deletions(-) diff --git a/llvm/lib/Target/Mips/MipsCallingConv.td b/llvm/lib/Target/Mips/MipsCallingConv.td index 866161bf50638d..25384a3fe8de37 100644 --- a/llvm/lib/Target/Mips/MipsCallingConv.td +++ b/llvm/lib/Target/Mips/MipsCallingConv.td @@ -20,8 +20,8 @@ class CCIfSubtargetNot : CCIfSubtarget; /// Match if the original argument (before lowering) was a float. /// For example, this is true for i32's that were lowered from soft-float. -class CCIfOrigArgWasNotFloat - : CCIf<"!static_cast(&State)->WasOriginalArgFloat(ValNo)", +class CCIfOrigArgWasFloat + : CCIf<"static_cast(&State)->WasOriginalArgFloat(ValNo)", A>; /// Match if the original argument (before lowering) was a 128-bit float (i.e. @@ -134,12 +134,13 @@ def CC_MipsN : CallingConv<[ CCIfSubtargetNot<"isLittle()", CCIfInReg>>>, - // All integers (except soft-float integers) are promoted to 64-bit. - CCIfType<[i8, i16, i32], CCIfOrigArgWasNotFloat>>, + // First deal with f32s that got turned into i32s due to soft-float + CCIfType<[i32], + CCIfSubtarget<"useSoftFloat()", + CCIfOrigArgWasFloat>>>, - // The only i32's we have left are soft-float arguments. - CCIfSubtarget<"useSoftFloat()", CCIfType<[i32], - CCDelegateTo>>, + // All remaining integers are promoted to 64-bit. + CCIfType<[i8, i16, i32], CCPromoteToType>, // Integer arguments are passed in integer registers. CCIfType<[i64], CCAssignToRegWithShadow<[A0_64, A1_64, A2_64, A3_64, diff --git a/llvm/test/CodeGen/Mips/fp16-promote.ll b/llvm/test/CodeGen/Mips/fp16-promote.ll index c104ffb3c72eb9..47bace9f5c03f6 100644 --- a/llvm/test/CodeGen/Mips/fp16-promote.ll +++ b/llvm/test/CodeGen/Mips/fp16-promote.ll @@ -1,28 +1,51 @@ ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 -; RUN: llc -mtriple=mipsel-linux-gnu < %s | FileCheck %s -check-prefix=CHECK-LIBCALL +; RUN: llc -mtriple=mipsel-linux-gnu < %s | FileCheck %s -check-prefix=MIPS32 +; RUN: llc -mtriple=mips64el-linux-gnu < %s | FileCheck %s -check-prefix=MIPS64 define void @test_fadd(ptr %p, ptr %q) nounwind { -; CHECK-LIBCALL-LABEL: test_fadd: -; CHECK-LIBCALL: # %bb.0: -; CHECK-LIBCALL-NEXT: addiu $sp, $sp, -32 -; CHECK-LIBCALL-NEXT: sdc1 $f20, 24($sp) # 8-byte Folded Spill -; CHECK-LIBCALL-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: sw $16, 16($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: move $16, $4 -; CHECK-LIBCALL-NEXT: lhu $4, 0($5) -; CHECK-LIBCALL-NEXT: jal __gnu_h2f_ieee -; CHECK-LIBCALL-NEXT: nop -; CHECK-LIBCALL-NEXT: lhu $4, 0($16) -; CHECK-LIBCALL-NEXT: jal __gnu_h2f_ieee -; CHECK-LIBCALL-NEXT: mov.s $f20, $f0 -; CHECK-LIBCALL-NEXT: jal __gnu_f2h_ieee -; CHECK-LIBCALL-NEXT: add.s $f12, $f0, $f20 -; CHECK-LIBCALL-NEXT: sh $2, 0($16) -; CHECK-LIBCALL-NEXT: lw $16, 16($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: ldc1 $f20, 24($sp) # 8-byte Folded Reload -; CHECK-LIBCALL-NEXT: jr $ra -; CHECK-LIBCALL-NEXT: addiu $sp, $sp, 32 +; MIPS32-LABEL: test_fadd: +; MIPS32: # %bb.0: +; MIPS32-NEXT: addiu $sp, $sp, -32 +; MIPS32-NEXT: sdc1 $f20, 24($sp) # 8-byte Folded Spill +; MIPS32-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill +; MIPS32-NEXT: sw $16, 16($sp) # 4-byte Folded Spill +; MIPS32-NEXT: move $16, $4 +; MIPS32-NEXT: lhu $4, 0($5) +; MIPS32-NEXT: jal __gnu_h2f_ieee +; MIPS32-NEXT: nop +; MIPS32-NEXT: lhu $4, 0($16) +; MIPS32-NEXT: jal __gnu_h2f_ieee +; MIPS32-NEXT: mov.s $f20, $f0 +; MIPS32-NEXT: jal __gnu_f2h_ieee +; MIPS32-NEXT: add.s $f12, $f0, $f20 +; MIPS32-NEXT: sh $2, 0($16) +; MIPS32-NEXT: lw $16, 16($sp) # 4-byte Folded Reload +; MIPS32-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload +; MIPS32-NEXT: ldc1 $f20, 24($sp) # 8-byte Folded Reload +; MIPS32-NEXT: jr $ra +; MIPS32-NEXT: addiu $sp, $sp, 32 +; +; MIPS64-LABEL: test_fadd: +; MIPS64: # %bb.0: +; MIPS64-NEXT: daddiu $sp, $sp, -32 +; MIPS64-NEXT: sdc1 $f24, 24($sp) # 8-byte Folded Spill +; MIPS64-NEXT: sd $ra, 16($sp) # 8-byte Folded Spill +; MIPS64-NEXT: sd $16, 8($sp) # 8-byte Folded Spill +; MIPS64-NEXT: move $16, $4 +; MIPS64-NEXT: lhu $4, 0($5) +; MIPS64-NEXT: jal __gnu_h2f_ieee +; MIPS64-NEXT: nop +; MIPS64-NEXT: lhu $4, 0($16) +; MIPS64-NEXT: jal __gnu_h2f_ieee +; MIPS64-NEXT: mov.s $f24, $f0 +; MIPS64-NEXT: jal __gnu_f2h_ieee +; MIPS64-NEXT: add.s $f12, $f0, $f24 +; MIPS64-NEXT: sh $2, 0($16) +; MIPS64-NEXT: ld $16, 8($sp) # 8-byte Folded Reload +; MIPS64-NEXT: ld $ra, 16($sp) # 8-byte Folded Reload +; MIPS64-NEXT: ldc1 $f24, 24($sp) # 8-byte Folded Reload +; MIPS64-NEXT: jr $ra +; MIPS64-NEXT: daddiu $sp, $sp, 32 %a = load half, ptr %p, align 2 %b = load half, ptr %q, align 2 %r = fadd half %a, %b @@ -31,282 +54,515 @@ define void @test_fadd(ptr %p, ptr %q) nounwind { } define float @test_fpext_float(ptr %p) nounwind { -; CHECK-LIBCALL-LABEL: test_fpext_float: -; CHECK-LIBCALL: # %bb.0: -; CHECK-LIBCALL-NEXT: addiu $sp, $sp, -24 -; CHECK-LIBCALL-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: lhu $4, 0($4) -; CHECK-LIBCALL-NEXT: jal __gnu_h2f_ieee -; CHECK-LIBCALL-NEXT: nop -; CHECK-LIBCALL-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: jr $ra -; CHECK-LIBCALL-NEXT: addiu $sp, $sp, 24 +; MIPS32-LABEL: test_fpext_float: +; MIPS32: # %bb.0: +; MIPS32-NEXT: addiu $sp, $sp, -24 +; MIPS32-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill +; MIPS32-NEXT: lhu $4, 0($4) +; MIPS32-NEXT: jal __gnu_h2f_ieee +; MIPS32-NEXT: nop +; MIPS32-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload +; MIPS32-NEXT: jr $ra +; MIPS32-NEXT: addiu $sp, $sp, 24 +; +; MIPS64-LABEL: test_fpext_float: +; MIPS64: # %bb.0: +; MIPS64-NEXT: daddiu $sp, $sp, -16 +; MIPS64-NEXT: sd $ra, 8($sp) # 8-byte Folded Spill +; MIPS64-NEXT: lhu $4, 0($4) +; MIPS64-NEXT: jal __gnu_h2f_ieee +; MIPS64-NEXT: nop +; MIPS64-NEXT: ld $ra, 8($sp) # 8-byte Folded Reload +; MIPS64-NEXT: jr $ra +; MIPS64-NEXT: daddiu $sp, $sp, 16 %a = load half, ptr %p, align 2 %r = fpext half %a to float ret float %r } define double @test_fpext_double(ptr %p) nounwind { -; CHECK-LIBCALL-LABEL: test_fpext_double: -; CHECK-LIBCALL: # %bb.0: -; CHECK-LIBCALL-NEXT: addiu $sp, $sp, -24 -; CHECK-LIBCALL-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: lhu $4, 0($4) -; CHECK-LIBCALL-NEXT: jal __gnu_h2f_ieee -; CHECK-LIBCALL-NEXT: nop -; CHECK-LIBCALL-NEXT: cvt.d.s $f0, $f0 -; CHECK-LIBCALL-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: jr $ra -; CHECK-LIBCALL-NEXT: addiu $sp, $sp, 24 +; MIPS32-LABEL: test_fpext_double: +; MIPS32: # %bb.0: +; MIPS32-NEXT: addiu $sp, $sp, -24 +; MIPS32-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill +; MIPS32-NEXT: lhu $4, 0($4) +; MIPS32-NEXT: jal __gnu_h2f_ieee +; MIPS32-NEXT: nop +; MIPS32-NEXT: cvt.d.s $f0, $f0 +; MIPS32-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload +; MIPS32-NEXT: jr $ra +; MIPS32-NEXT: addiu $sp, $sp, 24 +; +; MIPS64-LABEL: test_fpext_double: +; MIPS64: # %bb.0: +; MIPS64-NEXT: daddiu $sp, $sp, -16 +; MIPS64-NEXT: sd $ra, 8($sp) # 8-byte Folded Spill +; MIPS64-NEXT: lhu $4, 0($4) +; MIPS64-NEXT: jal __gnu_h2f_ieee +; MIPS64-NEXT: nop +; MIPS64-NEXT: cvt.d.s $f0, $f0 +; MIPS64-NEXT: ld $ra, 8($sp) # 8-byte Folded Reload +; MIPS64-NEXT: jr $ra +; MIPS64-NEXT: daddiu $sp, $sp, 16 %a = load half, ptr %p, align 2 %r = fpext half %a to double ret double %r } define void @test_fptrunc_float(float %f, ptr %p) nounwind { -; CHECK-LIBCALL-LABEL: test_fptrunc_float: -; CHECK-LIBCALL: # %bb.0: -; CHECK-LIBCALL-NEXT: addiu $sp, $sp, -24 -; CHECK-LIBCALL-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: sw $16, 16($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: jal __gnu_f2h_ieee -; CHECK-LIBCALL-NEXT: move $16, $5 -; CHECK-LIBCALL-NEXT: sh $2, 0($16) -; CHECK-LIBCALL-NEXT: lw $16, 16($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: jr $ra -; CHECK-LIBCALL-NEXT: addiu $sp, $sp, 24 +; MIPS32-LABEL: test_fptrunc_float: +; MIPS32: # %bb.0: +; MIPS32-NEXT: addiu $sp, $sp, -24 +; MIPS32-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill +; MIPS32-NEXT: sw $16, 16($sp) # 4-byte Folded Spill +; MIPS32-NEXT: jal __gnu_f2h_ieee +; MIPS32-NEXT: move $16, $5 +; MIPS32-NEXT: sh $2, 0($16) +; MIPS32-NEXT: lw $16, 16($sp) # 4-byte Folded Reload +; MIPS32-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload +; MIPS32-NEXT: jr $ra +; MIPS32-NEXT: addiu $sp, $sp, 24 +; +; MIPS64-LABEL: test_fptrunc_float: +; MIPS64: # %bb.0: +; MIPS64-NEXT: daddiu $sp, $sp, -16 +; MIPS64-NEXT: sd $ra, 8($sp) # 8-byte Folded Spill +; MIPS64-NEXT: sd $16, 0($sp) # 8-byte Folded Spill +; MIPS64-NEXT: jal __gnu_f2h_ieee +; MIPS64-NEXT: move $16, $5 +; MIPS64-NEXT: sh $2, 0($16) +; MIPS64-NEXT: ld $16, 0($sp) # 8-byte Folded Reload +; MIPS64-NEXT: ld $ra, 8($sp) # 8-byte Folded Reload +; MIPS64-NEXT: jr $ra +; MIPS64-NEXT: daddiu $sp, $sp, 16 %a = fptrunc float %f to half store half %a, ptr %p ret void } define void @test_fptrunc_double(double %d, ptr %p) nounwind { -; CHECK-LIBCALL-LABEL: test_fptrunc_double: -; CHECK-LIBCALL: # %bb.0: -; CHECK-LIBCALL-NEXT: addiu $sp, $sp, -24 -; CHECK-LIBCALL-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: sw $16, 16($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: jal __truncdfhf2 -; CHECK-LIBCALL-NEXT: move $16, $6 -; CHECK-LIBCALL-NEXT: sh $2, 0($16) -; CHECK-LIBCALL-NEXT: lw $16, 16($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: jr $ra -; CHECK-LIBCALL-NEXT: addiu $sp, $sp, 24 +; MIPS32-LABEL: test_fptrunc_double: +; MIPS32: # %bb.0: +; MIPS32-NEXT: addiu $sp, $sp, -24 +; MIPS32-NEXT: sw $ra, 20($sp) # 4-byte Folded Spill +; MIPS32-NEXT: sw $16, 16($sp) # 4-byte Folded Spill +; MIPS32-NEXT: jal __truncdfhf2 +; MIPS32-NEXT: move $16, $6 +; MIPS32-NEXT: sh $2, 0($16) +; MIPS32-NEXT: lw $16, 16($sp) # 4-byte Folded Reload +; MIPS32-NEXT: lw $ra, 20($sp) # 4-byte Folded Reload +; MIPS32-NEXT: jr $ra +; MIPS32-NEXT: addiu $sp, $sp, 24 +; +; MIPS64-LABEL: test_fptrunc_double: +; MIPS64: # %bb.0: +; MIPS64-NEXT: daddiu $sp, $sp, -16 +; MIPS64-NEXT: sd $ra, 8($sp) # 8-byte Folded Spill +; MIPS64-NEXT: sd $16, 0($sp) # 8-byte Folded Spill +; MIPS64-NEXT: jal __truncdfhf2 +; MIPS64-NEXT: move $16, $5 +; MIPS64-NEXT: sh $2, 0($16) +; MIPS64-NEXT: ld $16, 0($sp) # 8-byte Folded Reload +; MIPS64-NEXT: ld $ra, 8($sp) # 8-byte Folded Reload +; MIPS64-NEXT: jr $ra +; MIPS64-NEXT: daddiu $sp, $sp, 16 %a = fptrunc double %d to half store half %a, ptr %p ret void } define <4 x float> @test_vec_fpext_float(ptr %p) nounwind { -; CHECK-LIBCALL-LABEL: test_vec_fpext_float: -; CHECK-LIBCALL: # %bb.0: -; CHECK-LIBCALL-NEXT: addiu $sp, $sp, -32 -; CHECK-LIBCALL-NEXT: sw $ra, 28($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: sw $17, 24($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: sw $16, 20($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: move $17, $4 -; CHECK-LIBCALL-NEXT: lhu $4, 6($5) -; CHECK-LIBCALL-NEXT: jal __gnu_h2f_ieee -; CHECK-LIBCALL-NEXT: move $16, $5 -; CHECK-LIBCALL-NEXT: lhu $4, 4($16) -; CHECK-LIBCALL-NEXT: jal __gnu_h2f_ieee -; CHECK-LIBCALL-NEXT: swc1 $f0, 12($17) -; CHECK-LIBCALL-NEXT: swc1 $f0, 8($17) -; CHECK-LIBCALL-NEXT: lhu $4, 2($16) -; CHECK-LIBCALL-NEXT: jal __gnu_h2f_ieee -; CHECK-LIBCALL-NEXT: nop -; CHECK-LIBCALL-NEXT: swc1 $f0, 4($17) -; CHECK-LIBCALL-NEXT: lhu $4, 0($16) -; CHECK-LIBCALL-NEXT: jal __gnu_h2f_ieee -; CHECK-LIBCALL-NEXT: nop -; CHECK-LIBCALL-NEXT: swc1 $f0, 0($17) -; CHECK-LIBCALL-NEXT: lw $16, 20($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: lw $17, 24($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: lw $ra, 28($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: jr $ra -; CHECK-LIBCALL-NEXT: addiu $sp, $sp, 32 +; MIPS32-LABEL: test_vec_fpext_float: +; MIPS32: # %bb.0: +; MIPS32-NEXT: addiu $sp, $sp, -32 +; MIPS32-NEXT: sw $ra, 28($sp) # 4-byte Folded Spill +; MIPS32-NEXT: sw $17, 24($sp) # 4-byte Folded Spill +; MIPS32-NEXT: sw $16, 20($sp) # 4-byte Folded Spill +; MIPS32-NEXT: move $17, $4 +; MIPS32-NEXT: lhu $4, 6($5) +; MIPS32-NEXT: jal __gnu_h2f_ieee +; MIPS32-NEXT: move $16, $5 +; MIPS32-NEXT: lhu $4, 4($16) +; MIPS32-NEXT: jal __gnu_h2f_ieee +; MIPS32-NEXT: swc1 $f0, 12($17) +; MIPS32-NEXT: swc1 $f0, 8($17) +; MIPS32-NEXT: lhu $4, 2($16) +; MIPS32-NEXT: jal __gnu_h2f_ieee +; MIPS32-NEXT: nop +; MIPS32-NEXT: swc1 $f0, 4($17) +; MIPS32-NEXT: lhu $4, 0($16) +; MIPS32-NEXT: jal __gnu_h2f_ieee +; MIPS32-NEXT: nop +; MIPS32-NEXT: swc1 $f0, 0($17) +; MIPS32-NEXT: lw $16, 20($sp) # 4-byte Folded Reload +; MIPS32-NEXT: lw $17, 24($sp) # 4-byte Folded Reload +; MIPS32-NEXT: lw $ra, 28($sp) # 4-byte Folded Reload +; MIPS32-NEXT: jr $ra +; MIPS32-NEXT: addiu $sp, $sp, 32 +; +; MIPS64-LABEL: test_vec_fpext_float: +; MIPS64: # %bb.0: +; MIPS64-NEXT: daddiu $sp, $sp, -32 +; MIPS64-NEXT: sd $ra, 24($sp) # 8-byte Folded Spill +; MIPS64-NEXT: sd $18, 16($sp) # 8-byte Folded Spill +; MIPS64-NEXT: sd $17, 8($sp) # 8-byte Folded Spill +; MIPS64-NEXT: sd $16, 0($sp) # 8-byte Folded Spill +; MIPS64-NEXT: move $16, $4 +; MIPS64-NEXT: lhu $4, 2($4) +; MIPS64-NEXT: jal __gnu_h2f_ieee +; MIPS64-NEXT: nop +; MIPS64-NEXT: lhu $4, 6($16) +; MIPS64-NEXT: jal __gnu_h2f_ieee +; MIPS64-NEXT: mfc1 $17, $f0 +; MIPS64-NEXT: mfc1 $18, $f0 +; MIPS64-NEXT: lhu $4, 0($16) +; MIPS64-NEXT: jal __gnu_h2f_ieee +; MIPS64-NEXT: dsll $17, $17, 32 +; MIPS64-NEXT: mfc1 $1, $f0 +; MIPS64-NEXT: dsll $1, $1, 32 +; MIPS64-NEXT: dsrl $1, $1, 32 +; MIPS64-NEXT: or $17, $1, $17 +; MIPS64-NEXT: lhu $4, 4($16) +; MIPS64-NEXT: jal __gnu_h2f_ieee +; MIPS64-NEXT: dsll $18, $18, 32 +; MIPS64-NEXT: mfc1 $1, $f0 +; MIPS64-NEXT: dsll $1, $1, 32 +; MIPS64-NEXT: dsrl $1, $1, 32 +; MIPS64-NEXT: or $3, $1, $18 +; MIPS64-NEXT: move $2, $17 +; MIPS64-NEXT: ld $16, 0($sp) # 8-byte Folded Reload +; MIPS64-NEXT: ld $17, 8($sp) # 8-byte Folded Reload +; MIPS64-NEXT: ld $18, 16($sp) # 8-byte Folded Reload +; MIPS64-NEXT: ld $ra, 24($sp) # 8-byte Folded Reload +; MIPS64-NEXT: jr $ra +; MIPS64-NEXT: daddiu $sp, $sp, 32 %a = load <4 x half>, ptr %p, align 8 %b = fpext <4 x half> %a to <4 x float> ret <4 x float> %b } define <4 x double> @test_vec_fpext_double(ptr %p) nounwind { -; CHECK-LIBCALL-LABEL: test_vec_fpext_double: -; CHECK-LIBCALL: # %bb.0: -; CHECK-LIBCALL-NEXT: addiu $sp, $sp, -40 -; CHECK-LIBCALL-NEXT: sdc1 $f20, 32($sp) # 8-byte Folded Spill -; CHECK-LIBCALL-NEXT: sw $ra, 28($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: sw $17, 24($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: sw $16, 20($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: move $17, $4 -; CHECK-LIBCALL-NEXT: lhu $4, 6($5) -; CHECK-LIBCALL-NEXT: jal __gnu_h2f_ieee -; CHECK-LIBCALL-NEXT: move $16, $5 -; CHECK-LIBCALL-NEXT: lhu $4, 4($16) -; CHECK-LIBCALL-NEXT: jal __gnu_h2f_ieee -; CHECK-LIBCALL-NEXT: mov.s $f20, $f0 -; CHECK-LIBCALL-NEXT: lhu $4, 2($16) -; CHECK-LIBCALL-NEXT: cvt.d.s $f0, $f0 -; CHECK-LIBCALL-NEXT: cvt.d.s $f2, $f20 -; CHECK-LIBCALL-NEXT: sdc1 $f2, 24($17) -; CHECK-LIBCALL-NEXT: jal __gnu_h2f_ieee -; CHECK-LIBCALL-NEXT: sdc1 $f0, 16($17) -; CHECK-LIBCALL-NEXT: cvt.d.s $f0, $f0 -; CHECK-LIBCALL-NEXT: sdc1 $f0, 8($17) -; CHECK-LIBCALL-NEXT: lhu $4, 0($16) -; CHECK-LIBCALL-NEXT: jal __gnu_h2f_ieee -; CHECK-LIBCALL-NEXT: nop -; CHECK-LIBCALL-NEXT: cvt.d.s $f0, $f0 -; CHECK-LIBCALL-NEXT: sdc1 $f0, 0($17) -; CHECK-LIBCALL-NEXT: lw $16, 20($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: lw $17, 24($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: lw $ra, 28($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: ldc1 $f20, 32($sp) # 8-byte Folded Reload -; CHECK-LIBCALL-NEXT: jr $ra -; CHECK-LIBCALL-NEXT: addiu $sp, $sp, 40 +; MIPS32-LABEL: test_vec_fpext_double: +; MIPS32: # %bb.0: +; MIPS32-NEXT: addiu $sp, $sp, -40 +; MIPS32-NEXT: sdc1 $f20, 32($sp) # 8-byte Folded Spill +; MIPS32-NEXT: sw $ra, 28($sp) # 4-byte Folded Spill +; MIPS32-NEXT: sw $17, 24($sp) # 4-byte Folded Spill +; MIPS32-NEXT: sw $16, 20($sp) # 4-byte Folded Spill +; MIPS32-NEXT: move $17, $4 +; MIPS32-NEXT: lhu $4, 6($5) +; MIPS32-NEXT: jal __gnu_h2f_ieee +; MIPS32-NEXT: move $16, $5 +; MIPS32-NEXT: lhu $4, 4($16) +; MIPS32-NEXT: jal __gnu_h2f_ieee +; MIPS32-NEXT: mov.s $f20, $f0 +; MIPS32-NEXT: lhu $4, 2($16) +; MIPS32-NEXT: cvt.d.s $f0, $f0 +; MIPS32-NEXT: cvt.d.s $f2, $f20 +; MIPS32-NEXT: sdc1 $f2, 24($17) +; MIPS32-NEXT: jal __gnu_h2f_ieee +; MIPS32-NEXT: sdc1 $f0, 16($17) +; MIPS32-NEXT: cvt.d.s $f0, $f0 +; MIPS32-NEXT: sdc1 $f0, 8($17) +; MIPS32-NEXT: lhu $4, 0($16) +; MIPS32-NEXT: jal __gnu_h2f_ieee +; MIPS32-NEXT: nop +; MIPS32-NEXT: cvt.d.s $f0, $f0 +; MIPS32-NEXT: sdc1 $f0, 0($17) +; MIPS32-NEXT: lw $16, 20($sp) # 4-byte Folded Reload +; MIPS32-NEXT: lw $17, 24($sp) # 4-byte Folded Reload +; MIPS32-NEXT: lw $ra, 28($sp) # 4-byte Folded Reload +; MIPS32-NEXT: ldc1 $f20, 32($sp) # 8-byte Folded Reload +; MIPS32-NEXT: jr $ra +; MIPS32-NEXT: addiu $sp, $sp, 40 +; +; MIPS64-LABEL: test_vec_fpext_double: +; MIPS64: # %bb.0: +; MIPS64-NEXT: daddiu $sp, $sp, -32 +; MIPS64-NEXT: sdc1 $f24, 24($sp) # 8-byte Folded Spill +; MIPS64-NEXT: sd $ra, 16($sp) # 8-byte Folded Spill +; MIPS64-NEXT: sd $17, 8($sp) # 8-byte Folded Spill +; MIPS64-NEXT: sd $16, 0($sp) # 8-byte Folded Spill +; MIPS64-NEXT: move $17, $4 +; MIPS64-NEXT: lhu $4, 6($5) +; MIPS64-NEXT: jal __gnu_h2f_ieee +; MIPS64-NEXT: move $16, $5 +; MIPS64-NEXT: lhu $4, 4($16) +; MIPS64-NEXT: jal __gnu_h2f_ieee +; MIPS64-NEXT: mov.s $f24, $f0 +; MIPS64-NEXT: lhu $4, 2($16) +; MIPS64-NEXT: cvt.d.s $f0, $f0 +; MIPS64-NEXT: cvt.d.s $f1, $f24 +; MIPS64-NEXT: sdc1 $f1, 24($17) +; MIPS64-NEXT: jal __gnu_h2f_ieee +; MIPS64-NEXT: sdc1 $f0, 16($17) +; MIPS64-NEXT: cvt.d.s $f0, $f0 +; MIPS64-NEXT: sdc1 $f0, 8($17) +; MIPS64-NEXT: lhu $4, 0($16) +; MIPS64-NEXT: jal __gnu_h2f_ieee +; MIPS64-NEXT: nop +; MIPS64-NEXT: cvt.d.s $f0, $f0 +; MIPS64-NEXT: sdc1 $f0, 0($17) +; MIPS64-NEXT: ld $16, 0($sp) # 8-byte Folded Reload +; MIPS64-NEXT: ld $17, 8($sp) # 8-byte Folded Reload +; MIPS64-NEXT: ld $ra, 16($sp) # 8-byte Folded Reload +; MIPS64-NEXT: ldc1 $f24, 24($sp) # 8-byte Folded Reload +; MIPS64-NEXT: jr $ra +; MIPS64-NEXT: daddiu $sp, $sp, 32 %a = load <4 x half>, ptr %p, align 8 %b = fpext <4 x half> %a to <4 x double> ret <4 x double> %b } define void @test_vec_fptrunc_float(<4 x float> %a, ptr %p) nounwind { -; CHECK-LIBCALL-LABEL: test_vec_fptrunc_float: -; CHECK-LIBCALL: # %bb.0: -; CHECK-LIBCALL-NEXT: addiu $sp, $sp, -40 -; CHECK-LIBCALL-NEXT: sw $ra, 36($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: sw $19, 32($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: sw $18, 28($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: sw $17, 24($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: sw $16, 20($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: move $16, $7 -; CHECK-LIBCALL-NEXT: move $17, $5 -; CHECK-LIBCALL-NEXT: move $18, $4 -; CHECK-LIBCALL-NEXT: jal __gnu_f2h_ieee -; CHECK-LIBCALL-NEXT: mtc1 $6, $f12 -; CHECK-LIBCALL-NEXT: move $19, $2 -; CHECK-LIBCALL-NEXT: jal __gnu_f2h_ieee -; CHECK-LIBCALL-NEXT: mtc1 $16, $f12 -; CHECK-LIBCALL-NEXT: mtc1 $17, $f12 -; CHECK-LIBCALL-NEXT: lw $16, 56($sp) -; CHECK-LIBCALL-NEXT: sh $2, 6($16) -; CHECK-LIBCALL-NEXT: jal __gnu_f2h_ieee -; CHECK-LIBCALL-NEXT: sh $19, 4($16) -; CHECK-LIBCALL-NEXT: sh $2, 2($16) -; CHECK-LIBCALL-NEXT: jal __gnu_f2h_ieee -; CHECK-LIBCALL-NEXT: mtc1 $18, $f12 -; CHECK-LIBCALL-NEXT: sh $2, 0($16) -; CHECK-LIBCALL-NEXT: lw $16, 20($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: lw $17, 24($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: lw $18, 28($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: lw $19, 32($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: lw $ra, 36($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: jr $ra -; CHECK-LIBCALL-NEXT: addiu $sp, $sp, 40 +; MIPS32-LABEL: test_vec_fptrunc_float: +; MIPS32: # %bb.0: +; MIPS32-NEXT: addiu $sp, $sp, -40 +; MIPS32-NEXT: sw $ra, 36($sp) # 4-byte Folded Spill +; MIPS32-NEXT: sw $19, 32($sp) # 4-byte Folded Spill +; MIPS32-NEXT: sw $18, 28($sp) # 4-byte Folded Spill +; MIPS32-NEXT: sw $17, 24($sp) # 4-byte Folded Spill +; MIPS32-NEXT: sw $16, 20($sp) # 4-byte Folded Spill +; MIPS32-NEXT: move $16, $7 +; MIPS32-NEXT: move $17, $5 +; MIPS32-NEXT: move $18, $4 +; MIPS32-NEXT: jal __gnu_f2h_ieee +; MIPS32-NEXT: mtc1 $6, $f12 +; MIPS32-NEXT: move $19, $2 +; MIPS32-NEXT: jal __gnu_f2h_ieee +; MIPS32-NEXT: mtc1 $16, $f12 +; MIPS32-NEXT: mtc1 $17, $f12 +; MIPS32-NEXT: lw $16, 56($sp) +; MIPS32-NEXT: sh $2, 6($16) +; MIPS32-NEXT: jal __gnu_f2h_ieee +; MIPS32-NEXT: sh $19, 4($16) +; MIPS32-NEXT: sh $2, 2($16) +; MIPS32-NEXT: jal __gnu_f2h_ieee +; MIPS32-NEXT: mtc1 $18, $f12 +; MIPS32-NEXT: sh $2, 0($16) +; MIPS32-NEXT: lw $16, 20($sp) # 4-byte Folded Reload +; MIPS32-NEXT: lw $17, 24($sp) # 4-byte Folded Reload +; MIPS32-NEXT: lw $18, 28($sp) # 4-byte Folded Reload +; MIPS32-NEXT: lw $19, 32($sp) # 4-byte Folded Reload +; MIPS32-NEXT: lw $ra, 36($sp) # 4-byte Folded Reload +; MIPS32-NEXT: jr $ra +; MIPS32-NEXT: addiu $sp, $sp, 40 +; +; MIPS64-LABEL: test_vec_fptrunc_float: +; MIPS64: # %bb.0: +; MIPS64-NEXT: daddiu $sp, $sp, -48 +; MIPS64-NEXT: sd $ra, 40($sp) # 8-byte Folded Spill +; MIPS64-NEXT: sd $19, 32($sp) # 8-byte Folded Spill +; MIPS64-NEXT: sd $18, 24($sp) # 8-byte Folded Spill +; MIPS64-NEXT: sd $17, 16($sp) # 8-byte Folded Spill +; MIPS64-NEXT: sd $16, 8($sp) # 8-byte Folded Spill +; MIPS64-NEXT: move $16, $6 +; MIPS64-NEXT: move $17, $5 +; MIPS64-NEXT: move $18, $4 +; MIPS64-NEXT: sll $1, $18, 0 +; MIPS64-NEXT: jal __gnu_f2h_ieee +; MIPS64-NEXT: mtc1 $1, $f12 +; MIPS64-NEXT: move $19, $2 +; MIPS64-NEXT: sll $1, $17, 0 +; MIPS64-NEXT: jal __gnu_f2h_ieee +; MIPS64-NEXT: mtc1 $1, $f12 +; MIPS64-NEXT: dsrl $1, $17, 32 +; MIPS64-NEXT: sll $1, $1, 0 +; MIPS64-NEXT: mtc1 $1, $f12 +; MIPS64-NEXT: sh $2, 4($16) +; MIPS64-NEXT: jal __gnu_f2h_ieee +; MIPS64-NEXT: sh $19, 0($16) +; MIPS64-NEXT: sh $2, 6($16) +; MIPS64-NEXT: dsrl $1, $18, 32 +; MIPS64-NEXT: sll $1, $1, 0 +; MIPS64-NEXT: jal __gnu_f2h_ieee +; MIPS64-NEXT: mtc1 $1, $f12 +; MIPS64-NEXT: sh $2, 2($16) +; MIPS64-NEXT: ld $16, 8($sp) # 8-byte Folded Reload +; MIPS64-NEXT: ld $17, 16($sp) # 8-byte Folded Reload +; MIPS64-NEXT: ld $18, 24($sp) # 8-byte Folded Reload +; MIPS64-NEXT: ld $19, 32($sp) # 8-byte Folded Reload +; MIPS64-NEXT: ld $ra, 40($sp) # 8-byte Folded Reload +; MIPS64-NEXT: jr $ra +; MIPS64-NEXT: daddiu $sp, $sp, 48 %b = fptrunc <4 x float> %a to <4 x half> store <4 x half> %b, ptr %p, align 8 ret void } define void @test_vec_fptrunc_double(<4 x double> %a, ptr %p) nounwind { -; CHECK-LIBCALL-LABEL: test_vec_fptrunc_double: -; CHECK-LIBCALL: # %bb.0: -; CHECK-LIBCALL-NEXT: addiu $sp, $sp, -72 -; CHECK-LIBCALL-NEXT: sw $ra, 68($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: sw $19, 64($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: sw $18, 60($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: sw $17, 56($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: sw $16, 52($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: move $16, $5 -; CHECK-LIBCALL-NEXT: move $17, $4 -; CHECK-LIBCALL-NEXT: lw $1, 92($sp) -; CHECK-LIBCALL-NEXT: sw $1, 36($sp) -; CHECK-LIBCALL-NEXT: lw $1, 88($sp) -; CHECK-LIBCALL-NEXT: sw $1, 32($sp) -; CHECK-LIBCALL-NEXT: lw $1, 96($sp) -; CHECK-LIBCALL-NEXT: lw $2, 100($sp) -; CHECK-LIBCALL-NEXT: sw $2, 44($sp) -; CHECK-LIBCALL-NEXT: sw $1, 40($sp) -; CHECK-LIBCALL-NEXT: ldc1 $f12, 32($sp) -; CHECK-LIBCALL-NEXT: sw $7, 28($sp) -; CHECK-LIBCALL-NEXT: jal __truncdfhf2 -; CHECK-LIBCALL-NEXT: sw $6, 24($sp) -; CHECK-LIBCALL-NEXT: move $18, $2 -; CHECK-LIBCALL-NEXT: jal __truncdfhf2 -; CHECK-LIBCALL-NEXT: ldc1 $f12, 40($sp) -; CHECK-LIBCALL-NEXT: ldc1 $f12, 24($sp) -; CHECK-LIBCALL-NEXT: lw $19, 104($sp) -; CHECK-LIBCALL-NEXT: sh $2, 6($19) -; CHECK-LIBCALL-NEXT: jal __truncdfhf2 -; CHECK-LIBCALL-NEXT: sh $18, 4($19) -; CHECK-LIBCALL-NEXT: sh $2, 2($19) -; CHECK-LIBCALL-NEXT: sw $16, 20($sp) -; CHECK-LIBCALL-NEXT: sw $17, 16($sp) -; CHECK-LIBCALL-NEXT: jal __truncdfhf2 -; CHECK-LIBCALL-NEXT: ldc1 $f12, 16($sp) -; CHECK-LIBCALL-NEXT: sh $2, 0($19) -; CHECK-LIBCALL-NEXT: lw $16, 52($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: lw $17, 56($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: lw $18, 60($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: lw $19, 64($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: lw $ra, 68($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: jr $ra -; CHECK-LIBCALL-NEXT: addiu $sp, $sp, 72 +; MIPS32-LABEL: test_vec_fptrunc_double: +; MIPS32: # %bb.0: +; MIPS32-NEXT: addiu $sp, $sp, -72 +; MIPS32-NEXT: sw $ra, 68($sp) # 4-byte Folded Spill +; MIPS32-NEXT: sw $19, 64($sp) # 4-byte Folded Spill +; MIPS32-NEXT: sw $18, 60($sp) # 4-byte Folded Spill +; MIPS32-NEXT: sw $17, 56($sp) # 4-byte Folded Spill +; MIPS32-NEXT: sw $16, 52($sp) # 4-byte Folded Spill +; MIPS32-NEXT: move $16, $5 +; MIPS32-NEXT: move $17, $4 +; MIPS32-NEXT: lw $1, 92($sp) +; MIPS32-NEXT: sw $1, 36($sp) +; MIPS32-NEXT: lw $1, 88($sp) +; MIPS32-NEXT: sw $1, 32($sp) +; MIPS32-NEXT: lw $1, 96($sp) +; MIPS32-NEXT: lw $2, 100($sp) +; MIPS32-NEXT: sw $2, 44($sp) +; MIPS32-NEXT: sw $1, 40($sp) +; MIPS32-NEXT: ldc1 $f12, 32($sp) +; MIPS32-NEXT: sw $7, 28($sp) +; MIPS32-NEXT: jal __truncdfhf2 +; MIPS32-NEXT: sw $6, 24($sp) +; MIPS32-NEXT: move $18, $2 +; MIPS32-NEXT: jal __truncdfhf2 +; MIPS32-NEXT: ldc1 $f12, 40($sp) +; MIPS32-NEXT: ldc1 $f12, 24($sp) +; MIPS32-NEXT: lw $19, 104($sp) +; MIPS32-NEXT: sh $2, 6($19) +; MIPS32-NEXT: jal __truncdfhf2 +; MIPS32-NEXT: sh $18, 4($19) +; MIPS32-NEXT: sh $2, 2($19) +; MIPS32-NEXT: sw $16, 20($sp) +; MIPS32-NEXT: sw $17, 16($sp) +; MIPS32-NEXT: jal __truncdfhf2 +; MIPS32-NEXT: ldc1 $f12, 16($sp) +; MIPS32-NEXT: sh $2, 0($19) +; MIPS32-NEXT: lw $16, 52($sp) # 4-byte Folded Reload +; MIPS32-NEXT: lw $17, 56($sp) # 4-byte Folded Reload +; MIPS32-NEXT: lw $18, 60($sp) # 4-byte Folded Reload +; MIPS32-NEXT: lw $19, 64($sp) # 4-byte Folded Reload +; MIPS32-NEXT: lw $ra, 68($sp) # 4-byte Folded Reload +; MIPS32-NEXT: jr $ra +; MIPS32-NEXT: addiu $sp, $sp, 72 +; +; MIPS64-LABEL: test_vec_fptrunc_double: +; MIPS64: # %bb.0: +; MIPS64-NEXT: daddiu $sp, $sp, -48 +; MIPS64-NEXT: sd $ra, 40($sp) # 8-byte Folded Spill +; MIPS64-NEXT: sd $20, 32($sp) # 8-byte Folded Spill +; MIPS64-NEXT: sd $19, 24($sp) # 8-byte Folded Spill +; MIPS64-NEXT: sd $18, 16($sp) # 8-byte Folded Spill +; MIPS64-NEXT: sd $17, 8($sp) # 8-byte Folded Spill +; MIPS64-NEXT: sd $16, 0($sp) # 8-byte Folded Spill +; MIPS64-NEXT: move $16, $8 +; MIPS64-NEXT: move $17, $7 +; MIPS64-NEXT: move $18, $5 +; MIPS64-NEXT: move $19, $4 +; MIPS64-NEXT: jal __truncdfhf2 +; MIPS64-NEXT: dmtc1 $6, $f12 +; MIPS64-NEXT: move $20, $2 +; MIPS64-NEXT: jal __truncdfhf2 +; MIPS64-NEXT: dmtc1 $17, $f12 +; MIPS64-NEXT: dmtc1 $18, $f12 +; MIPS64-NEXT: sh $2, 6($16) +; MIPS64-NEXT: jal __truncdfhf2 +; MIPS64-NEXT: sh $20, 4($16) +; MIPS64-NEXT: sh $2, 2($16) +; MIPS64-NEXT: jal __truncdfhf2 +; MIPS64-NEXT: dmtc1 $19, $f12 +; MIPS64-NEXT: sh $2, 0($16) +; MIPS64-NEXT: ld $16, 0($sp) # 8-byte Folded Reload +; MIPS64-NEXT: ld $17, 8($sp) # 8-byte Folded Reload +; MIPS64-NEXT: ld $18, 16($sp) # 8-byte Folded Reload +; MIPS64-NEXT: ld $19, 24($sp) # 8-byte Folded Reload +; MIPS64-NEXT: ld $20, 32($sp) # 8-byte Folded Reload +; MIPS64-NEXT: ld $ra, 40($sp) # 8-byte Folded Reload +; MIPS64-NEXT: jr $ra +; MIPS64-NEXT: daddiu $sp, $sp, 48 %b = fptrunc <4 x double> %a to <4 x half> store <4 x half> %b, ptr %p, align 8 ret void } define half @test_fadd_fadd(half %a, half %b, half %c) nounwind { -; CHECK-LIBCALL-LABEL: test_fadd_fadd: -; CHECK-LIBCALL: # %bb.0: -; CHECK-LIBCALL-NEXT: addiu $sp, $sp, -40 -; CHECK-LIBCALL-NEXT: sdc1 $f20, 32($sp) # 8-byte Folded Spill -; CHECK-LIBCALL-NEXT: sw $ra, 28($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: sw $17, 24($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: sw $16, 20($sp) # 4-byte Folded Spill -; CHECK-LIBCALL-NEXT: move $16, $6 -; CHECK-LIBCALL-NEXT: move $17, $4 -; CHECK-LIBCALL-NEXT: jal __gnu_h2f_ieee -; CHECK-LIBCALL-NEXT: move $4, $5 -; CHECK-LIBCALL-NEXT: mov.s $f20, $f0 -; CHECK-LIBCALL-NEXT: jal __gnu_h2f_ieee -; CHECK-LIBCALL-NEXT: move $4, $17 -; CHECK-LIBCALL-NEXT: jal __gnu_f2h_ieee -; CHECK-LIBCALL-NEXT: add.s $f12, $f0, $f20 -; CHECK-LIBCALL-NEXT: jal __gnu_h2f_ieee -; CHECK-LIBCALL-NEXT: move $4, $2 -; CHECK-LIBCALL-NEXT: mov.s $f20, $f0 -; CHECK-LIBCALL-NEXT: jal __gnu_h2f_ieee -; CHECK-LIBCALL-NEXT: move $4, $16 -; CHECK-LIBCALL-NEXT: jal __gnu_f2h_ieee -; CHECK-LIBCALL-NEXT: add.s $f12, $f20, $f0 -; CHECK-LIBCALL-NEXT: lw $16, 20($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: lw $17, 24($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: lw $ra, 28($sp) # 4-byte Folded Reload -; CHECK-LIBCALL-NEXT: ldc1 $f20, 32($sp) # 8-byte Folded Reload -; CHECK-LIBCALL-NEXT: jr $ra -; CHECK-LIBCALL-NEXT: addiu $sp, $sp, 40 +; MIPS32-LABEL: test_fadd_fadd: +; MIPS32: # %bb.0: +; MIPS32-NEXT: addiu $sp, $sp, -40 +; MIPS32-NEXT: sdc1 $f20, 32($sp) # 8-byte Folded Spill +; MIPS32-NEXT: sw $ra, 28($sp) # 4-byte Folded Spill +; MIPS32-NEXT: sw $17, 24($sp) # 4-byte Folded Spill +; MIPS32-NEXT: sw $16, 20($sp) # 4-byte Folded Spill +; MIPS32-NEXT: move $16, $6 +; MIPS32-NEXT: move $17, $4 +; MIPS32-NEXT: jal __gnu_h2f_ieee +; MIPS32-NEXT: move $4, $5 +; MIPS32-NEXT: mov.s $f20, $f0 +; MIPS32-NEXT: jal __gnu_h2f_ieee +; MIPS32-NEXT: move $4, $17 +; MIPS32-NEXT: jal __gnu_f2h_ieee +; MIPS32-NEXT: add.s $f12, $f0, $f20 +; MIPS32-NEXT: jal __gnu_h2f_ieee +; MIPS32-NEXT: move $4, $2 +; MIPS32-NEXT: mov.s $f20, $f0 +; MIPS32-NEXT: jal __gnu_h2f_ieee +; MIPS32-NEXT: move $4, $16 +; MIPS32-NEXT: jal __gnu_f2h_ieee +; MIPS32-NEXT: add.s $f12, $f20, $f0 +; MIPS32-NEXT: lw $16, 20($sp) # 4-byte Folded Reload +; MIPS32-NEXT: lw $17, 24($sp) # 4-byte Folded Reload +; MIPS32-NEXT: lw $ra, 28($sp) # 4-byte Folded Reload +; MIPS32-NEXT: ldc1 $f20, 32($sp) # 8-byte Folded Reload +; MIPS32-NEXT: jr $ra +; MIPS32-NEXT: addiu $sp, $sp, 40 +; +; MIPS64-LABEL: test_fadd_fadd: +; MIPS64: # %bb.0: +; MIPS64-NEXT: daddiu $sp, $sp, -32 +; MIPS64-NEXT: sdc1 $f24, 24($sp) # 8-byte Folded Spill +; MIPS64-NEXT: sd $ra, 16($sp) # 8-byte Folded Spill +; MIPS64-NEXT: sd $17, 8($sp) # 8-byte Folded Spill +; MIPS64-NEXT: sd $16, 0($sp) # 8-byte Folded Spill +; MIPS64-NEXT: move $16, $6 +; MIPS64-NEXT: move $17, $4 +; MIPS64-NEXT: jal __gnu_h2f_ieee +; MIPS64-NEXT: sll $4, $5, 0 +; MIPS64-NEXT: mov.s $f24, $f0 +; MIPS64-NEXT: jal __gnu_h2f_ieee +; MIPS64-NEXT: sll $4, $17, 0 +; MIPS64-NEXT: jal __gnu_f2h_ieee +; MIPS64-NEXT: add.s $f12, $f0, $f24 +; MIPS64-NEXT: jal __gnu_h2f_ieee +; MIPS64-NEXT: sll $4, $2, 0 +; MIPS64-NEXT: mov.s $f24, $f0 +; MIPS64-NEXT: jal __gnu_h2f_ieee +; MIPS64-NEXT: sll $4, $16, 0 +; MIPS64-NEXT: jal __gnu_f2h_ieee +; MIPS64-NEXT: add.s $f12, $f24, $f0 +; MIPS64-NEXT: ld $16, 0($sp) # 8-byte Folded Reload +; MIPS64-NEXT: ld $17, 8($sp) # 8-byte Folded Reload +; MIPS64-NEXT: ld $ra, 16($sp) # 8-byte Folded Reload +; MIPS64-NEXT: ldc1 $f24, 24($sp) # 8-byte Folded Reload +; MIPS64-NEXT: jr $ra +; MIPS64-NEXT: daddiu $sp, $sp, 32 %d = fadd half %a, %b %e = fadd half %d, %c ret half %e } define half @to_half(i16 %bits) nounwind { -; CHECK-LIBCALL-LABEL: to_half: -; CHECK-LIBCALL: # %bb.0: -; CHECK-LIBCALL-NEXT: jr $ra -; CHECK-LIBCALL-NEXT: move $2, $4 +; MIPS32-LABEL: to_half: +; MIPS32: # %bb.0: +; MIPS32-NEXT: jr $ra +; MIPS32-NEXT: move $2, $4 +; +; MIPS64-LABEL: to_half: +; MIPS64: # %bb.0: +; MIPS64-NEXT: jr $ra +; MIPS64-NEXT: sll $2, $4, 0 %f = bitcast i16 %bits to half ret half %f } define i16 @from_half(half %f) nounwind { -; CHECK-LIBCALL-LABEL: from_half: -; CHECK-LIBCALL: # %bb.0: -; CHECK-LIBCALL-NEXT: jr $ra -; CHECK-LIBCALL-NEXT: move $2, $4 +; MIPS32-LABEL: from_half: +; MIPS32: # %bb.0: +; MIPS32-NEXT: jr $ra +; MIPS32-NEXT: move $2, $4 +; +; MIPS64-LABEL: from_half: +; MIPS64: # %bb.0: +; MIPS64-NEXT: jr $ra +; MIPS64-NEXT: sll $2, $4, 0 %bits = bitcast half %f to i16 ret i16 %bits }