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

Artem Belevich via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 12 10:26:31 PDT 2024


================
@@ -1150,6 +1150,16 @@ def DoubleConst1 : PatLeaf<(fpimm), [{
   return &N->getValueAPF().getSemantics() == &llvm::APFloat::IEEEdouble() &&
          N->getValueAPF().convertToDouble() == 1.0;
 }]>;
+// Constant -1.0 (double)
+def DoubleConstNeg1 : PatLeaf<(fpimm), [{
+  return &N->getValueAPF().getSemantics() == &llvm::APFloat::IEEEdouble() &&
+         N->getValueAPF().convertToDouble() == -1.0;
+}]>;
+// Constant -1.0 -> 1.0 (double)
----------------
Artem-B wrote:

This transform applies to all double constants, not just 1.0/-1.0. You may want to update the comment accordingly.

Also, this defines a node transform, as opposed to node matchers above, so it would be good to separate them a bit visually, so rephrasing the comment would help with that, too.

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


More information about the llvm-commits mailing list