[llvm] [AMDGPU] Fix performFMACombine FDOT2 fold ignores denormal-fp-math-f32 (PR #205101)

Wooseok Lee via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 22 10:08:56 PDT 2026


================
@@ -17936,9 +17936,17 @@ SDValue SITargetLowering::performFMACombine(SDNode *N,
       Op2.getOpcode() != ISD::FP_EXTEND)
     return SDValue();
 
-  // fdot2_f32_f16 always flushes fp32 denormal operand and output to zero,
-  // regardless of the denorm mode setting. Therefore,
-  // fp-contract is sufficient to allow generating fdot2.
+  // fdot2_f32_f16 unconditionally flushes the f32 accumulator input and
+  // output to zero (FTZ), ignoring the hardware mode register. Only fold when
+  // the function's denormal-fp-math-f32 is known to flush denormals for both
+  // inputs and outputs (PreserveSign or PositiveZero). DenormalMode::Dynamic
+  // is also rejected because the runtime mode could be IEEE.
+  const DenormalMode FP32DenormMode =
+      DAG.getMachineFunction().getDenormalMode(APFloat::IEEEsingle());
+  if (!FP32DenormMode.inputsAreZero() || !FP32DenormMode.outputsAreZero())
----------------
wooseoklee wrote:

Got it.

https://github.com/llvm/llvm-project/pull/205101


More information about the llvm-commits mailing list