summaryrefslogtreecommitdiffstats
path: root/llvm/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
commit856ffa6677c8666bf61ca69a2861d1280f50ec59 (patch)
tree34bdac50632830197fd6db0032479595d4d098a4 /llvm/lib
parent020be9dc29070407c483e15f65aa2e8624a2beec (diff)
downloadbcm5719-llvm-856ffa6677c8666bf61ca69a2861d1280f50ec59.tar.gz
bcm5719-llvm-856ffa6677c8666bf61ca69a2861d1280f50ec59.zip
Cost Model: Normalize the insert/extract index when splitting types
llvm-svn: 167402
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/X86/X86ISelLowering.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 575d30df2e0..a42b25b65f7 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/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);
}
OpenPOWER on IntegriCloud