aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/CodeGenPrepare.cpp
diff options
context:
space:
mode:
authorPaul Walker <paul.walker@arm.com>2020-12-03 12:26:29 +0000
committerPaul Walker <paul.walker@arm.com>2020-12-15 10:57:51 +0000
commit6d35bd1d48e9fdde38483e6b22a900daa7e3d46a (patch)
treed83265ef11345f65ca0278165fe38ddf02512370 /llvm/lib/CodeGen/CodeGenPrepare.cpp
parentbd0709266911bce2f1e8a875f9ed49d56953f323 (diff)
downloadllvm-6d35bd1d48e9fdde38483e6b22a900daa7e3d46a.zip
llvm-6d35bd1d48e9fdde38483e6b22a900daa7e3d46a.tar.gz
llvm-6d35bd1d48e9fdde38483e6b22a900daa7e3d46a.tar.bz2
[CodeGenPrepare] Update optimizeGatherScatterInst for scalable vectors.
optimizeGatherScatterInst does nothing specific to fixed length vectors but uses FixedVectorType to extract the number of elements. This patch simply updates the code to use VectorType and getElementCount instead. For testing I just copied Transforms/CodeGenPrepare/X86/gather-scatter-opt.ll replacing `<4 x ` with `<vscale x 4`. Differential Revision: https://reviews.llvm.org/D92572
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp14
1 files changed, 5 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 9b44b30..8fe5cb9 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -5304,14 +5304,10 @@ bool CodeGenPrepare::optimizeMemoryInst(Instruction *MemoryInst, Value *Addr,
///
/// If the final index isn't a vector or is a splat, we can emit a scalar GEP
/// followed by a GEP with an all zeroes vector index. This will enable
-/// SelectionDAGBuilder to use a the scalar GEP as the uniform base and have a
+/// SelectionDAGBuilder to use the scalar GEP as the uniform base and have a
/// zero index.
bool CodeGenPrepare::optimizeGatherScatterInst(Instruction *MemoryInst,
Value *Ptr) {
- // FIXME: Support scalable vectors.
- if (isa<ScalableVectorType>(Ptr->getType()))
- return false;
-
Value *NewAddr;
if (const auto *GEP = dyn_cast<GetElementPtrInst>(Ptr)) {
@@ -5370,7 +5366,7 @@ bool CodeGenPrepare::optimizeGatherScatterInst(Instruction *MemoryInst,
if (!RewriteGEP && Ops.size() == 2)
return false;
- unsigned NumElts = cast<FixedVectorType>(Ptr->getType())->getNumElements();
+ auto NumElts = cast<VectorType>(Ptr->getType())->getElementCount();
IRBuilder<> Builder(MemoryInst);
@@ -5380,7 +5376,7 @@ bool CodeGenPrepare::optimizeGatherScatterInst(Instruction *MemoryInst,
// and a vector GEP with all zeroes final index.
if (!Ops[FinalIndex]->getType()->isVectorTy()) {
NewAddr = Builder.CreateGEP(Ops[0], makeArrayRef(Ops).drop_front());
- auto *IndexTy = FixedVectorType::get(ScalarIndexTy, NumElts);
+ auto *IndexTy = VectorType::get(ScalarIndexTy, NumElts);
NewAddr = Builder.CreateGEP(NewAddr, Constant::getNullValue(IndexTy));
} else {
Value *Base = Ops[0];
@@ -5403,13 +5399,13 @@ bool CodeGenPrepare::optimizeGatherScatterInst(Instruction *MemoryInst,
if (!V)
return false;
- unsigned NumElts = cast<FixedVectorType>(Ptr->getType())->getNumElements();
+ auto NumElts = cast<VectorType>(Ptr->getType())->getElementCount();
IRBuilder<> Builder(MemoryInst);
// Emit a vector GEP with a scalar pointer and all 0s vector index.
Type *ScalarIndexTy = DL->getIndexType(V->getType()->getScalarType());
- auto *IndexTy = FixedVectorType::get(ScalarIndexTy, NumElts);
+ auto *IndexTy = VectorType::get(ScalarIndexTy, NumElts);
NewAddr = Builder.CreateGEP(V, Constant::getNullValue(IndexTy));
} else {
// Constant, SelectionDAGBuilder knows to check if its a splat.