[llvm] [SelectionDAG] Use `KnownBits` to determine if an operand may be NaN. (PR #188606)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 31 00:26:24 PDT 2026


================
@@ -6323,13 +6323,23 @@ bool SelectionDAG::isKnownNeverNaN(SDValue Op, const APInt &DemandedElts,
       return true;
     return isKnownNeverNaN(Op.getOperand(0), DemandedElts, SNaN, Depth + 1);
   }
+  case ISD::BITCAST: {
+    // Try to infer NaN from known bits, but only for detecting signaling or
+    // nonsignaling NaNs
+    EVT VT = Op.getValueType();
+    if (!SNaN && VT.isFloatingPoint()) {
----------------
arsenm wrote:

computeKnownBits can do that, computeKnownFPClass cannot. When reinterpreting the bits as a different FP type, the class logic no longer holds in general 

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


More information about the llvm-commits mailing list