diff options
author | Jonas Paulsson <paulsson@linux.vnet.ibm.com> | 2018-11-30 07:09:34 +0000 |
---|---|---|
committer | Jonas Paulsson <paulsson@linux.vnet.ibm.com> | 2018-11-30 07:09:34 +0000 |
commit | b1d014883ccd66659ccf4b8099bf33cbb4853de6 (patch) | |
tree | 12ec083c8e61742b0e481bf85f17199bd3fca3f1 /llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp | |
parent | 8cfb12b9bd042d70a365dc6d7144d944d1a64612 (diff) | |
download | bcm5719-llvm-b1d014883ccd66659ccf4b8099bf33cbb4853de6.tar.gz bcm5719-llvm-b1d014883ccd66659ccf4b8099bf33cbb4853de6.zip |
[SystemZ::TTI] i8/i16 operands extension costs revisited
Three minor changes to these extra costs:
* For ICmp instructions, instead of adding 2 all the time for extending each
operand, this is only done if that operand is neither a load or an
immediate.
* The operands extension costs for divides removed, because we now use a high
cost already for the divide (20).
* The costs for lhsr/ashr extra costs removed as this did not seem useful.
Review: Ulrich Weigand
https://reviews.llvm.org/D55053
llvm-svn: 347961
Diffstat (limited to 'llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp')
-rw-r--r-- | llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp b/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp index 32883efbdab..6155ba4b5c8 100644 --- a/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp +++ b/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp @@ -467,9 +467,6 @@ int SystemZTTIImpl::getArithmeticInstrCost( if (Opcode == Instruction::FRem) return LIBCALL_COST; - if (Opcode == Instruction::LShr || Opcode == Instruction::AShr) - return (ScalarBits >= 32 ? 1 : 2 /*ext*/); - // Or requires one instruction, although it has custom handling for i64. if (Opcode == Instruction::Or) return 1; @@ -484,12 +481,8 @@ int SystemZTTIImpl::getArithmeticInstrCost( return (SignedDivRem ? SDivPow2Cost : 1); if (DivRemConst) return DivMulSeqCost; - if (SignedDivRem) - // sext of op(s) for narrow types - return DivInstrCost + (ScalarBits < 32 ? 3 : (ScalarBits == 32 ? 1 : 0)); - if (UnsignedDivRem) - // Clearing of low 64 bit reg + sext of op(s) for narrow types + dl[g]r - return DivInstrCost + (ScalarBits < 32 ? 3 : 1); + if (SignedDivRem || UnsignedDivRem) + return DivInstrCost; } // Fallback to the default implementation. @@ -779,6 +772,18 @@ int SystemZTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, return BaseT::getCastInstrCost(Opcode, Dst, Src, I); } +// Scalar i8 / i16 operations will typically be made after first extending +// the operands to i32. +static unsigned getOperandsExtensionCost(const Instruction *I) { + unsigned ExtCost = 0; + for (Value *Op : I->operands()) + // A load of i8 or i16 sign/zero extends to i32. + if (!isa<LoadInst>(Op) && !isa<ConstantInt>(Op)) + ExtCost++; + + return ExtCost; +} + int SystemZTTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy, Type *CondTy, const Instruction *I) { if (ValTy->isVectorTy()) { @@ -835,17 +840,8 @@ int SystemZTTIImpl::getCmpSelInstrCost(unsigned Opcode, Type *ValTy, switch (Opcode) { case Instruction::ICmp: { unsigned Cost = 1; - if (ValTy->isIntegerTy() && ValTy->getScalarSizeInBits() <= 16) { - if (I != nullptr) { - // Single instruction for comparison of memory with a small immediate. - if (const LoadInst* Ld = dyn_cast<LoadInst>(I->getOperand(0))) { - const Instruction *FoldedValue = nullptr; - if (isFoldableLoad(Ld, FoldedValue)) - return Cost; - } - } - Cost += 2; // extend both operands - } + if (ValTy->isIntegerTy() && ValTy->getScalarSizeInBits() <= 16) + Cost += (I != nullptr ? getOperandsExtensionCost(I) : 2); return Cost; } case Instruction::Select: |