Skip to content

Commit 3d03537

Browse files
authored
[AMDGPU] Fix HasFP32Denormals check in FDIV32 lowering (#66212)
Fixes SWDEV-403219
1 parent c532db0 commit 3d03537

File tree

4 files changed

+2643
-247
lines changed

4 files changed

+2643
-247
lines changed

llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4725,7 +4725,7 @@ bool AMDGPULegalizerInfo::legalizeFDIV32(MachineInstr &MI,
47254725

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

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

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

47434743
auto Fmas = B.buildIntrinsic(Intrinsic::amdgcn_div_fmas, {S32})

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9589,7 +9589,7 @@ SDValue SITargetLowering::LowerFDIV32(SDValue Op, SelectionDAG &DAG) const {
95899589
const SIMachineFunctionInfo *Info = MF.getInfo<SIMachineFunctionInfo>();
95909590
const DenormalMode DenormMode = Info->getMode().FP32Denormals;
95919591

9592-
const bool HasFP32Denormals = DenormMode == DenormalMode::getIEEE();
9592+
const bool HasFP32Denormals = DenormMode != DenormalMode::getPreserveSign();
95939593

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

0 commit comments

Comments
 (0)