aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGBuiltin.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2012-01-25 02:06:10 +0000
committerChris Lattner <sabre@nondot.org>2012-01-25 02:06:10 +0000
commit9ddc6246b5f3dbb1a1e05d012361dc2c6d403381 (patch)
treedb53b076e8e5bb9c5038df1b78b682b6c818bff7 /lib/CodeGen/CGBuiltin.cpp
parent443aac9bd22624c6abb1fe7e581ac30c4e654eea (diff)
use the new ConstantVector::getSplat method where it makes sense.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148902 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGBuiltin.cpp')
-rw-r--r--lib/CodeGen/CGBuiltin.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp
index a3e21dcab6..e63eeb3c76 100644
--- a/lib/CodeGen/CGBuiltin.cpp
+++ b/lib/CodeGen/CGBuiltin.cpp
@@ -1212,8 +1212,7 @@ static llvm::VectorType *GetNeonType(LLVMContext &C, NeonTypeFlags TypeFlags) {
Value *CodeGenFunction::EmitNeonSplat(Value *V, Constant *C) {
unsigned nElts = cast<llvm::VectorType>(V->getType())->getNumElements();
- SmallVector<Constant*, 16> Indices(nElts, C);
- Value* SV = llvm::ConstantVector::get(Indices);
+ Value* SV = llvm::ConstantVector::getSplat(nElts, C);
return Builder.CreateShuffleVector(V, V, SV, "lane");
}
@@ -1233,13 +1232,11 @@ Value *CodeGenFunction::EmitNeonCall(Function *F, SmallVectorImpl<Value*> &Ops,
Value *CodeGenFunction::EmitNeonShiftVector(Value *V, llvm::Type *Ty,
bool neg) {
- ConstantInt *CI = cast<ConstantInt>(V);
- int SV = CI->getSExtValue();
+ int SV = cast<ConstantInt>(V)->getSExtValue();
llvm::VectorType *VTy = cast<llvm::VectorType>(Ty);
llvm::Constant *C = ConstantInt::get(VTy->getElementType(), neg ? -SV : SV);
- SmallVector<llvm::Constant*, 16> CV(VTy->getNumElements(), C);
- return llvm::ConstantVector::get(CV);
+ return llvm::ConstantVector::getSplat(VTy->getNumElements(), C);
}
/// GetPointeeAlignment - Given an expression with a pointer type, find the
@@ -1957,8 +1954,8 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID,
for (unsigned vi = 0; vi != 2; ++vi) {
SmallVector<Constant*, 16> Indices;
for (unsigned i = 0, e = VTy->getNumElements(); i != e; i += 2) {
- Indices.push_back(ConstantInt::get(Int32Ty, i+vi));
- Indices.push_back(ConstantInt::get(Int32Ty, i+e+vi));
+ Indices.push_back(Builder.getInt32(i+vi));
+ Indices.push_back(Builder.getInt32(i+e+vi));
}
Value *Addr = Builder.CreateConstInBoundsGEP1_32(Ops[0], vi);
SV = llvm::ConstantVector::get(Indices);
@@ -2019,7 +2016,7 @@ BuildVector(const SmallVectorImpl<llvm::Value*> &Ops) {
// If this is a constant vector, create a ConstantVector.
if (AllConstants) {
- std::vector<llvm::Constant*> CstOps;
+ SmallVector<llvm::Constant*, 16> CstOps;
for (unsigned i = 0, e = Ops.size(); i != e; ++i)
CstOps.push_back(cast<Constant>(Ops[i]));
return llvm::ConstantVector::get(CstOps);
@@ -2030,8 +2027,7 @@ BuildVector(const SmallVectorImpl<llvm::Value*> &Ops) {
llvm::UndefValue::get(llvm::VectorType::get(Ops[0]->getType(), Ops.size()));
for (unsigned i = 0, e = Ops.size(); i != e; ++i)
- Result = Builder.CreateInsertElement(Result, Ops[i],
- llvm::ConstantInt::get(llvm::Type::getInt32Ty(getLLVMContext()), i));
+ Result = Builder.CreateInsertElement(Result, Ops[i], Builder.getInt32(i));
return Result;
}