Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit d2cb662

Browse files
committed
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346760 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 9693395 commit d2cb662

File tree

3 files changed

+82
-89
lines changed

3 files changed

+82
-89
lines changed

lib/Target/X86/X86TargetTransformInfo.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,9 +612,18 @@ int X86TTIImpl::getArithmeticInstrCost(
612612
};
613613

614614
// Look for XOP lowering tricks.
615-
if (ST->hasXOP())
616-
if (const auto *Entry = CostTableLookup(XOPShiftCostTable, ISD, LT.second))
615+
if (ST->hasXOP()) {
616+
// If the right shift is constant then we'll fold the negation so
617+
// it's as cheap as a left shift.
618+
int ShiftISD = ISD;
619+
if ((ShiftISD == ISD::SRL || ShiftISD == ISD::SRA) &&
620+
(Op2Info == TargetTransformInfo::OK_UniformConstantValue ||
621+
Op2Info == TargetTransformInfo::OK_NonUniformConstantValue))
622+
ShiftISD = ISD::SHL;
623+
if (const auto *Entry =
624+
CostTableLookup(XOPShiftCostTable, ShiftISD, LT.second))
617625
return LT.first * Entry->Cost;
626+
}
618627

619628
static const CostTblEntry SSE2UniformShiftCostTable[] = {
620629
// Uniform splats are cheaper for the following instructions.

0 commit comments

Comments
 (0)