[llvm] [NVPTX] Improve support for rsqrt.approx (PR #89417)

Alex MacLean via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 19 10:51:22 PDT 2024


================
@@ -30,6 +30,10 @@ using namespace llvm;
 #define DEBUG_TYPE "nvptx-isel"
 #define PASS_NAME "NVPTX DAG->DAG Pattern Instruction Selection"
 
+static cl::opt<bool>
+    DisableRsqrtOpt("nvptx-disable-rsqrt-opt", cl::init(false), cl::Hidden,
----------------
AlexMaclean wrote:

> We'll need someone familiar with FP nuances to take a look.

Any ideas who might have the necessary expertise?

> Enabling sqrt->rsqrt.approx by default sounds risky to me.

By default such a transformation is disabled. We'll only do that transformation when `-nvptx-prec-sqrtf32=0` has been specified. In these cases we'd lower `sqrt` to `sqrt.approx` before this change. Adding `sqrt.approx` -> `rsqrt.approx` seems safe to me, and FWIW it hasn't caused any issues with our internal testing. 



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


More information about the llvm-commits mailing list