[llvm] [DAG] Add ISD::FSQRT handling to computeKnownFPClass (PR #213620)

Varad Rahul Kamthe via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 3 02:10:03 PDT 2026


================
@@ -6191,6 +6191,25 @@ KnownFPClass SelectionDAG::computeKnownFPClass(SDValue Op,
     Known.fneg();
     break;
   }
+  case ISD::FSQRT: {
+    FPClassTest InterestedSrcs = InterestedClasses;
+    if (InterestedClasses & fcNan)
+      InterestedSrcs |= KnownFPClass::OrderedLessThanZeroMask;
+
+    KnownFPClass KnownSrc = computeKnownFPClass(Op.getOperand(0), DemandedElts,
+                                                InterestedSrcs, Depth + 1);
+
+    const fltSemantics &FltSem =
+        Op.getValueType().getScalarType().getFltSemantics();
+    DenormalMode Mode = getMachineFunction().getDenormalMode(FltSem);
+
+    Known = KnownFPClass::sqrt(KnownSrc, Mode);
+
+    if (Op->getFlags().hasNoNaNs())
----------------
varadk27 wrote:

You're right -- I checked and SelectionDAG's `computeKnownFPClass` has no equivalent mechanism anywhere in the function (checked both entry and exit), so this doesn't happen automatically yet.

I'll add the scope_exit pattern generically before the switch, mirroring the IR version's `nnan/ninf` handling, and drop the manual check from the `sqrt` case. Since that applies to every opcode rather than just `FSQRT`, I'll re-run the full test suite to make sure nothing else shifts as a result. Will push an update shortly.

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


More information about the llvm-commits mailing list