R600/SI: Add a pattern for f32 ftrunc

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211377 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Tom Stellard 2014-06-20 17:06:09 +00:00
parent 2cda6e8ca6
commit 61d64acd0c
4 changed files with 104 additions and 96 deletions

View File

@ -938,6 +938,8 @@ SDValue AMDGPUTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
case AMDGPUIntrinsic::AMDIL_round_nearest: // Legacy name. case AMDGPUIntrinsic::AMDIL_round_nearest: // Legacy name.
return DAG.getNode(ISD::FRINT, DL, VT, Op.getOperand(1)); return DAG.getNode(ISD::FRINT, DL, VT, Op.getOperand(1));
case AMDGPUIntrinsic::AMDGPU_trunc:
return DAG.getNode(ISD::FTRUNC, DL, VT, Op.getOperand(1));
} }
} }

View File

@ -721,14 +721,11 @@ def SETNE_DX10 : R600_2OP <
>; >;
def FRACT : R600_1OP_Helper <0x10, "FRACT", AMDGPUfract>; def FRACT : R600_1OP_Helper <0x10, "FRACT", AMDGPUfract>;
def TRUNC : R600_1OP_Helper <0x11, "TRUNC", int_AMDGPU_trunc>; def TRUNC : R600_1OP_Helper <0x11, "TRUNC", ftrunc>;
def CEIL : R600_1OP_Helper <0x12, "CEIL", fceil>; def CEIL : R600_1OP_Helper <0x12, "CEIL", fceil>;
def RNDNE : R600_1OP_Helper <0x13, "RNDNE", frint>; def RNDNE : R600_1OP_Helper <0x13, "RNDNE", frint>;
def FLOOR : R600_1OP_Helper <0x14, "FLOOR", ffloor>; def FLOOR : R600_1OP_Helper <0x14, "FLOOR", ffloor>;
// Add also ftrunc intrinsic pattern
def : Pat<(ftrunc f32:$src0), (TRUNC $src0)>;
def MOV : R600_1OP <0x19, "MOV", []>; def MOV : R600_1OP <0x19, "MOV", []>;
let isPseudo = 1, isCodeGenOnly = 1, usesCustomInserter = 1 in { let isPseudo = 1, isCodeGenOnly = 1, usesCustomInserter = 1 in {

View File

@ -1098,7 +1098,7 @@ defm V_FRACT_F32 : VOP1_32 <0x00000020, "V_FRACT_F32",
[(set f32:$dst, (AMDGPUfract f32:$src0))] [(set f32:$dst, (AMDGPUfract f32:$src0))]
>; >;
defm V_TRUNC_F32 : VOP1_32 <0x00000021, "V_TRUNC_F32", defm V_TRUNC_F32 : VOP1_32 <0x00000021, "V_TRUNC_F32",
[(set f32:$dst, (int_AMDGPU_trunc f32:$src0))] [(set f32:$dst, (ftrunc f32:$src0))]
>; >;
defm V_CEIL_F32 : VOP1_32 <0x00000022, "V_CEIL_F32", defm V_CEIL_F32 : VOP1_32 <0x00000022, "V_CEIL_F32",
[(set f32:$dst, (fceil f32:$src0))] [(set f32:$dst, (fceil f32:$src0))]

View File

@ -1,110 +1,119 @@
; RUN: llc -march=r600 -mcpu=bonaire < %s | FileCheck -check-prefix=CI -check-prefix=FUNC %s ; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=EG --check-prefix=FUNC %s
; RUN: llc -march=r600 -mcpu=SI < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s ; RUN: llc -march=r600 -mcpu=SI < %s | FileCheck -check-prefix=SI --check-prefix=FUNC %s
declare double @llvm.trunc.f64(double) nounwind readnone declare float @llvm.trunc.f32(float) nounwind readnone
declare <2 x double> @llvm.trunc.v2f64(<2 x double>) nounwind readnone declare <2 x float> @llvm.trunc.v2f32(<2 x float>) nounwind readnone
declare <3 x double> @llvm.trunc.v3f64(<3 x double>) nounwind readnone declare <3 x float> @llvm.trunc.v3f32(<3 x float>) nounwind readnone
declare <4 x double> @llvm.trunc.v4f64(<4 x double>) nounwind readnone declare <4 x float> @llvm.trunc.v4f32(<4 x float>) nounwind readnone
declare <8 x double> @llvm.trunc.v8f64(<8 x double>) nounwind readnone declare <8 x float> @llvm.trunc.v8f32(<8 x float>) nounwind readnone
declare <16 x double> @llvm.trunc.v16f64(<16 x double>) nounwind readnone declare <16 x float> @llvm.trunc.v16f32(<16 x float>) nounwind readnone
; FUNC-LABEL: @v_ftrunc_f64: ; FUNC-LABEL: @ftrunc_f32:
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; SI: V_BFE_I32 {{v[0-9]+}}, {{v[0-9]+}}, 20, 11 ; SI: V_TRUNC_F32_e32
; SI: S_ENDPGM define void @ftrunc_f32(float addrspace(1)* %out, float %x) {
define void @v_ftrunc_f64(double addrspace(1)* %out, double addrspace(1)* %in) { %y = call float @llvm.trunc.f32(float %x) nounwind readnone
%x = load double addrspace(1)* %in, align 8 store float %y, float addrspace(1)* %out
%y = call double @llvm.trunc.f64(double %x) nounwind readnone
store double %y, double addrspace(1)* %out, align 8
ret void ret void
} }
; FUNC-LABEL: @ftrunc_f64: ; FUNC-LABEL: @ftrunc_v2f32:
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; EG: TRUNC
; SI: S_BFE_I32 [[SEXP:s[0-9]+]], {{s[0-9]+}}, 0xb0014 ; SI: V_TRUNC_F32_e32
; SI: S_ADD_I32 s{{[0-9]+}}, [[SEXP]], 0xfffffc01 ; SI: V_TRUNC_F32_e32
; SI: S_LSHR_B64 define void @ftrunc_v2f32(<2 x float> addrspace(1)* %out, <2 x float> %x) {
; SI: S_NOT_B64 %y = call <2 x float> @llvm.trunc.v2f32(<2 x float> %x) nounwind readnone
; SI: S_AND_B64 store <2 x float> %y, <2 x float> addrspace(1)* %out
; SI: S_AND_B32 s{{[0-9]+}}, s{{[0-9]+}}, 0x80000000
; SI: CMP_LT_I32
; SI: CNDMASK_B32
; SI: CNDMASK_B32
; SI: CMP_GT_I32
; SI: CNDMASK_B32
; SI: CNDMASK_B32
; SI: S_ENDPGM
define void @ftrunc_f64(double addrspace(1)* %out, double %x) {
%y = call double @llvm.trunc.f64(double %x) nounwind readnone
store double %y, double addrspace(1)* %out
ret void ret void
} }
; FUNC-LABEL: @ftrunc_v2f64: ; FIXME-FUNC-LABEL: @ftrunc_v3f32:
; CI: V_TRUNC_F64_e32 ; FIXME-EG: TRUNC
; CI: V_TRUNC_F64_e32 ; FIXME-EG: TRUNC
define void @ftrunc_v2f64(<2 x double> addrspace(1)* %out, <2 x double> %x) { ; FIXME-EG: TRUNC
%y = call <2 x double> @llvm.trunc.v2f64(<2 x double> %x) nounwind readnone ; FIXME-SI: V_TRUNC_F32_e32
store <2 x double> %y, <2 x double> addrspace(1)* %out ; FIXME-SI: V_TRUNC_F32_e32
ret void ; FIXME-SI: V_TRUNC_F32_e32
} ; define void @ftrunc_v3f32(<3 x float> addrspace(1)* %out, <3 x float> %x) {
; %y = call <3 x float> @llvm.trunc.v3f32(<3 x float> %x) nounwind readnone
; FIXME-FUNC-LABEL: @ftrunc_v3f64: ; store <3 x float> %y, <3 x float> addrspace(1)* %out
; FIXME-CI: V_TRUNC_F64_e32
; FIXME-CI: V_TRUNC_F64_e32
; FIXME-CI: V_TRUNC_F64_e32
; define void @ftrunc_v3f64(<3 x double> addrspace(1)* %out, <3 x double> %x) {
; %y = call <3 x double> @llvm.trunc.v3f64(<3 x double> %x) nounwind readnone
; store <3 x double> %y, <3 x double> addrspace(1)* %out
; ret void ; ret void
; } ; }
; FUNC-LABEL: @ftrunc_v4f64: ; FUNC-LABEL: @ftrunc_v4f32:
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
define void @ftrunc_v4f64(<4 x double> addrspace(1)* %out, <4 x double> %x) { ; SI: V_TRUNC_F32_e32
%y = call <4 x double> @llvm.trunc.v4f64(<4 x double> %x) nounwind readnone ; SI: V_TRUNC_F32_e32
store <4 x double> %y, <4 x double> addrspace(1)* %out ; SI: V_TRUNC_F32_e32
; SI: V_TRUNC_F32_e32
define void @ftrunc_v4f32(<4 x float> addrspace(1)* %out, <4 x float> %x) {
%y = call <4 x float> @llvm.trunc.v4f32(<4 x float> %x) nounwind readnone
store <4 x float> %y, <4 x float> addrspace(1)* %out
ret void ret void
} }
; FUNC-LABEL: @ftrunc_v8f64: ; FUNC-LABEL: @ftrunc_v8f32:
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
define void @ftrunc_v8f64(<8 x double> addrspace(1)* %out, <8 x double> %x) { ; SI: V_TRUNC_F32_e32
%y = call <8 x double> @llvm.trunc.v8f64(<8 x double> %x) nounwind readnone ; SI: V_TRUNC_F32_e32
store <8 x double> %y, <8 x double> addrspace(1)* %out ; SI: V_TRUNC_F32_e32
; SI: V_TRUNC_F32_e32
; SI: V_TRUNC_F32_e32
; SI: V_TRUNC_F32_e32
; SI: V_TRUNC_F32_e32
; SI: V_TRUNC_F32_e32
define void @ftrunc_v8f32(<8 x float> addrspace(1)* %out, <8 x float> %x) {
%y = call <8 x float> @llvm.trunc.v8f32(<8 x float> %x) nounwind readnone
store <8 x float> %y, <8 x float> addrspace(1)* %out
ret void ret void
} }
; FUNC-LABEL: @ftrunc_v16f64: ; FUNC-LABEL: @ftrunc_v16f32:
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
; CI: V_TRUNC_F64_e32 ; EG: TRUNC
define void @ftrunc_v16f64(<16 x double> addrspace(1)* %out, <16 x double> %x) { ; SI: V_TRUNC_F32_e32
%y = call <16 x double> @llvm.trunc.v16f64(<16 x double> %x) nounwind readnone ; SI: V_TRUNC_F32_e32
store <16 x double> %y, <16 x double> addrspace(1)* %out ; SI: V_TRUNC_F32_e32
; SI: V_TRUNC_F32_e32
; SI: V_TRUNC_F32_e32
; SI: V_TRUNC_F32_e32
; SI: V_TRUNC_F32_e32
; SI: V_TRUNC_F32_e32
; SI: V_TRUNC_F32_e32
; SI: V_TRUNC_F32_e32
; SI: V_TRUNC_F32_e32
; SI: V_TRUNC_F32_e32
; SI: V_TRUNC_F32_e32
; SI: V_TRUNC_F32_e32
; SI: V_TRUNC_F32_e32
; SI: V_TRUNC_F32_e32
define void @ftrunc_v16f32(<16 x float> addrspace(1)* %out, <16 x float> %x) {
%y = call <16 x float> @llvm.trunc.v16f32(<16 x float> %x) nounwind readnone
store <16 x float> %y, <16 x float> addrspace(1)* %out
ret void ret void
} }