Skip to content

Commit

Permalink
[AMDGPU] Fix HasFP32Denormals check in FDIV32 lowering (llvm#66212)
Browse files Browse the repository at this point in the history
Fixes SWDEV-403219
  • Loading branch information
Pierre-vh authored and ZijunZhaoCCK committed Sep 19, 2023
1 parent 7d577cb commit 810a0d1
Show file tree
Hide file tree
Showing 4 changed files with 2,643 additions and 247 deletions.
4 changes: 2 additions & 2 deletions llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4725,7 +4725,7 @@ bool AMDGPULegalizerInfo::legalizeFDIV32(MachineInstr &MI,

// FIXME: Doesn't correctly model the FP mode switch, and the FP operations
// aren't modeled as reading it.
if (Mode.FP32Denormals != DenormalMode::getIEEE())
if (Mode.FP32Denormals == DenormalMode::getPreserveSign())
toggleSPDenormMode(true, B, ST, Mode);

auto Fma0 = B.buildFMA(S32, NegDivScale0, ApproxRcp, One, Flags);
Expand All @@ -4737,7 +4737,7 @@ bool AMDGPULegalizerInfo::legalizeFDIV32(MachineInstr &MI,

// FIXME: This mishandles dynamic denormal mode. We need to query the
// current mode and restore the original.
if (Mode.FP32Denormals != DenormalMode::getIEEE())
if (Mode.FP32Denormals == DenormalMode::getPreserveSign())
toggleSPDenormMode(false, B, ST, Mode);

auto Fmas = B.buildIntrinsic(Intrinsic::amdgcn_div_fmas, {S32})
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AMDGPU/SIISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9589,7 +9589,7 @@ SDValue SITargetLowering::LowerFDIV32(SDValue Op, SelectionDAG &DAG) const {
const SIMachineFunctionInfo *Info = MF.getInfo<SIMachineFunctionInfo>();
const DenormalMode DenormMode = Info->getMode().FP32Denormals;

const bool HasFP32Denormals = DenormMode == DenormalMode::getIEEE();
const bool HasFP32Denormals = DenormMode != DenormalMode::getPreserveSign();

if (!HasFP32Denormals) {
// Note we can't use the STRICT_FMA/STRICT_FMUL for the non-strict FDIV
Expand Down
Loading

0 comments on commit 810a0d1

Please sign in to comment.