aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorNadav Rotem <nrotem@apple.com>2012-11-05 21:12:13 +0000
committerNadav Rotem <nrotem@apple.com>2012-11-05 21:12:13 +0000
commita4ab5290e6808c54aff178d465d533e4eba53feb (patch)
tree825d6c953291e7870c97e5704b79e9533785fe0d /lib
parent75138f58b0abaff54270481e879bc770df88114c (diff)
Cost Model: Normalize the insert/extract index when splitting types
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167402 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Target/X86/X86ISelLowering.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp
index 575d30df2e..a42b25b65f 100644
--- a/lib/Target/X86/X86ISelLowering.cpp
+++ b/lib/Target/X86/X86ISelLowering.cpp
@@ -17556,9 +17556,26 @@ X86VectorTargetTransformInfo::getArithmeticInstrCost(unsigned Opcode,
unsigned
X86VectorTargetTransformInfo::getVectorInstrCost(unsigned Opcode, Type *Val,
unsigned Index) const {
- // Floating point scalars are already located in index #0.
- if (Val->getScalarType()->isFloatingPointTy() && Index == 0)
- return 0;
+ assert(Val->isVectorTy() && "This must be a vector type");
+
+ if (Index != -1) {
+ // Legalize the type.
+ std::pair<unsigned, MVT> LT =
+ getTypeLegalizationCost(Val->getContext(), TLI->getValueType(Val));
+
+ // This type is legalized to a scalar type.
+ if (!LT.second.isVector())
+ return 0;
+
+ // The type may be split. Normalize the index to the new type.
+ unsigned Width = LT.second.getVectorNumElements();
+ Index = Index % Width;
+
+ // Floating point scalars are already located in index #0.
+ if (Val->getScalarType()->isFloatingPointTy() && Index == 0)
+ return 0;
+ }
+
return VectorTargetTransformImpl::getVectorInstrCost(Opcode, Val, Index);
}