CodeGen: Simplify the generation of a splat

llvm-svn: 151912
This commit is contained in:
Tobias Grosser 2012-03-02 15:20:21 +00:00
parent 415245def5
commit f6beec674e
2 changed files with 5 additions and 12 deletions

View File

@ -523,17 +523,10 @@ Value *VectorBlockGenerator::makeVectorOperand(Value *Operand) {
if (Operand->getType()->isVectorTy())
return Operand;
VectorType *VectorType = VectorType::get(Operand->getType(), VectorWidth);
Value *Vector = UndefValue::get(VectorType);
Value *Vector = UndefValue::get(VectorType::get(Operand->getType(), 1));
Vector = Builder.CreateInsertElement(Vector, Operand, Builder.getInt32(0));
std::vector<Constant*> Splat;
for (int i = 0; i < VectorWidth; i++)
Splat.push_back (Builder.getInt32(0));
Constant *SplatVector = ConstantVector::get(Splat);
Constant *SplatVector = ConstantVector::getSplat(VectorWidth,
Builder.getInt32(0));
return Builder.CreateShuffleVector(Vector, Vector, SplatVector);
}

View File

@ -41,7 +41,7 @@ bb:
ret i32 %tmp1
}
; CHECK: insertelement <4 x float> undef, float %p_tmp4, i32 0
; CHECK: shufflevector <4 x float> %0, <4 x float> %0, <4 x i32> zeroinitializer
; CHECK: insertelement <1 x float> undef, float %p_tmp4, i32 0
; CHECK: shufflevector <1 x float> %0, <1 x float> %0, <4 x i32> zeroinitializer
; CHECK: fadd <4 x float> %tmp_p_vec_full, %1