[llvm] [NVPTX] Lower -1/x to neg.f64(recp.rn.f64) instead of fdiv (PR #98343)

Artem Belevich via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 11 11:23:12 PDT 2024


================
@@ -1225,6 +1235,10 @@ def FDIV64ri :
             "div.rn.f64 \t$dst, $a, $b;",
             [(set Float64Regs:$dst, (fdiv Float64Regs:$a, fpimm:$b))]>;
 
+// fdiv -1.0, X => fneg (rcp.rn X)
+def : Pat<(fdiv DoubleConstNeg1:$a, Float64Regs:$b),
+          (FNEGf64 (FDIV641r (NegDoubleConst node:$a), Float64Regs:$b))>;
----------------
Artem-B wrote:

Do we really need `NegDoubleConst` just for a known constant value. Can we just use `f64 -1.0` ?

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


More information about the llvm-commits mailing list