forked from OSchip/llvm-project
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:
parent
d998be79cc
commit
f906c7286f
|
@ -2495,6 +2495,7 @@ X86TargetLowering::LowerBUILD_VECTOR(SDOperand Op, SelectionDAG &DAG) {
|
||||||
unsigned NumZero = 0;
|
unsigned NumZero = 0;
|
||||||
unsigned NumNonZero = 0;
|
unsigned NumNonZero = 0;
|
||||||
unsigned NonZeros = 0;
|
unsigned NonZeros = 0;
|
||||||
|
unsigned NumNonZeroImms = 0;
|
||||||
std::set<SDOperand> Values;
|
std::set<SDOperand> Values;
|
||||||
for (unsigned i = 0; i < NumElems; ++i) {
|
for (unsigned i = 0; i < NumElems; ++i) {
|
||||||
SDOperand Elt = Op.getOperand(i);
|
SDOperand Elt = Op.getOperand(i);
|
||||||
|
@ -2505,6 +2506,9 @@ X86TargetLowering::LowerBUILD_VECTOR(SDOperand Op, SelectionDAG &DAG) {
|
||||||
else {
|
else {
|
||||||
NonZeros |= (1 << i);
|
NonZeros |= (1 << i);
|
||||||
NumNonZero++;
|
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.
|
// Let legalizer expand 2-wide build_vectors.
|
||||||
if (EVTBits == 64)
|
if (EVTBits == 64)
|
||||||
return SDOperand();
|
return SDOperand();
|
||||||
|
|
|
@ -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>
|
||||||
|
}
|
Loading…
Reference in New Issue