[PATCH] D76853: [DAGCombiner] Use rsqrt to estimate sqrt only when ninf flag set

Sanjay Patel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 27 09:41:44 PDT 2020


spatel added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:13096-13098
   if (!DAG.getTarget().Options.UnsafeFPMath &&
       !Flags.hasApproximateFuncs())
     return SDValue();
----------------
Can we add the 'ninf' check here instead?


================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:21193
+
+  // Use rsqrt to estimate would produce wrong result for +Inf
+  if (!Reciprocal && !Options.NoInfsFPMath && !Flags.hasNoInfs())
----------------
We can make this comment more exact; something like:
  // Require 'ninf' because sqrt(Inf) == Inf, but an estimate computes:
  // sqrt(Inf) == rqsrt(Inf) * Inf == 0 * Inf == NaN. 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D76853/new/

https://reviews.llvm.org/D76853





More information about the llvm-commits mailing list