[llvm-commits] [llvm] r167402 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp test/Analysis/CostModel/X86/insert-extract-at-zero.ll
Nadav Rotem
nrotem at apple.com
Mon Nov 5 13:12:13 PST 2012
Author: nadav
Date: Mon Nov 5 15:12:13 2012
New Revision: 167402
URL: http://llvm.org/viewvc/llvm-project?rev=167402&view=rev
Log:
Cost Model: Normalize the insert/extract index when splitting types
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/test/Analysis/CostModel/X86/insert-extract-at-zero.ll
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=167402&r1=167401&r2=167402&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Mon Nov 5 15:12:13 2012
@@ -17556,9 +17556,26 @@
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);
}
Modified: llvm/trunk/test/Analysis/CostModel/X86/insert-extract-at-zero.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Analysis/CostModel/X86/insert-extract-at-zero.ll?rev=167402&r1=167401&r2=167402&view=diff
==============================================================================
--- llvm/trunk/test/Analysis/CostModel/X86/insert-extract-at-zero.ll (original)
+++ llvm/trunk/test/Analysis/CostModel/X86/insert-extract-at-zero.ll Mon Nov 5 15:12:13 2012
@@ -29,5 +29,12 @@
;CHECK: cost of 0 {{.*}} insert
%J = insertelement <4 x double> undef, double undef, i32 0
+ ;CHECK: cost of 0 {{.*}} insert
+ %K = insertelement <8 x double> undef, double undef, i32 4
+ ;CHECK: cost of 0 {{.*}} insert
+ %L = insertelement <16 x double> undef, double undef, i32 8
+ ;CHECK: cost of 1 {{.*}} insert
+ %M = insertelement <16 x double> undef, double undef, i32 9
ret i32 0
}
+
More information about the llvm-commits
mailing list