summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorSimon Pilgrim <llvm-dev@redking.me.uk>2018-11-13 16:40:10 +0000
committerSimon Pilgrim <llvm-dev@redking.me.uk>2018-11-13 16:40:10 +0000
commite827fe09b3967fc899af8e5916d66ff0c65f3124 (patch)
treed60d43cba219453d69d17487861d99672b2d2e3a /llvm/lib/Target
parent86ed347bcd2c4ef8c12a38473bfc14d7db70f3db (diff)
downloadbcm5719-llvm-e827fe09b3967fc899af8e5916d66ff0c65f3124.tar.gz
bcm5719-llvm-e827fe09b3967fc899af8e5916d66ff0c65f3124.zip
[CostModel][X86] Fix constant vector XOP rights shifts
We'll constant fold these cases so they are as cheap as vector left shift cases. Noticed while improving funnel shift costs. llvm-svn: 346760
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/X86/X86TargetTransformInfo.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
index a79a48ef579..0010423bc76 100644
--- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
+++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp
@@ -612,9 +612,18 @@ int X86TTIImpl::getArithmeticInstrCost(
};
// Look for XOP lowering tricks.
- if (ST->hasXOP())
- if (const auto *Entry = CostTableLookup(XOPShiftCostTable, ISD, LT.second))
+ if (ST->hasXOP()) {
+ // If the right shift is constant then we'll fold the negation so
+ // it's as cheap as a left shift.
+ int ShiftISD = ISD;
+ if ((ShiftISD == ISD::SRL || ShiftISD == ISD::SRA) &&
+ (Op2Info == TargetTransformInfo::OK_UniformConstantValue ||
+ Op2Info == TargetTransformInfo::OK_NonUniformConstantValue))
+ ShiftISD = ISD::SHL;
+ if (const auto *Entry =
+ CostTableLookup(XOPShiftCostTable, ShiftISD, LT.second))
return LT.first * Entry->Cost;
+ }
static const CostTblEntry SSE2UniformShiftCostTable[] = {
// Uniform splats are cheaper for the following instructions.
OpenPOWER on IntegriCloud