Skip to content

Commit cef177d

Browse files
committed
[VP] llvm.vp.fma intrinsic and LangRef
Differential Revision: https://reviews.llvm.org/D119185
1 parent 74e9090 commit cef177d

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

llvm/docs/LangRef.rst

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18812,6 +18812,54 @@ Examples:
1881218812
%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> undef
1881318813

1881418814

18815+
.. _int_vp_fma:
18816+
18817+
'``llvm.vp.fma.*``' Intrinsics
18818+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
18819+
18820+
Syntax:
18821+
"""""""
18822+
This is an overloaded intrinsic.
18823+
18824+
::
18825+
18826+
declare <16 x float> @llvm.vp.fma.v16f32 (<16 x float> <left_op>, <16 x float> <middle_op>, <16 x float> <right_op>, <16 x i1> <mask>, i32 <vector_length>)
18827+
declare <vscale x 4 x float> @llvm.vp.fma.nxv4f32 (<vscale x 4 x float> <left_op>, <vscale x 4 x float> <middle_op>, <vscale x 4 x float> <right_op>, <vscale x 4 x i1> <mask>, i32 <vector_length>)
18828+
declare <256 x double> @llvm.vp.fma.v256f64 (<256 x double> <left_op>, <256 x double> <middle_op>, <256 x double> <right_op>, <256 x i1> <mask>, i32 <vector_length>)
18829+
18830+
Overview:
18831+
"""""""""
18832+
18833+
Predicated floating-point fused multiply-add of two vectors of floating-point values.
18834+
18835+
18836+
Arguments:
18837+
""""""""""
18838+
18839+
The first three operands and the result have the same vector of floating-point type. The
18840+
fourth operand is the vector mask and has the same number of elements as the
18841+
result vector type. The fifth operand is the explicit vector length of the
18842+
operation.
18843+
18844+
Semantics:
18845+
""""""""""
18846+
18847+
The '``llvm.vp.fma``' intrinsic performs floating-point fused multiply-add (:ref:`llvm.fma <int_fma>`)
18848+
of the first, second, and third vector operand on each enabled lane. The result on
18849+
disabled lanes is undefined. The operation is performed in the default
18850+
floating-point environment.
18851+
18852+
Examples:
18853+
"""""""""
18854+
18855+
.. code-block:: llvm
18856+
18857+
%r = call <4 x float> @llvm.vp.fma.v4f32(<4 x float> %a, <4 x float> %b, <4 x float> %c, <4 x i1> %mask, i32 %evl)
18858+
;; For all lanes below %evl, %r is lane-wise equivalent to %also.r
18859+
18860+
%t = call <4 x float> @llvm.fma(<4 x float> %a, <4 x float> %b, <4 x float> %c)
18861+
%also.r = select <4 x i1> %mask, <4 x float> %t, <4 x float> undef
18862+
1881518863

1881618864
.. _int_vp_reduce_add:
1881718865

llvm/include/llvm/IR/Intrinsics.td

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,6 +1504,13 @@ let IntrProperties =
15041504
LLVMMatchType<0>,
15051505
LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
15061506
llvm_i32_ty]>;
1507+
1508+
def int_vp_fma : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1509+
[ LLVMMatchType<0>,
1510+
LLVMMatchType<0>,
1511+
LLVMMatchType<0>,
1512+
LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1513+
llvm_i32_ty]>;
15071514
}
15081515
// Shuffles.
15091516
def int_vp_select : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],

llvm/include/llvm/IR/VPIntrinsics.def

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@ HELPER_REGISTER_BINARY_FP_VP(frem, VP_FREM, FRem)
211211

212212
#undef HELPER_REGISTER_BINARY_FP_VP
213213

214+
// llvm.vp.fma(x,y,z,mask,vlen)
215+
BEGIN_REGISTER_VP(vp_fma, 3, 4, VP_FMA, -1)
216+
VP_PROPERTY_CONSTRAINEDFP(1, 1, experimental_constrained_fma)
217+
END_REGISTER_VP(vp_fma, VP_FMA)
218+
214219
///// } Floating-Point Arithmetic
215220

216221
///// Memory Operations {

llvm/unittests/IR/VPIntrinsicTest.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ class VPIntrinsicTest : public testing::Test {
5151
Str << " declare <8 x float> @llvm.vp." << BinaryFPOpcode
5252
<< ".v8f32(<8 x float>, <8 x float>, <8 x i1>, i32) ";
5353

54+
Str << " declare <8 x float> @llvm.vp.fma.v8f32(<8 x float>, <8 x float>, "
55+
"<8 x float>, <8 x i1>, i32) ";
56+
5457
Str << " declare void @llvm.vp.store.v8i32.p0v8i32(<8 x i32>, <8 x i32>*, "
5558
"<8 x i1>, i32) ";
5659
Str << " declare void @llvm.vp.scatter.v8i32.v8p0i32(<8 x i32>, <8 x "

0 commit comments

Comments
 (0)