diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2016-12-22 03:05:44 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2016-12-22 03:05:44 +0000 |
commit | cdff21b14ec687e1e8b855d2ba92f68a5e037a26 (patch) | |
tree | 3b782c40be82859e54cedc0ad1c159875cc4ff58 /llvm/lib/Target | |
parent | 4052a576c05a9d11b7f7ac354db901275101003b (diff) | |
download | bcm5719-llvm-cdff21b14ec687e1e8b855d2ba92f68a5e037a26.tar.gz bcm5719-llvm-cdff21b14ec687e1e8b855d2ba92f68a5e037a26.zip |
AMDGPU: Allow rcp and rsq usage with f16
llvm-svn: 290302
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r-- | llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/Target/AMDGPU/SIISelLowering.cpp | 11 |
2 files changed, 8 insertions, 4 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp b/llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp index 2e8db08830e..e6230547a9b 100644 --- a/llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUCodeGenPrepare.cpp @@ -324,7 +324,6 @@ static bool shouldKeepFDivF32(Value *Num, bool UnsafeDiv) { bool AMDGPUCodeGenPrepare::visitFDiv(BinaryOperator &FDiv) { Type *Ty = FDiv.getType(); - // TODO: Handle half if (!Ty->getScalarType()->isFloatTy()) return false; diff --git a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp index 5411ccf7400..fe8f4a38c64 100644 --- a/llvm/lib/Target/AMDGPU/SIISelLowering.cpp +++ b/llvm/lib/Target/AMDGPU/SIISelLowering.cpp @@ -2925,16 +2925,18 @@ SDValue SITargetLowering::lowerFastUnsafeFDIV(SDValue Op, bool Unsafe = DAG.getTarget().Options.UnsafeFPMath; if (const ConstantFPSDNode *CLHS = dyn_cast<ConstantFPSDNode>(LHS)) { - if ((Unsafe || (VT == MVT::f32 && !Subtarget->hasFP32Denormals()))) { - + if (Unsafe || (VT == MVT::f32 && !Subtarget->hasFP32Denormals()) || + VT == MVT::f16) { if (CLHS->isExactlyValue(1.0)) { // v_rcp_f32 and v_rsq_f32 do not support denormals, and according to // the CI documentation has a worst case error of 1 ulp. // OpenCL requires <= 2.5 ulp for 1.0 / x, so it should always be OK to // use it as long as we aren't trying to use denormals. + // + // v_rcp_f16 and v_rsq_f16 DO support denormals. // 1.0 / sqrt(x) -> rsq(x) - // + // XXX - Is UnsafeFPMath sufficient to do this for f64? The maximum ULP // error seems really high at 2^29 ULP. if (RHS.getOpcode() == ISD::FSQRT) @@ -3009,6 +3011,9 @@ static SDValue getFPTernOp(SelectionDAG &DAG, unsigned Opcode, const SDLoc &SL, } SDValue SITargetLowering::LowerFDIV16(SDValue Op, SelectionDAG &DAG) const { + if (SDValue FastLowered = lowerFastUnsafeFDIV(Op, DAG)) + return FastLowered; + SDLoc SL(Op); SDValue Src0 = Op.getOperand(0); SDValue Src1 = Op.getOperand(1); |