diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -15079,6 +15079,173 @@ that is used by the conditional branch controlling the loop. +Element-wise Reduction Intrinsics +--------------------------------- + +Element-wise reductions between two arguments can be expressed using the +following intrinsics. Each one takes two operands as an input and applies its +respective operation to the arguments element-wise, returning result of the +same type as the argument type. + + +'``llvm.reduce.smax.*``' Intrinsic +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Syntax: +""""""" + +This is an overloaded intrinsic. You can use ``@llvm.reduce.smax`` on any +integer bit width, or any vector of integer elements. + +:: + + declare i32 @llvm.reduce.smax.i32(i32 %a, i32 %b) + declare <4 x i32> @llvm.reduce.smax.v4i32(<4 x i32> %a, <4 x i32> %b) + +Overview: +""""""""" + +The '``llvm.reduce.smax.*``' intrinsics do a signed integer ``MAX`` +element-wise reduction between the arguments. +The return type matches the type of the arguments. + +Arguments: +"""""""""" + +The arguments (``%a`` and ``%b``) may be of any integer type, or a vector with +integer element type. The return type must match the arguments type. +``%a`` and ``%b`` are the two values that will undergo element-wise reduction. + + +'``llvm.reduce.smin.*``' Intrinsic +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Syntax: +""""""" + +This is an overloaded intrinsic. You can use ``@llvm.reduce.smin`` on any +integer bit width, or any vector of integer elements. + +:: + + declare i32 @llvm.reduce.smin.i32(i32 %a, i32 %b) + declare <4 x i32> @llvm.reduce.smin.v4i32(<4 x i32> %a, <4 x i32> %b) + +Overview: +""""""""" + +The '``llvm.reduce.smin.*``' intrinsics do a signed integer ``MIN`` +element-wise reduction between the arguments. +The return type matches the type of the arguments. + +Arguments: +"""""""""" + +The arguments (``%a`` and ``%b``) may be of any integer type, or a vector with +integer element type. The return type must match the arguments type. +``%a`` and ``%b`` are the two values that will undergo element-wise reduction. + + +'``llvm.reduce.umax.*``' Intrinsic +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Syntax: +""""""" + +This is an overloaded intrinsic. You can use ``@llvm.reduce.umax`` on any +integer bit width, or any vector of integer elements. + +:: + + declare i32 @llvm.reduce.umax.i32(i32 %a, i32 %b) + declare <4 x i32> @llvm.reduce.umax.v4i32(<4 x i32> %a, <4 x i32> %b) + +Overview: +""""""""" + +The '``llvm.reduce.umax.*``' intrinsics do a unsigned integer ``MAX`` +element-wise reduction between the arguments. +The return type matches the type of the arguments. + +Arguments: +"""""""""" + +The arguments (``%a`` and ``%b``) may be of any integer type, or a vector with +integer element type. The return type must match the arguments type. +``%a`` and ``%b`` are the two values that will undergo element-wise reduction. + + +'``llvm.reduce.umin.*``' Intrinsic +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Syntax: +""""""" + +This is an overloaded intrinsic. You can use ``@llvm.reduce.umin`` on any +integer bit width, or any vector of integer elements. + +:: + + declare i32 @llvm.reduce.umin.i32(i32 %a, i32 %b) + declare <4 x i32> @llvm.reduce.umin.v4i32(<4 x i32> %a, <4 x i32> %b) + +Overview: +""""""""" + +The '``llvm.reduce.umin.*``' intrinsics do a unsigned integer ``MIN`` +element-wise reduction between the arguments. +The return type matches the type of the arguments. + +Arguments: +"""""""""" + +The arguments (``%a`` and ``%b``) may be of any integer type, or a vector with +integer element type. The return type must match the arguments type. +``%a`` and ``%b`` are the two values that will undergo element-wise reduction. + + +'``llvm.reduce.abs.*``' Intrinsic +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Syntax: +""""""" + +This is an overloaded intrinsic. You can use ``llvm.reduce.abs`` on any +integer bit width, or any vector of integer elements. + +:: + + declare i32 @llvm.reduce.abs.i32(i32 , i1 ) + declare <4 x i32> @llvm.reduce.abs.v4i32(<4 x i32> , i1 ) + +Overview: +""""""""" + +The '``llvm.reduce.abs``' family of intrinsic functions returns absolute value +of an argument. + +Arguments: +"""""""""" + +The first argument is the value for which the absolute value is to be returned. +This argument may be of any integer type, or a vector with integer element type. +The return type must match the first argument type. + +The second argument must be a constant and is a flag to indicate whether the +result value of the '``llvm.reduce.abs``' intrinsic is a a +:ref:`poison value `if the argument is statically or dynamically +an ``INT_MIN`` value. + +Semantics: +"""""""""" + +The '``llvm.reduce.abs``' intrinsic negates the argument, or each element of +the argument if it is negative. If the argument is ``INT_MIN``, then the result +is also ``INT_MIN`` if ``is_int_min_poison == 0`` and ``poison`` otherwise. + +.. _int_overflow: + + Experimental Vector Reduction Intrinsics ----------------------------------------