diff --git a/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp b/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp index 7fe58539cd4ec..2c752457d165e 100644 --- a/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp +++ b/llvm/lib/Target/X86/GISel/X86LegalizerInfo.cpp @@ -98,10 +98,11 @@ X86LegalizerInfo::X86LegalizerInfo(const X86Subtarget &STI, .widenScalarToNextPow2(0, /*Min=*/8) .clampScalar(0, s8, sMaxScalar); - getActionDefinitionsBuilder( - {G_LROUND, G_LLROUND, G_FCOS, G_FCOSH, G_FACOS, G_FSIN, G_FSINH, - G_FASIN, G_FTAN, G_FTANH, G_FATAN, G_FATAN2, G_FPOW, G_FEXP, - G_FEXP2, G_FEXP10, G_FLOG, G_FLOG2, G_FLOG10, G_FPOWI, G_FSINCOS}) + getActionDefinitionsBuilder({G_LROUND, G_LLROUND, G_FCOS, G_FCOSH, G_FACOS, + G_FSIN, G_FSINH, G_FASIN, G_FTAN, G_FTANH, + G_FATAN, G_FATAN2, G_FPOW, G_FEXP, G_FEXP2, + G_FEXP10, G_FLOG, G_FLOG2, G_FLOG10, G_FPOWI, + G_FSINCOS, G_FCEIL, G_FFLOOR}) .libcall(); getActionDefinitionsBuilder(G_FSQRT) @@ -580,7 +581,7 @@ X86LegalizerInfo::X86LegalizerInfo(const X86Subtarget &STI, .lower(); // fp intrinsics - getActionDefinitionsBuilder(G_INTRINSIC_ROUNDEVEN) + getActionDefinitionsBuilder({G_INTRINSIC_ROUNDEVEN, G_INTRINSIC_TRUNC}) .scalarize(0) .minScalar(0, LLT::scalar(32)) .libcall(); diff --git a/llvm/test/CodeGen/X86/isel-ceil.ll b/llvm/test/CodeGen/X86/isel-ceil.ll index c82cfebd4814d..21df3f1160003 100644 --- a/llvm/test/CodeGen/X86/isel-ceil.ll +++ b/llvm/test/CodeGen/X86/isel-ceil.ll @@ -3,8 +3,8 @@ ; RUN: llc < %s -mtriple=x86_64-linux-gnu -fast-isel | FileCheck %s --check-prefixes=X64,FASTISEL-X64 ; RUN: llc < %s -mtriple=i686-linux-gnu | FileCheck %s --check-prefixes=X86 ; RUN: llc < %s -mtriple=i686-linux-gnu -fast-isel | FileCheck %s --check-prefixes=X86 -; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=GISEL-X64 -; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X86 +; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=GISEL-X64 +; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=GISEL-X86 define float @ceil_f32(float %a) nounwind readnone { ; DAG-X64-LABEL: ceil_f32: @@ -29,7 +29,19 @@ define float @ceil_f32(float %a) nounwind readnone { ; ; GISEL-X64-LABEL: ceil_f32: ; GISEL-X64: # %bb.0: -; GISEL-X64-NEXT: jmp ceilf@PLT # TAILCALL +; GISEL-X64-NEXT: pushq %rax +; GISEL-X64-NEXT: callq ceilf +; GISEL-X64-NEXT: popq %rax +; GISEL-X64-NEXT: retq +; +; GISEL-X86-LABEL: ceil_f32: +; GISEL-X86: # %bb.0: +; GISEL-X86-NEXT: subl $12, %esp +; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %eax +; GISEL-X86-NEXT: movl %eax, (%esp) +; GISEL-X86-NEXT: calll ceilf +; GISEL-X86-NEXT: addl $12, %esp +; GISEL-X86-NEXT: retl %c = call float @llvm.ceil.f32(float %a) ret float %c } @@ -57,7 +69,24 @@ define double @ceil_f64(double %a) nounwind readnone { ; ; GISEL-X64-LABEL: ceil_f64: ; GISEL-X64: # %bb.0: -; GISEL-X64-NEXT: jmp ceil@PLT # TAILCALL +; GISEL-X64-NEXT: pushq %rax +; GISEL-X64-NEXT: callq ceil +; GISEL-X64-NEXT: popq %rax +; GISEL-X64-NEXT: retq +; +; GISEL-X86-LABEL: ceil_f64: +; GISEL-X86: # %bb.0: +; GISEL-X86-NEXT: subl $12, %esp +; GISEL-X86-NEXT: leal {{[0-9]+}}(%esp), %eax +; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %ecx +; GISEL-X86-NEXT: movl 4(%eax), %eax +; GISEL-X86-NEXT: xorl %edx, %edx +; GISEL-X86-NEXT: addl %esp, %edx +; GISEL-X86-NEXT: movl %ecx, (%esp) +; GISEL-X86-NEXT: movl %eax, 4(%edx) +; GISEL-X86-NEXT: calll ceil +; GISEL-X86-NEXT: addl $12, %esp +; GISEL-X86-NEXT: retl %c = call double @llvm.ceil.f64(double %a) ret double %c } @@ -86,10 +115,18 @@ define x86_fp80 @ceil_f80(x86_fp80 %a) nounwind readnone { ; GISEL-X64-NEXT: subq $24, %rsp ; GISEL-X64-NEXT: fldt {{[0-9]+}}(%rsp) ; GISEL-X64-NEXT: fstpt (%rsp) -; GISEL-X64-NEXT: callq ceill@PLT +; GISEL-X64-NEXT: callq ceill ; GISEL-X64-NEXT: addq $24, %rsp ; GISEL-X64-NEXT: retq +; +; GISEL-X86-LABEL: ceil_f80: +; GISEL-X86: # %bb.0: +; GISEL-X86-NEXT: subl $12, %esp +; GISEL-X86-NEXT: fldt {{[0-9]+}}(%esp) +; GISEL-X86-NEXT: fstpt (%esp) +; GISEL-X86-NEXT: calll ceill +; GISEL-X86-NEXT: addl $12, %esp +; GISEL-X86-NEXT: retl %c = call x86_fp80 @llvm.ceil.f80(x86_fp80 %a) ret x86_fp80 %c } - diff --git a/llvm/test/CodeGen/X86/isel-floor.ll b/llvm/test/CodeGen/X86/isel-floor.ll index 675925b611263..66eeee89169ba 100644 --- a/llvm/test/CodeGen/X86/isel-floor.ll +++ b/llvm/test/CodeGen/X86/isel-floor.ll @@ -3,8 +3,8 @@ ; RUN: llc < %s -mtriple=x86_64-linux-gnu -fast-isel | FileCheck %s --check-prefixes=X64,FASTISEL-X64 ; RUN: llc < %s -mtriple=i686-linux-gnu | FileCheck %s --check-prefixes=X86 ; RUN: llc < %s -mtriple=i686-linux-gnu -fast-isel | FileCheck %s --check-prefixes=X86 -; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=GISEL-X64 -; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X86 +; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=GISEL-X64 +; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=GISEL-X86 define float @floor_f32(float %a) nounwind readnone { ; DAG-X64-LABEL: floor_f32: @@ -29,7 +29,19 @@ define float @floor_f32(float %a) nounwind readnone { ; ; GISEL-X64-LABEL: floor_f32: ; GISEL-X64: # %bb.0: -; GISEL-X64-NEXT: jmp floorf@PLT # TAILCALL +; GISEL-X64-NEXT: pushq %rax +; GISEL-X64-NEXT: callq floorf +; GISEL-X64-NEXT: popq %rax +; GISEL-X64-NEXT: retq +; +; GISEL-X86-LABEL: floor_f32: +; GISEL-X86: # %bb.0: +; GISEL-X86-NEXT: subl $12, %esp +; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %eax +; GISEL-X86-NEXT: movl %eax, (%esp) +; GISEL-X86-NEXT: calll floorf +; GISEL-X86-NEXT: addl $12, %esp +; GISEL-X86-NEXT: retl %c = call float @llvm.floor.f32(float %a) ret float %c } @@ -57,7 +69,24 @@ define double @floor_f64(double %a) nounwind readnone { ; ; GISEL-X64-LABEL: floor_f64: ; GISEL-X64: # %bb.0: -; GISEL-X64-NEXT: jmp floor@PLT # TAILCALL +; GISEL-X64-NEXT: pushq %rax +; GISEL-X64-NEXT: callq floor +; GISEL-X64-NEXT: popq %rax +; GISEL-X64-NEXT: retq +; +; GISEL-X86-LABEL: floor_f64: +; GISEL-X86: # %bb.0: +; GISEL-X86-NEXT: subl $12, %esp +; GISEL-X86-NEXT: leal {{[0-9]+}}(%esp), %eax +; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %ecx +; GISEL-X86-NEXT: movl 4(%eax), %eax +; GISEL-X86-NEXT: xorl %edx, %edx +; GISEL-X86-NEXT: addl %esp, %edx +; GISEL-X86-NEXT: movl %ecx, (%esp) +; GISEL-X86-NEXT: movl %eax, 4(%edx) +; GISEL-X86-NEXT: calll floor +; GISEL-X86-NEXT: addl $12, %esp +; GISEL-X86-NEXT: retl %c = call double @llvm.floor.f64(double %a) ret double %c } @@ -86,10 +115,18 @@ define x86_fp80 @floor_f80(x86_fp80 %a) nounwind readnone { ; GISEL-X64-NEXT: subq $24, %rsp ; GISEL-X64-NEXT: fldt {{[0-9]+}}(%rsp) ; GISEL-X64-NEXT: fstpt (%rsp) -; GISEL-X64-NEXT: callq floorl@PLT +; GISEL-X64-NEXT: callq floorl ; GISEL-X64-NEXT: addq $24, %rsp ; GISEL-X64-NEXT: retq +; +; GISEL-X86-LABEL: floor_f80: +; GISEL-X86: # %bb.0: +; GISEL-X86-NEXT: subl $12, %esp +; GISEL-X86-NEXT: fldt {{[0-9]+}}(%esp) +; GISEL-X86-NEXT: fstpt (%esp) +; GISEL-X86-NEXT: calll floorl +; GISEL-X86-NEXT: addl $12, %esp +; GISEL-X86-NEXT: retl %c = call x86_fp80 @llvm.floor.f80(x86_fp80 %a) ret x86_fp80 %c } - diff --git a/llvm/test/CodeGen/X86/isel-ftrunc.ll b/llvm/test/CodeGen/X86/isel-ftrunc.ll index 9bf06193961a3..dcdb016d29aca 100644 --- a/llvm/test/CodeGen/X86/isel-ftrunc.ll +++ b/llvm/test/CodeGen/X86/isel-ftrunc.ll @@ -3,8 +3,8 @@ ; RUN: llc < %s -mtriple=x86_64-linux-gnu -fast-isel | FileCheck %s --check-prefixes=X64,FASTISEL-X64 ; RUN: llc < %s -mtriple=i686-linux-gnu | FileCheck %s --check-prefixes=X86 ; RUN: llc < %s -mtriple=i686-linux-gnu -fast-isel | FileCheck %s --check-prefixes=X86 -; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=GISEL-X64 -; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=2 | FileCheck %s --check-prefixes=X86 +; RUN: llc < %s -mtriple=x86_64-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=GISEL-X64 +; RUN: llc < %s -mtriple=i686-linux-gnu -global-isel -global-isel-abort=1 | FileCheck %s --check-prefixes=GISEL-X86 define float @trunc_f32(float %a) nounwind readnone { ; DAG-X64-LABEL: trunc_f32: @@ -29,7 +29,19 @@ define float @trunc_f32(float %a) nounwind readnone { ; ; GISEL-X64-LABEL: trunc_f32: ; GISEL-X64: # %bb.0: -; GISEL-X64-NEXT: jmp truncf@PLT # TAILCALL +; GISEL-X64-NEXT: pushq %rax +; GISEL-X64-NEXT: callq truncf +; GISEL-X64-NEXT: popq %rax +; GISEL-X64-NEXT: retq +; +; GISEL-X86-LABEL: trunc_f32: +; GISEL-X86: # %bb.0: +; GISEL-X86-NEXT: subl $12, %esp +; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %eax +; GISEL-X86-NEXT: movl %eax, (%esp) +; GISEL-X86-NEXT: calll truncf +; GISEL-X86-NEXT: addl $12, %esp +; GISEL-X86-NEXT: retl %c = call float @llvm.trunc.f32(float %a) ret float %c } @@ -57,7 +69,24 @@ define double @trunc_f64(double %a) nounwind readnone { ; ; GISEL-X64-LABEL: trunc_f64: ; GISEL-X64: # %bb.0: -; GISEL-X64-NEXT: jmp trunc@PLT # TAILCALL +; GISEL-X64-NEXT: pushq %rax +; GISEL-X64-NEXT: callq trunc +; GISEL-X64-NEXT: popq %rax +; GISEL-X64-NEXT: retq +; +; GISEL-X86-LABEL: trunc_f64: +; GISEL-X86: # %bb.0: +; GISEL-X86-NEXT: subl $12, %esp +; GISEL-X86-NEXT: leal {{[0-9]+}}(%esp), %eax +; GISEL-X86-NEXT: movl {{[0-9]+}}(%esp), %ecx +; GISEL-X86-NEXT: movl 4(%eax), %eax +; GISEL-X86-NEXT: xorl %edx, %edx +; GISEL-X86-NEXT: addl %esp, %edx +; GISEL-X86-NEXT: movl %ecx, (%esp) +; GISEL-X86-NEXT: movl %eax, 4(%edx) +; GISEL-X86-NEXT: calll trunc +; GISEL-X86-NEXT: addl $12, %esp +; GISEL-X86-NEXT: retl %c = call double @llvm.trunc.f64(double %a) ret double %c } @@ -86,10 +115,18 @@ define x86_fp80 @trunc_f80(x86_fp80 %a) nounwind readnone { ; GISEL-X64-NEXT: subq $24, %rsp ; GISEL-X64-NEXT: fldt {{[0-9]+}}(%rsp) ; GISEL-X64-NEXT: fstpt (%rsp) -; GISEL-X64-NEXT: callq truncl@PLT +; GISEL-X64-NEXT: callq truncl ; GISEL-X64-NEXT: addq $24, %rsp ; GISEL-X64-NEXT: retq +; +; GISEL-X86-LABEL: trunc_f80: +; GISEL-X86: # %bb.0: +; GISEL-X86-NEXT: subl $12, %esp +; GISEL-X86-NEXT: fldt {{[0-9]+}}(%esp) +; GISEL-X86-NEXT: fstpt (%esp) +; GISEL-X86-NEXT: calll truncl +; GISEL-X86-NEXT: addl $12, %esp +; GISEL-X86-NEXT: retl %c = call x86_fp80 @llvm.trunc.f80(x86_fp80 %a) ret x86_fp80 %c } -