diff options
author | Sander de Smalen <sander.desmalen@arm.com> | 2019-06-13 09:37:38 +0000 |
---|---|---|
committer | Sander de Smalen <sander.desmalen@arm.com> | 2019-06-13 09:37:38 +0000 |
commit | 51c2fa0e2ac1ee0afdffb45ff3c2bac4bf09c3cf (patch) | |
tree | 49360c0aef3239b611cbd42593dc54c2f6470098 /llvm/lib/IR/Function.cpp | |
parent | 8d59f5370d46a2b9cb2714a3342eb58bacd52580 (diff) | |
download | bcm5719-llvm-51c2fa0e2ac1ee0afdffb45ff3c2bac4bf09c3cf.tar.gz bcm5719-llvm-51c2fa0e2ac1ee0afdffb45ff3c2bac4bf09c3cf.zip |
Improve reduction intrinsics by overloading result value.
This patch uses the mechanism from D62995 to strengthen the
definitions of the reduction intrinsics by letting the scalar
result/accumulator type be overloaded from the vector element type.
For example:
; The LLVM LangRef specifies that the scalar result must equal the
; vector element type, but this is not checked/enforced by LLVM.
declare i32 @llvm.experimental.vector.reduce.or.i32.v4i32(<4 x i32> %a)
This patch changes that into:
declare i32 @llvm.experimental.vector.reduce.or.v4i32(<4 x i32> %a)
Which has the type-constraint more explicit and causes LLVM to check
the result type with the vector element type.
Reviewers: RKSimon, arsenm, rnk, greened, aemerson
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D62996
llvm-svn: 363240
Diffstat (limited to 'llvm/lib/IR/Function.cpp')
-rw-r--r-- | llvm/lib/IR/Function.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/llvm/lib/IR/Function.cpp b/llvm/lib/IR/Function.cpp index affd85e79ee..770524feace 100644 --- a/llvm/lib/IR/Function.cpp +++ b/llvm/lib/IR/Function.cpp @@ -700,7 +700,8 @@ enum IIT_Info { IIT_STRUCT6 = 38, IIT_STRUCT7 = 39, IIT_STRUCT8 = 40, - IIT_F128 = 41 + IIT_F128 = 41, + IIT_VEC_ELEMENT = 42 }; static void DecodeIITType(unsigned &NextElt, ArrayRef<unsigned char> Infos, @@ -865,6 +866,12 @@ static void DecodeIITType(unsigned &NextElt, ArrayRef<unsigned char> Infos, DecodeIITType(NextElt, Infos, OutputTable); return; } + case IIT_VEC_ELEMENT: { + unsigned ArgInfo = (NextElt == Infos.size() ? 0 : Infos[NextElt++]); + OutputTable.push_back(IITDescriptor::get(IITDescriptor::VecElementArgument, + ArgInfo)); + return; + } } llvm_unreachable("unhandled"); } @@ -977,6 +984,12 @@ static Type *DecodeFixedType(ArrayRef<Intrinsic::IITDescriptor> &Infos, Type *EltTy = VTy->getVectorElementType(); return PointerType::getUnqual(EltTy); } + case IITDescriptor::VecElementArgument: { + Type *Ty = Tys[D.getArgumentNumber()]; + if (VectorType *VTy = dyn_cast<VectorType>(Ty)) + return VTy->getElementType(); + llvm_unreachable("Expected an argument of Vector Type"); + } case IITDescriptor::VecOfAnyPtrsToElt: // Return the overloaded type (which determines the pointers address space) return Tys[D.getOverloadArgNumber()]; @@ -1237,6 +1250,12 @@ static bool matchIntrinsicType( return ThisArgEltTy->getElementType() != ReferenceType->getVectorElementType(); } + case IITDescriptor::VecElementArgument: { + if (D.getArgumentNumber() >= ArgTys.size()) + return IsDeferredCheck ? true : DeferCheck(Ty); + auto *ReferenceType = dyn_cast<VectorType>(ArgTys[D.getArgumentNumber()]); + return !ReferenceType || Ty != ReferenceType->getElementType(); + } } llvm_unreachable("unhandled"); } |