[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 04:32: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:

Updated. Moved this to the generic `scope_exit `mechanism before the switch, matching the IR version. Also had to wrap the switch in a nested block so the guard's destructor runs before the function returns (otherwise it can race NRVO and silently not apply). 
The diff looks larger than it is because wrapping the switch required reindenting the entire block; no logic changed inside the switch. Full `check-llvm` run is clean.

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


More information about the llvm-commits mailing list