aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib
diff options
context:
space:
mode:
authorPhilip Reames <preames@rivosinc.com>2023-08-07 07:37:35 -0700
committerPhilip Reames <listmail@philipreames.com>2023-08-07 07:42:04 -0700
commit999ac10d7649e41755a9624dbb508c2db8bf3ddd (patch)
treea4d4d4a20279040012532d71439872e4ba48b840 /llvm/lib
parent56d92c17583e5f0b5e1e521b5f614be79436fccc (diff)
downloadllvm-999ac10d7649e41755a9624dbb508c2db8bf3ddd.zip
llvm-999ac10d7649e41755a9624dbb508c2db8bf3ddd.tar.gz
llvm-999ac10d7649e41755a9624dbb508c2db8bf3ddd.tar.bz2
[RISCVGatherScatterLowering] Support broadcast base pointer
A broadcast base pointer is the same as a scalar base pointer for GEP semantics (when there's at least one other vector operand). This is the form that SLP likes to emit, so we should handle it. Differential Revision: https://reviews.llvm.org/D157132
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp b/llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp
index b9c69a9..fac3526 100644
--- a/llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVGatherScatterLowering.cpp
@@ -331,8 +331,12 @@ RISCVGatherScatterLowering::determineBaseAndStride(GetElementPtrInst *GEP,
SmallVector<Value *, 2> Ops(GEP->operands());
// Base pointer needs to be a scalar.
- if (Ops[0]->getType()->isVectorTy())
- return std::make_pair(nullptr, nullptr);
+ Value *ScalarBase = Ops[0];
+ if (ScalarBase->getType()->isVectorTy()) {
+ ScalarBase = getSplatValue(ScalarBase);
+ if (!ScalarBase)
+ return std::make_pair(nullptr, nullptr);
+ }
std::optional<unsigned> VecOperand;
unsigned TypeScale = 0;
@@ -379,7 +383,7 @@ RISCVGatherScatterLowering::determineBaseAndStride(GetElementPtrInst *GEP,
Ops[*VecOperand] = Start;
Type *SourceTy = GEP->getSourceElementType();
Value *BasePtr =
- Builder.CreateGEP(SourceTy, Ops[0], ArrayRef(Ops).drop_front());
+ Builder.CreateGEP(SourceTy, ScalarBase, ArrayRef(Ops).drop_front());
// Convert stride to pointer size if needed.
Type *IntPtrTy = DL->getIntPtrType(BasePtr->getType());
@@ -415,7 +419,7 @@ RISCVGatherScatterLowering::determineBaseAndStride(GetElementPtrInst *GEP,
Ops[*VecOperand] = BasePhi;
Type *SourceTy = GEP->getSourceElementType();
Value *BasePtr =
- Builder.CreateGEP(SourceTy, Ops[0], ArrayRef(Ops).drop_front());
+ Builder.CreateGEP(SourceTy, ScalarBase, ArrayRef(Ops).drop_front());
// Final adjustments to stride should go in the start block.
Builder.SetInsertPoint(