aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorPaul Walker <paul.walker@arm.com>2023-01-04 11:45:54 +0000
committerPaul Walker <paul.walker@arm.com>2023-01-11 14:08:06 +0000
commiteae26b6640afff715172d75fdee02e7df7530a9b (patch)
treea824244d3b6a9297bfa853bf6f7e2596f730e44f /llvm/lib
parent4313b6f9ebc2556ff039249691a4dc619e32840c (diff)
downloadllvm-eae26b6640afff715172d75fdee02e7df7530a9b.zip
llvm-eae26b6640afff715172d75fdee02e7df7530a9b.tar.gz
llvm-eae26b6640afff715172d75fdee02e7df7530a9b.tar.bz2
[IRBuilder] Use canonical i64 type for insertelement index used by vector splats.
Instcombine prefers this canonical form (see getPreferredVectorIndex), as does IRBuilder when passing the index as an integer so we may as well use the prefered form from creation. NOTE: All test changes are mechanical with nothing else expected beyond a change of index type from i32 to i64. Differential Revision: https://reviews.llvm.org/D140983
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/IR/Constants.cpp4
-rw-r--r--llvm/lib/IR/IRBuilder.cpp4
2 files changed, 3 insertions, 5 deletions
diff --git a/llvm/lib/IR/Constants.cpp b/llvm/lib/IR/Constants.cpp
index f777b1b..a536711 100644
--- a/llvm/lib/IR/Constants.cpp
+++ b/llvm/lib/IR/Constants.cpp
@@ -1415,11 +1415,11 @@ Constant *ConstantVector::getSplat(ElementCount EC, Constant *V) {
else if (isa<UndefValue>(V))
return UndefValue::get(VTy);
- Type *I32Ty = Type::getInt32Ty(VTy->getContext());
+ Type *IdxTy = Type::getInt64Ty(VTy->getContext());
// Move scalar into vector.
Constant *PoisonV = PoisonValue::get(VTy);
- V = ConstantExpr::getInsertElement(PoisonV, V, ConstantInt::get(I32Ty, 0));
+ V = ConstantExpr::getInsertElement(PoisonV, V, ConstantInt::get(IdxTy, 0));
// Build shuffle mask to perform the splat.
SmallVector<int, 8> Zeros(EC.getKnownMinValue(), 0);
// Splat.
diff --git a/llvm/lib/IR/IRBuilder.cpp b/llvm/lib/IR/IRBuilder.cpp
index c4923bc..f871205 100644
--- a/llvm/lib/IR/IRBuilder.cpp
+++ b/llvm/lib/IR/IRBuilder.cpp
@@ -1257,10 +1257,8 @@ Value *IRBuilderBase::CreateVectorSplat(ElementCount EC, Value *V,
assert(EC.isNonZero() && "Cannot splat to an empty vector!");
// First insert it into a poison vector so we can shuffle it.
- Type *I32Ty = getInt32Ty();
Value *Poison = PoisonValue::get(VectorType::get(V->getType(), EC));
- V = CreateInsertElement(Poison, V, ConstantInt::get(I32Ty, 0),
- Name + ".splatinsert");
+ V = CreateInsertElement(Poison, V, getInt64(0), Name + ".splatinsert");
// Shuffle the value across the desired number of elements.
SmallVector<int, 16> Zeros;