[llvm] [AMDGPU] Legalize strict fp_extend from bf16 (PR #215477)

via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 18 10:10:35 PDT 2026


================
@@ -5006,10 +5006,15 @@ SDValue SITargetLowering::lowerFP_EXTEND(SDValue Op, SelectionDAG &DAG) const {
       DAG.getNode(ISD::BITCAST, SL, SrcVT.changeTypeToInteger(), Src);
 
   EVT DstVT = Op.getValueType();
-  if (IsStrict)
-    llvm_unreachable("Need STRICT_BF16_TO_FP");
+  SDValue Result = DAG.getNode(ISD::BF16_TO_FP, SL, DstVT, BitCast);
+  if (!IsStrict)
+    return Result;
 
-  return DAG.getNode(ISD::BF16_TO_FP, SL, DstVT, BitCast);
+  // Route through a strict add of -0.0, exact for every input including
+  // sign of zero, so a real FP instruction quiets/traps on a signaling NaN.
+  SDValue NegZero = DAG.getConstantFP(-0.0, SL, DstVT);
+  return DAG.getNode(ISD::STRICT_FADD, SL, DAG.getVTList(DstVT, MVT::Other),
----------------
carlobertolli wrote:

Is this guaranteed not to be dropped by a later pass?

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


More information about the llvm-commits mailing list