From ae34b4280ebde6217706902e8a27bb858765a61c Mon Sep 17 00:00:00 2001 From: Nadav Rotem Date: Fri, 28 Dec 2012 08:19:03 +0000 Subject: [PATCH] CostModel: initial checkin for code that estimates the cost of special shuffles. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@171180 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/X86ISelLowering.cpp | 16 ++++++++++++++++ lib/Target/X86/X86ISelLowering.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index e5122abd4ba..5d495a68eda 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -18237,3 +18237,19 @@ unsigned X86VectorTargetTransformInfo::getCastInstrCost(unsigned Opcode, return VectorTargetTransformImpl::getCastInstrCost(Opcode, Dst, Src); } + +unsigned X86VectorTargetTransformInfo::getShuffleCost(ShuffleKind Kind, Type *Tp, + int Index) const { + // We only estimate the cost of reverse shuffles. + if (Kind != Reverse) + return VectorTargetTransformImpl::getShuffleCost(Kind, Tp, Index); + + std::pair LT = getTypeLegalizationCost(Tp); + unsigned Cost = 1; + if (LT.second.getSizeInBits() > 128) + Cost = 3; // Extract + insert + copy. + + // Multiple by the number of parts. + return Cost * LT.first; +} + diff --git a/lib/Target/X86/X86ISelLowering.h b/lib/Target/X86/X86ISelLowering.h index 1a696a8f536..1b4b5eb65da 100644 --- a/lib/Target/X86/X86ISelLowering.h +++ b/lib/Target/X86/X86ISelLowering.h @@ -973,6 +973,8 @@ namespace llvm { virtual unsigned getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src) const; + + unsigned getShuffleCost(ShuffleKind Kind, Type *Tp, int Index) const; }; }