1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 11:13:28 +01:00

[CostModel][X86][XOP] Added XOP costmodel for BITREVERSE

Now that we have a nice fast VPPERM solution. Added framework for future intrinsic costs as well.

llvm-svn: 270537
This commit is contained in:
Simon Pilgrim 2016-05-24 08:17:50 +00:00
parent 10ec45b080
commit de7240c8f6
3 changed files with 61 additions and 13 deletions

View File

@ -917,6 +917,49 @@ int X86TTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy) {
return BaseT::getCmpSelInstrCost(Opcode, ValTy, CondTy);
}
int X86TTIImpl::getIntrinsicInstrCost(Intrinsic::ID IID, Type *RetTy,
ArrayRef<Type *> Tys, FastMathFlags FMF) {
static const CostTblEntry XOPCostTbl[] = {
{ ISD::BITREVERSE, MVT::v4i64, 4 },
{ ISD::BITREVERSE, MVT::v8i32, 4 },
{ ISD::BITREVERSE, MVT::v16i16, 4 },
{ ISD::BITREVERSE, MVT::v32i8, 4 },
{ ISD::BITREVERSE, MVT::v2i64, 1 },
{ ISD::BITREVERSE, MVT::v4i32, 1 },
{ ISD::BITREVERSE, MVT::v8i16, 1 },
{ ISD::BITREVERSE, MVT::v16i8, 1 },
{ ISD::BITREVERSE, MVT::i64, 3 },
{ ISD::BITREVERSE, MVT::i32, 3 },
{ ISD::BITREVERSE, MVT::i16, 3 },
{ ISD::BITREVERSE, MVT::i8, 3 }
};
unsigned ISD = ISD::DELETED_NODE;
switch (IID) {
default:
break;
case Intrinsic::bitreverse:
ISD = ISD::BITREVERSE;
break;
}
// Legalize the type.
std::pair<int, MVT> LT = TLI->getTypeLegalizationCost(DL, RetTy);
MVT MTy = LT.second;
// Attempt to lookup cost.
if (ST->hasXOP())
if (const auto *Entry = CostTableLookup(XOPCostTbl, ISD, MTy))
return LT.first * Entry->Cost;
return BaseT::getIntrinsicInstrCost(IID, RetTy, Tys, FMF);
}
int X86TTIImpl::getIntrinsicInstrCost(Intrinsic::ID IID, Type *RetTy,
ArrayRef<Value *> Args, FastMathFlags FMF) {
return BaseT::getIntrinsicInstrCost(IID, RetTy, Args, FMF);
}
int X86TTIImpl::getVectorInstrCost(unsigned Opcode, Type *Val, unsigned Index) {
assert(Val->isVectorTy() && "This must be a vector type");
@ -1320,7 +1363,7 @@ int X86TTIImpl::getGSVectorCost(unsigned Opcode, Type *SrcVTy, Value *Ptr,
GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(Ptr);
if (IndexSize < 64 || !GEP)
return IndexSize;
unsigned NumOfVarIndices = 0;
Value *Ptrs = GEP->getPointerOperand();
if (Ptrs->getType()->isVectorTy() && !getSplatValue(Ptrs))

View File

@ -80,6 +80,11 @@ public:
bool VariableMask, unsigned Alignment);
int getAddressComputationCost(Type *PtrTy, bool IsComplex);
int getIntrinsicInstrCost(Intrinsic::ID IID, Type *RetTy,
ArrayRef<Type *> Tys, FastMathFlags FMF);
int getIntrinsicInstrCost(Intrinsic::ID IID, Type *RetTy,
ArrayRef<Value *> Args, FastMathFlags FMF);
int getReductionCost(unsigned Opcode, Type *Ty, bool IsPairwiseForm);
int getIntImmCost(int64_t);

View File

@ -18,7 +18,7 @@ define i64 @var_bitreverse_i64(i64 %a) {
; SSE42: Found an estimated cost of 1 for instruction: %bitreverse
; AVX: Found an estimated cost of 1 for instruction: %bitreverse
; AVX2: Found an estimated cost of 1 for instruction: %bitreverse
; XOP: Found an estimated cost of 1 for instruction: %bitreverse
; XOP: Found an estimated cost of 3 for instruction: %bitreverse
%bitreverse = call i64 @llvm.bitreverse.i64(i64 %a)
ret i64 %bitreverse
}
@ -29,7 +29,7 @@ define i32 @var_bitreverse_i32(i32 %a) {
; SSE42: Found an estimated cost of 1 for instruction: %bitreverse
; AVX: Found an estimated cost of 1 for instruction: %bitreverse
; AVX2: Found an estimated cost of 1 for instruction: %bitreverse
; XOP: Found an estimated cost of 1 for instruction: %bitreverse
; XOP: Found an estimated cost of 3 for instruction: %bitreverse
%bitreverse = call i32 @llvm.bitreverse.i32(i32 %a)
ret i32 %bitreverse
}
@ -40,7 +40,7 @@ define i16 @var_bitreverse_i16(i16 %a) {
; SSE42: Found an estimated cost of 1 for instruction: %bitreverse
; AVX: Found an estimated cost of 1 for instruction: %bitreverse
; AVX2: Found an estimated cost of 1 for instruction: %bitreverse
; XOP: Found an estimated cost of 1 for instruction: %bitreverse
; XOP: Found an estimated cost of 3 for instruction: %bitreverse
%bitreverse = call i16 @llvm.bitreverse.i16(i16 %a)
ret i16 %bitreverse
}
@ -51,7 +51,7 @@ define i8 @var_bitreverse_i8(i8 %a) {
; SSE42: Found an estimated cost of 1 for instruction: %bitreverse
; AVX: Found an estimated cost of 1 for instruction: %bitreverse
; AVX2: Found an estimated cost of 1 for instruction: %bitreverse
; XOP: Found an estimated cost of 1 for instruction: %bitreverse
; XOP: Found an estimated cost of 3 for instruction: %bitreverse
%bitreverse = call i8 @llvm.bitreverse.i8(i8 %a)
ret i8 %bitreverse
}
@ -74,7 +74,7 @@ define <2 x i64> @var_bitreverse_v2i64(<2 x i64> %a) {
; SSE42: Found an estimated cost of 6 for instruction: %bitreverse
; AVX: Found an estimated cost of 6 for instruction: %bitreverse
; AVX2: Found an estimated cost of 6 for instruction: %bitreverse
; XOP: Found an estimated cost of 6 for instruction: %bitreverse
; XOP: Found an estimated cost of 1 for instruction: %bitreverse
%bitreverse = call <2 x i64> @llvm.bitreverse.v2i64(<2 x i64> %a)
ret <2 x i64> %bitreverse
}
@ -85,7 +85,7 @@ define <4 x i64> @var_bitreverse_v4i64(<4 x i64> %a) {
; SSE42: Found an estimated cost of 12 for instruction: %bitreverse
; AVX: Found an estimated cost of 12 for instruction: %bitreverse
; AVX2: Found an estimated cost of 12 for instruction: %bitreverse
; XOP: Found an estimated cost of 12 for instruction: %bitreverse
; XOP: Found an estimated cost of 4 for instruction: %bitreverse
%bitreverse = call <4 x i64> @llvm.bitreverse.v4i64(<4 x i64> %a)
ret <4 x i64> %bitreverse
}
@ -96,7 +96,7 @@ define <4 x i32> @var_bitreverse_v4i32(<4 x i32> %a) {
; SSE42: Found an estimated cost of 12 for instruction: %bitreverse
; AVX: Found an estimated cost of 12 for instruction: %bitreverse
; AVX2: Found an estimated cost of 12 for instruction: %bitreverse
; XOP: Found an estimated cost of 12 for instruction: %bitreverse
; XOP: Found an estimated cost of 1 for instruction: %bitreverse
%bitreverse = call <4 x i32> @llvm.bitreverse.v4i32(<4 x i32> %a)
ret <4 x i32> %bitreverse
}
@ -107,7 +107,7 @@ define <8 x i32> @var_bitreverse_v8i32(<8 x i32> %a) {
; SSE42: Found an estimated cost of 24 for instruction: %bitreverse
; AVX: Found an estimated cost of 24 for instruction: %bitreverse
; AVX2: Found an estimated cost of 24 for instruction: %bitreverse
; XOP: Found an estimated cost of 24 for instruction: %bitreverse
; XOP: Found an estimated cost of 4 for instruction: %bitreverse
%bitreverse = call <8 x i32> @llvm.bitreverse.v8i32(<8 x i32> %a)
ret <8 x i32> %bitreverse
}
@ -118,7 +118,7 @@ define <8 x i16> @var_bitreverse_v8i16(<8 x i16> %a) {
; SSE42: Found an estimated cost of 24 for instruction: %bitreverse
; AVX: Found an estimated cost of 24 for instruction: %bitreverse
; AVX2: Found an estimated cost of 24 for instruction: %bitreverse
; XOP: Found an estimated cost of 24 for instruction: %bitreverse
; XOP: Found an estimated cost of 1 for instruction: %bitreverse
%bitreverse = call <8 x i16> @llvm.bitreverse.v8i16(<8 x i16> %a)
ret <8 x i16> %bitreverse
}
@ -129,7 +129,7 @@ define <16 x i16> @var_bitreverse_v16i16(<16 x i16> %a) {
; SSE42: Found an estimated cost of 48 for instruction: %bitreverse
; AVX: Found an estimated cost of 48 for instruction: %bitreverse
; AVX2: Found an estimated cost of 48 for instruction: %bitreverse
; XOP: Found an estimated cost of 48 for instruction: %bitreverse
; XOP: Found an estimated cost of 4 for instruction: %bitreverse
%bitreverse = call <16 x i16> @llvm.bitreverse.v16i16(<16 x i16> %a)
ret <16 x i16> %bitreverse
}
@ -140,7 +140,7 @@ define <16 x i8> @var_bitreverse_v16i8(<16 x i8> %a) {
; SSE42: Found an estimated cost of 48 for instruction: %bitreverse
; AVX: Found an estimated cost of 48 for instruction: %bitreverse
; AVX2: Found an estimated cost of 48 for instruction: %bitreverse
; XOP: Found an estimated cost of 48 for instruction: %bitreverse
; XOP: Found an estimated cost of 1 for instruction: %bitreverse
%bitreverse = call <16 x i8> @llvm.bitreverse.v16i8(<16 x i8> %a)
ret <16 x i8> %bitreverse
}
@ -151,7 +151,7 @@ define <32 x i8> @var_bitreverse_v32i8(<32 x i8> %a) {
; SSE42: Found an estimated cost of 96 for instruction: %bitreverse
; AVX: Found an estimated cost of 96 for instruction: %bitreverse
; AVX2: Found an estimated cost of 96 for instruction: %bitreverse
; XOP: Found an estimated cost of 96 for instruction: %bitreverse
; XOP: Found an estimated cost of 4 for instruction: %bitreverse
%bitreverse = call <32 x i8> @llvm.bitreverse.v32i8(<32 x i8> %a)
ret <32 x i8> %bitreverse
}