[clang] [llvm] [NVPTX] Cleanup and document nvvm.fabs intrinsics, adding f16 support (PR #135644)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 15 12:29:32 PDT 2025
================
@@ -309,6 +309,60 @@ space casted to this space), 1 is returned, otherwise 0 is returned.
Arithmetic Intrinsics
---------------------
+'``llvm.nvvm.fabs.*``' Intrinsic
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Syntax:
+"""""""
+
+.. code-block:: llvm
+
+ declare float @llvm.nvvm.fabs.f32(float %a)
+ declare double @llvm.nvvm.fabs.f64(double %a)
+ declare half @llvm.nvvm.fabs.f16(half %a)
+ declare <2 x half> @llvm.nvvm.fabs.v2f16(<2 x half> %a)
+ declare bfloat @llvm.nvvm.fabs.bf16(bfloat %a)
+ declare <2 x bfloat> @llvm.nvvm.fabs.v2bf16(<2 x bfloat> %a)
+
+Overview:
+"""""""""
+
+The '``llvm.nvvm.fabs.*``' intrinsics return the absolute value of the operand.
+
+Semantics:
+""""""""""
+
+Unlike, '``llvm.fabs.*``', these intrinsics do not perfectly preserve NaN
+values. Instead, a NaN input yeilds an unspecified NaN output. The exception to
+this rule is the double precision variant, for which NaN is preserved.
----------------
efriedma-quic wrote:
The "exception" here seems like it's letting too much of the implementation leak through... it's hard to understand the semantics, and it'll make it very hard to transition if we decide to turn this into a target-independent intrinsic. Maybe just say it's always unspecified, and juts use the regular llvm.fabs.f64 where the nan handling matters?
https://github.com/llvm/llvm-project/pull/135644
More information about the llvm-commits
mailing list