Skip to content

Commit 60745fb

Browse files
committed
[VP] llvm.vp.fneg intrinsic and LangRef
Reviewed By: frasercrmck Differential Revision: https://reviews.llvm.org/D119262
1 parent 62a775f commit 60745fb

File tree

4 files changed

+66
-6
lines changed

4 files changed

+66
-6
lines changed

llvm/docs/LangRef.rst

Lines changed: 53 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18599,7 +18599,7 @@ operation.
1859918599
Semantics:
1860018600
""""""""""
1860118601

18602-
The '``llvm.vp.fadd``' intrinsic performs floating-point addition (:ref:`add <i_fadd>`)
18602+
The '``llvm.vp.fadd``' intrinsic performs floating-point addition (:ref:`fadd <i_fadd>`)
1860318603
of the first and second vector operand on each enabled lane. The result on
1860418604
disabled lanes is undefined. The operation is performed in the default
1860518605
floating-point environment.
@@ -18648,7 +18648,7 @@ operation.
1864818648
Semantics:
1864918649
""""""""""
1865018650

18651-
The '``llvm.vp.fsub``' intrinsic performs floating-point subtraction (:ref:`add <i_fsub>`)
18651+
The '``llvm.vp.fsub``' intrinsic performs floating-point subtraction (:ref:`fsub <i_fsub>`)
1865218652
of the first and second vector operand on each enabled lane. The result on
1865318653
disabled lanes is undefined. The operation is performed in the default
1865418654
floating-point environment.
@@ -18697,7 +18697,7 @@ operation.
1869718697
Semantics:
1869818698
""""""""""
1869918699

18700-
The '``llvm.vp.fmul``' intrinsic performs floating-point multiplication (:ref:`add <i_fmul>`)
18700+
The '``llvm.vp.fmul``' intrinsic performs floating-point multiplication (:ref:`fmul <i_fmul>`)
1870118701
of the first and second vector operand on each enabled lane. The result on
1870218702
disabled lanes is undefined. The operation is performed in the default
1870318703
floating-point environment.
@@ -18746,7 +18746,7 @@ operation.
1874618746
Semantics:
1874718747
""""""""""
1874818748

18749-
The '``llvm.vp.fdiv``' intrinsic performs floating-point division (:ref:`add <i_fdiv>`)
18749+
The '``llvm.vp.fdiv``' intrinsic performs floating-point division (:ref:`fdiv <i_fdiv>`)
1875018750
of the first and second vector operand on each enabled lane. The result on
1875118751
disabled lanes is undefined. The operation is performed in the default
1875218752
floating-point environment.
@@ -18795,7 +18795,7 @@ operation.
1879518795
Semantics:
1879618796
""""""""""
1879718797

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

1881718865
'``llvm.vp.fma.*``' Intrinsics

llvm/include/llvm/IR/Intrinsics.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,6 +1505,11 @@ let IntrProperties =
15051505
LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
15061506
llvm_i32_ty]>;
15071507

1508+
def int_vp_fneg : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
1509+
[ LLVMMatchType<0>,
1510+
LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
1511+
llvm_i32_ty]>;
1512+
15081513
def int_vp_fma : DefaultAttrsIntrinsic<[ llvm_anyvector_ty ],
15091514
[ LLVMMatchType<0>,
15101515
LLVMMatchType<0>,

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.fneg(x,mask,vlen)
215+
BEGIN_REGISTER_VP(vp_fneg, 1, 2, VP_FNEG, -1)
216+
VP_PROPERTY_FUNCTIONAL_OPC(FNeg)
217+
END_REGISTER_VP(vp_fneg, VP_FNEG)
218+
214219
// llvm.vp.fma(x,y,z,mask,vlen)
215220
BEGIN_REGISTER_VP(vp_fma, 3, 4, VP_FMA, -1)
216221
VP_PROPERTY_CONSTRAINEDFP(1, 1, experimental_constrained_fma)

llvm/unittests/IR/VPIntrinsicTest.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ 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.fneg.v8f32(<8 x float>, <8 x i1>, "
55+
"i32)";
5456
Str << " declare <8 x float> @llvm.vp.fma.v8f32(<8 x float>, <8 x float>, "
55-
"<8 x float>, <8 x i1>, i32) ";
57+
"<8 x float>, <8 x i1>, i32) ";
5658

5759
Str << " declare void @llvm.vp.store.v8i32.p0v8i32(<8 x i32>, <8 x i32>*, "
5860
"<8 x i1>, i32) ";

0 commit comments

Comments
 (0)