Skip to content

Move stepvector intrinsic out of experimental namespace #98043

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions llvm/docs/LangRef.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19581,27 +19581,27 @@ vector <N x eltty>, imm is a signed integer constant in the range
-N <= imm < N. For a scalable vector <vscale x N x eltty>, imm is a signed
integer constant in the range -X <= imm < X where X=vscale_range_min * N.

'``llvm.experimental.stepvector``' Intrinsic
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
'``llvm.stepvector``' Intrinsic
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

This is an overloaded intrinsic. You can use ``llvm.experimental.stepvector``
This is an overloaded intrinsic. You can use ``llvm.stepvector``
to generate a vector whose lane values comprise the linear sequence
<0, 1, 2, ...>. It is primarily intended for scalable vectors.

::

declare <vscale x 4 x i32> @llvm.experimental.stepvector.nxv4i32()
declare <vscale x 8 x i16> @llvm.experimental.stepvector.nxv8i16()
declare <vscale x 4 x i32> @llvm.stepvector.nxv4i32()
declare <vscale x 8 x i16> @llvm.stepvector.nxv8i16()

The '``llvm.experimental.stepvector``' intrinsics are used to create vectors
The '``llvm.stepvector``' intrinsics are used to create vectors
of integers whose elements contain a linear sequence of values starting from 0
with a step of 1. This experimental intrinsic can only be used for vectors
with integer elements that are at least 8 bits in size. If the sequence value
exceeds the allowed limit for the element type then the result for that lane is
undefined.
with a step of 1. This intrinsic can only be used for vectors with integer
elements that are at least 8 bits in size. If the sequence value exceeds
the allowed limit for the element type then the result for that lane is
a poison value.

These intrinsics work for both fixed and scalable vectors. While this intrinsic
is marked as experimental, the recommended way to express this operation for
supports all vector types, the recommended way to express this operation for
fixed-width vectors is still to generate a constant vector instead.


Expand Down
1 change: 1 addition & 0 deletions llvm/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ Changes to the LLVM IR

* The ``x86_mmx`` IR type has been removed. It will be translated to
the standard vector type ``<1 x i64>`` in bitcode upgrade.
* Renamed ``llvm.experimental.stepvector`` intrinsic to ``llvm.stepvector``.

Changes to LLVM infrastructure
------------------------------
Expand Down
6 changes: 3 additions & 3 deletions llvm/include/llvm/CodeGen/BasicTTIImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1641,7 +1641,7 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
return thisT()->getStridedMemoryOpCost(Instruction::Load, RetTy, Ptr,
VarMask, Alignment, CostKind, I);
}
case Intrinsic::experimental_stepvector: {
case Intrinsic::stepvector: {
if (isa<ScalableVectorType>(RetTy))
return BaseT::getIntrinsicInstrCost(ICA, CostKind);
// The cost of materialising a constant integer vector.
Expand Down Expand Up @@ -1789,8 +1789,8 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
Type *NewVecTy = VectorType::get(
NewEltTy, cast<VectorType>(Args[0]->getType())->getElementCount());

IntrinsicCostAttributes StepVecAttrs(Intrinsic::experimental_stepvector,
NewVecTy, {}, FMF);
IntrinsicCostAttributes StepVecAttrs(Intrinsic::stepvector, NewVecTy, {},
FMF);
InstructionCost Cost =
thisT()->getIntrinsicInstrCost(StepVecAttrs, CostKind);

Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/IR/Intrinsics.td
Original file line number Diff line number Diff line change
Expand Up @@ -1846,8 +1846,8 @@ def int_threadlocal_address : DefaultAttrsIntrinsic<[llvm_anyptr_ty], [LLVMMatch
[NonNull<RetIndex>, NonNull<ArgIndex<0>>,
IntrNoMem, IntrSpeculatable, IntrWillReturn]>;

def int_experimental_stepvector : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
[], [IntrNoMem]>;
def int_stepvector : DefaultAttrsIntrinsic<[llvm_anyvector_ty],
[], [IntrNoMem]>;

//===---------------- Vector Predication Intrinsics --------------===//
// Memory Intrinsics
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7781,7 +7781,7 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
case Intrinsic::experimental_deoptimize:
LowerDeoptimizeCall(&I);
return;
case Intrinsic::experimental_stepvector:
case Intrinsic::stepvector:
visitStepVector(I);
return;
case Intrinsic::vector_reduce_fadd:
Expand Down
7 changes: 7 additions & 0 deletions llvm/lib/IR/AutoUpgrade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,13 @@ static bool upgradeIntrinsicFunction1(Function *F, Function *&NewFn,
}
break; // No other 'experimental.vector.*'.
}
if (Name.consume_front("experimental.stepvector.")) {
Intrinsic::ID ID = Intrinsic::stepvector;
rename(F);
NewFn = Intrinsic::getDeclaration(F->getParent(), ID,
F->getFunctionType()->getReturnType());
return true;
}
break; // No other 'e*'.
case 'f':
if (Name.starts_with("flt.rounds")) {
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/IR/IRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ Value *IRBuilderBase::CreateStepVector(Type *DstType, const Twine &Name) {
if (STy->getScalarSizeInBits() < 8)
StepVecType =
VectorType::get(getInt8Ty(), cast<ScalableVectorType>(DstType));
Value *Res = CreateIntrinsic(Intrinsic::experimental_stepvector,
{StepVecType}, {}, nullptr, Name);
Value *Res = CreateIntrinsic(Intrinsic::stepvector, {StepVecType}, {},
nullptr, Name);
if (StepVecType != DstType)
Res = CreateTrunc(Res, DstType);
return Res;
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/IR/Verifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6097,11 +6097,11 @@ void Verifier::visitIntrinsicCall(Intrinsic::ID ID, CallBase &Call) {
&Call);
break;
}
case Intrinsic::experimental_stepvector: {
case Intrinsic::stepvector: {
VectorType *VecTy = dyn_cast<VectorType>(Call.getType());
Check(VecTy && VecTy->getScalarType()->isIntegerTy() &&
VecTy->getScalarSizeInBits() >= 8,
"experimental_stepvector only supported for vectors of integers "
"stepvector only supported for vectors of integers "
"with a bitwidth of at least 8.",
&Call);
break;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ AArch64TTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
return LT.first;
break;
}
case Intrinsic::experimental_stepvector: {
case Intrinsic::stepvector: {
InstructionCost Cost = 1; // Cost of the `index' instruction
auto LT = getTypeLegalizationCost(RetTy);
// Legalisation of illegal vectors involves an `index' instruction plus
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ static std::pair<Value *, Value *> matchStridedStart(Value *Start,
return matchStridedConstant(StartC);

// Base case, start is a stepvector
if (match(Start, m_Intrinsic<Intrinsic::experimental_stepvector>())) {
if (match(Start, m_Intrinsic<Intrinsic::stepvector>())) {
auto *Ty = Start->getType()->getScalarType();
return std::make_pair(ConstantInt::get(Ty, 0), ConstantInt::get(Ty, 1));
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -929,7 +929,7 @@ RISCVTTIImpl::getIntrinsicInstrCost(const IntrinsicCostAttributes &ICA,
break;
}
// TODO: add more intrinsic
case Intrinsic::experimental_stepvector: {
case Intrinsic::stepvector: {
auto LT = getTypeLegalizationCost(RetTy);
// Legalisation of illegal types involves an `index' instruction plus
// (LT.first - 1) vector adds.
Expand Down
5 changes: 2 additions & 3 deletions llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static bool cheapToScalarize(Value *V, Value *EI) {
if (auto *C = dyn_cast<Constant>(V))
return CEI || C->getSplatValue();

if (CEI && match(V, m_Intrinsic<Intrinsic::experimental_stepvector>())) {
if (CEI && match(V, m_Intrinsic<Intrinsic::stepvector>())) {
ElementCount EC = cast<VectorType>(V->getType())->getElementCount();
// Index needs to be lower than the minimum size of the vector, because
// for scalable vector, the vector size is known at run time.
Expand Down Expand Up @@ -433,8 +433,7 @@ Instruction *InstCombinerImpl::visitExtractElementInst(ExtractElementInst &EI) {
Intrinsic::ID IID = II->getIntrinsicID();
// Index needs to be lower than the minimum size of the vector, because
// for scalable vector, the vector size is known at run time.
if (IID == Intrinsic::experimental_stepvector &&
IndexC->getValue().ult(NumElts)) {
if (IID == Intrinsic::stepvector && IndexC->getValue().ult(NumElts)) {
Type *Ty = EI.getType();
unsigned BitWidth = Ty->getIntegerBitWidth();
Value *Idx;
Expand Down
36 changes: 18 additions & 18 deletions llvm/test/Analysis/CostModel/AArch64/neon-stepvector.ll
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,36 @@ target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
; Check icmp for legal integer vectors.
define void @stepvector_legal_int() {
; CHECK-LABEL: 'stepvector_legal_int'
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %1 = call <2 x i64> @llvm.experimental.stepvector.v2i64()
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %2 = call <4 x i32> @llvm.experimental.stepvector.v4i32()
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %3 = call <8 x i16> @llvm.experimental.stepvector.v8i16()
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %4 = call <16 x i8> @llvm.experimental.stepvector.v16i8()
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %1 = call <2 x i64> @llvm.stepvector.v2i64()
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %2 = call <4 x i32> @llvm.stepvector.v4i32()
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %3 = call <8 x i16> @llvm.stepvector.v8i16()
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %4 = call <16 x i8> @llvm.stepvector.v16i8()
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
;
%1 = call <2 x i64> @llvm.experimental.stepvector.v2i64()
%2 = call <4 x i32> @llvm.experimental.stepvector.v4i32()
%3 = call <8 x i16> @llvm.experimental.stepvector.v8i16()
%4 = call <16 x i8> @llvm.experimental.stepvector.v16i8()
%1 = call <2 x i64> @llvm.stepvector.v2i64()
%2 = call <4 x i32> @llvm.stepvector.v4i32()
%3 = call <8 x i16> @llvm.stepvector.v8i16()
%4 = call <16 x i8> @llvm.stepvector.v16i8()
ret void
}

; Check icmp for an illegal integer vector.
define void @stepvector_illegal_int() {
; CHECK-LABEL: 'stepvector_illegal_int'
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %1 = call <4 x i64> @llvm.experimental.stepvector.v4i64()
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %2 = call <16 x i32> @llvm.experimental.stepvector.v16i32()
; CHECK-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %1 = call <4 x i64> @llvm.stepvector.v4i64()
; CHECK-NEXT: Cost Model: Found an estimated cost of 4 for instruction: %2 = call <16 x i32> @llvm.stepvector.v16i32()
; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: ret void
;
%1 = call <4 x i64> @llvm.experimental.stepvector.v4i64()
%2 = call <16 x i32> @llvm.experimental.stepvector.v16i32()
%1 = call <4 x i64> @llvm.stepvector.v4i64()
%2 = call <16 x i32> @llvm.stepvector.v16i32()
ret void
}


declare <2 x i64> @llvm.experimental.stepvector.v2i64()
declare <4 x i32> @llvm.experimental.stepvector.v4i32()
declare <8 x i16> @llvm.experimental.stepvector.v8i16()
declare <16 x i8> @llvm.experimental.stepvector.v16i8()
declare <2 x i64> @llvm.stepvector.v2i64()
declare <4 x i32> @llvm.stepvector.v4i32()
declare <8 x i16> @llvm.stepvector.v8i16()
declare <16 x i8> @llvm.stepvector.v16i8()

declare <4 x i64> @llvm.experimental.stepvector.v4i64()
declare <16 x i32> @llvm.experimental.stepvector.v16i32()
declare <4 x i64> @llvm.stepvector.v4i64()
declare <16 x i32> @llvm.stepvector.v16i32()
36 changes: 18 additions & 18 deletions llvm/test/Analysis/CostModel/AArch64/sve-stepvector.ll
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,32 @@ target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
; Check icmp for legal integer vectors.
define void @stepvector_legal_int() {
; CHECK-LABEL: 'stepvector_legal_int'
; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %1 = call <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %2 = call <vscale x 4 x i32> @llvm.experimental.stepvector.nxv4i32()
; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %3 = call <vscale x 8 x i16> @llvm.experimental.stepvector.nxv8i16()
; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %4 = call <vscale x 16 x i8> @llvm.experimental.stepvector.nxv16i8()
%1 = call <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
%2 = call <vscale x 4 x i32> @llvm.experimental.stepvector.nxv4i32()
%3 = call <vscale x 8 x i16> @llvm.experimental.stepvector.nxv8i16()
%4 = call <vscale x 16 x i8> @llvm.experimental.stepvector.nxv16i8()
; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %1 = call <vscale x 2 x i64> @llvm.stepvector.nxv2i64()
; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %2 = call <vscale x 4 x i32> @llvm.stepvector.nxv4i32()
; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %3 = call <vscale x 8 x i16> @llvm.stepvector.nxv8i16()
; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %4 = call <vscale x 16 x i8> @llvm.stepvector.nxv16i8()
%1 = call <vscale x 2 x i64> @llvm.stepvector.nxv2i64()
%2 = call <vscale x 4 x i32> @llvm.stepvector.nxv4i32()
%3 = call <vscale x 8 x i16> @llvm.stepvector.nxv8i16()
%4 = call <vscale x 16 x i8> @llvm.stepvector.nxv16i8()
ret void
}

; Check icmp for an illegal integer vector.
define void @stepvector_illegal_int() {
; CHECK-LABEL: 'stepvector_illegal_int'
; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %1 = call <vscale x 4 x i64> @llvm.experimental.stepvector.nxv4i64()
; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %2 = call <vscale x 16 x i32> @llvm.experimental.stepvector.nxv16i32()
%1 = call <vscale x 4 x i64> @llvm.experimental.stepvector.nxv4i64()
%2 = call <vscale x 16 x i32> @llvm.experimental.stepvector.nxv16i32()
; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %1 = call <vscale x 4 x i64> @llvm.stepvector.nxv4i64()
; CHECK: Cost Model: Found an estimated cost of 4 for instruction: %2 = call <vscale x 16 x i32> @llvm.stepvector.nxv16i32()
%1 = call <vscale x 4 x i64> @llvm.stepvector.nxv4i64()
%2 = call <vscale x 16 x i32> @llvm.stepvector.nxv16i32()
ret void
}


declare <vscale x 2 x i64> @llvm.experimental.stepvector.nxv2i64()
declare <vscale x 4 x i32> @llvm.experimental.stepvector.nxv4i32()
declare <vscale x 8 x i16> @llvm.experimental.stepvector.nxv8i16()
declare <vscale x 16 x i8> @llvm.experimental.stepvector.nxv16i8()
declare <vscale x 2 x i64> @llvm.stepvector.nxv2i64()
declare <vscale x 4 x i32> @llvm.stepvector.nxv4i32()
declare <vscale x 8 x i16> @llvm.stepvector.nxv8i16()
declare <vscale x 16 x i8> @llvm.stepvector.nxv16i8()

declare <vscale x 4 x i64> @llvm.experimental.stepvector.nxv4i64()
declare <vscale x 16 x i32> @llvm.experimental.stepvector.nxv16i32()
declare <vscale x 4 x i64> @llvm.stepvector.nxv4i64()
declare <vscale x 16 x i32> @llvm.stepvector.nxv16i32()
Loading
Loading