Use movaps to load a v4f32 build_vector of all-constant values into a

register instead of loading each element individually.

llvm-svn: 40478
This commit is contained in:
Dan Gohman 2007-07-24 22:55:08 +00:00
parent d998be79cc
commit f906c7286f
2 changed files with 14 additions and 0 deletions

View File

@ -2495,6 +2495,7 @@ X86TargetLowering::LowerBUILD_VECTOR(SDOperand Op, SelectionDAG &DAG) {
unsigned NumZero = 0;
unsigned NumNonZero = 0;
unsigned NonZeros = 0;
unsigned NumNonZeroImms = 0;
std::set<SDOperand> Values;
for (unsigned i = 0; i < NumElems; ++i) {
SDOperand Elt = Op.getOperand(i);
@ -2505,6 +2506,9 @@ X86TargetLowering::LowerBUILD_VECTOR(SDOperand Op, SelectionDAG &DAG) {
else {
NonZeros |= (1 << i);
NumNonZero++;
if (Elt.getOpcode() == ISD::Constant ||
Elt.getOpcode() == ISD::ConstantFP)
NumNonZeroImms++;
}
}
}
@ -2548,6 +2552,11 @@ X86TargetLowering::LowerBUILD_VECTOR(SDOperand Op, SelectionDAG &DAG) {
}
}
// A vector full of immediates; various special cases are already
// handled, so this is best done with a single constant-pool load.
if (NumNonZero == NumNonZeroImms)
return SDOperand();
// Let legalizer expand 2-wide build_vectors.
if (EVTBits == 64)
return SDOperand();

View File

@ -0,0 +1,5 @@
; RUN: llvm-as < %s | llc -march=x86 -mattr=+sse | grep movaps
define <4 x float> @foo() {
ret <4 x float> <float 3.223542354, float 2.3, float 1.2, float 0.1>
}