Skip to content

Commit

Permalink
[CostModel][X86] Fix constant vector XOP rights shifts
Browse files Browse the repository at this point in the history
We'll constant fold these cases so they are as cheap as vector left shift cases.

Noticed while improving funnel shift costs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346760 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
RKSimon committed Nov 13, 2018
1 parent 9693395 commit d2cb662
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 89 deletions.
13 changes: 11 additions & 2 deletions lib/Target/X86/X86TargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading

0 comments on commit d2cb662

Please sign in to comment.