diff options
author | Jonas Paulsson <paulsson@linux.vnet.ibm.com> | 2018-11-01 09:01:51 +0000 |
---|---|---|
committer | Jonas Paulsson <paulsson@linux.vnet.ibm.com> | 2018-11-01 09:01:51 +0000 |
commit | f15a53bc81377aa0c5e3864fd9cb41fa667a011d (patch) | |
tree | 52d5b8bbfc8e0e02ef4b501d5c579f5c5f0cac13 /llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp | |
parent | 1bb9aea56bdbac6fa8cb28d18a0b6c9879bee12b (diff) | |
download | bcm5719-llvm-f15a53bc81377aa0c5e3864fd9cb41fa667a011d.tar.gz bcm5719-llvm-f15a53bc81377aa0c5e3864fd9cb41fa667a011d.zip |
[SystemZ::TTI] Accurate costs for i1->double vector conversions
This factors out a new method getBoolVecToIntConversionCost() containing the
code for vector sext/zext of i1, in order to reuse it for i1 to double vector
conversions.
Review: Ulrich Weigand
https://reviews.llvm.org/D53923
llvm-svn: 345817
Diffstat (limited to 'llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp')
-rw-r--r-- | llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp b/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp index 94db56e3738..18333bfcc11 100644 --- a/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp +++ b/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp @@ -635,6 +635,25 @@ static Type *getCmpOpsType(const Instruction *I, unsigned VF = 1) { return nullptr; } +// Get the cost of converting a boolean vector to a vector with same width +// and element size as Dst, plus the cost of zero extending if needed. +unsigned SystemZTTIImpl:: +getBoolVecToIntConversionCost(unsigned Opcode, Type *Dst, + const Instruction *I) { + assert (Dst->isVectorTy()); + unsigned VF = Dst->getVectorNumElements(); + unsigned Cost = 0; + // If we know what the widths of the compared operands, get any cost of + // converting it to match Dst. Otherwise assume same widths. + Type *CmpOpTy = ((I != nullptr) ? getCmpOpsType(I, VF) : nullptr); + if (CmpOpTy != nullptr) + Cost = getVectorBitmaskConversionCost(CmpOpTy, Dst); + if (Opcode == Instruction::ZExt || Opcode == Instruction::UIToFP) + // One 'vn' per dst vector with an immediate mask. + Cost += getNumVectorRegs(Dst); + return Cost; +} + int SystemZTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, const Instruction *I) { unsigned DstScalarBits = Dst->getScalarSizeInBits(); @@ -666,19 +685,8 @@ int SystemZTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, return (NumUnpacks * NumDstVectors) + NumSrcVectorOps; } - else if (SrcScalarBits == 1) { - // This should be extension of a compare i1 result. - // If we know what the widths of the compared operands, get the - // cost of converting it to Dst. Otherwise assume same widths. - unsigned Cost = 0; - Type *CmpOpTy = ((I != nullptr) ? getCmpOpsType(I, VF) : nullptr); - if (CmpOpTy != nullptr) - Cost = getVectorBitmaskConversionCost(CmpOpTy, Dst); - if (Opcode == Instruction::ZExt) - // One 'vn' per dst vector with an immediate mask. - Cost += NumDstVectors; - return Cost; - } + else if (SrcScalarBits == 1) + return getBoolVecToIntConversionCost(Opcode, Dst, I); } if (Opcode == Instruction::SIToFP || Opcode == Instruction::UIToFP || @@ -687,8 +695,13 @@ int SystemZTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, // (seems to miss on differentiating on scalar/vector types). // Only 64 bit vector conversions are natively supported. - if (SrcScalarBits == 64 && DstScalarBits == 64) - return NumDstVectors; + if (DstScalarBits == 64) { + if (SrcScalarBits == 64) + return NumDstVectors; + + if (SrcScalarBits == 1) + return getBoolVecToIntConversionCost(Opcode, Dst, I) + NumDstVectors; + } // Return the cost of multiple scalar invocation plus the cost of // inserting and extracting the values. Base implementation does not |