[llvm] c0c5a98 - [NFC][OpaquePtr] Explicitly pass GEP source type in optimizeGatherScatterInst()
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 11 11:50:12 PDT 2021
Author: Arthur Eubanks
Date: 2021-06-11T11:49:59-07:00
New Revision: c0c5a98b2c47bfb93a99b408cee2416005c16274
URL: https://github.com/llvm/llvm-project/commit/c0c5a98b2c47bfb93a99b408cee2416005c16274
DIFF: https://github.com/llvm/llvm-project/commit/c0c5a98b2c47bfb93a99b408cee2416005c16274.diff
LOG: [NFC][OpaquePtr] Explicitly pass GEP source type in optimizeGatherScatterInst()
Reviewed By: craig.topper
Differential Revision: https://reviews.llvm.org/D103480
Added:
Modified:
llvm/lib/CodeGen/CodeGenPrepare.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 0bdaaa6b14cf..04fa74ab5285 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -5558,7 +5558,10 @@ bool CodeGenPrepare::optimizeGatherScatterInst(Instruction *MemoryInst,
NewAddr = Builder.CreateGEP(SourceTy, Ops[0],
makeArrayRef(Ops).drop_front());
auto *IndexTy = VectorType::get(ScalarIndexTy, NumElts);
- NewAddr = Builder.CreateGEP(NewAddr, Constant::getNullValue(IndexTy));
+ auto *SecondTy = GetElementPtrInst::getIndexedType(
+ SourceTy, makeArrayRef(Ops).drop_front());
+ NewAddr =
+ Builder.CreateGEP(SecondTy, NewAddr, Constant::getNullValue(IndexTy));
} else {
Value *Base = Ops[0];
Value *Index = Ops[FinalIndex];
@@ -5569,10 +5572,12 @@ bool CodeGenPrepare::optimizeGatherScatterInst(Instruction *MemoryInst,
Ops[FinalIndex] = Constant::getNullValue(ScalarIndexTy);
Base = Builder.CreateGEP(SourceTy, Base,
makeArrayRef(Ops).drop_front());
+ SourceTy = GetElementPtrInst::getIndexedType(
+ SourceTy, makeArrayRef(Ops).drop_front());
}
// Now create the GEP with scalar pointer and vector index.
- NewAddr = Builder.CreateGEP(Base, Index);
+ NewAddr = Builder.CreateGEP(SourceTy, Base, Index);
}
} else if (!isa<Constant>(Ptr)) {
// Not a GEP, maybe its a splat and we can create a GEP to enable
@@ -5588,7 +5593,16 @@ bool CodeGenPrepare::optimizeGatherScatterInst(Instruction *MemoryInst,
// Emit a vector GEP with a scalar pointer and all 0s vector index.
Type *ScalarIndexTy = DL->getIndexType(V->getType()->getScalarType());
auto *IndexTy = VectorType::get(ScalarIndexTy, NumElts);
- NewAddr = Builder.CreateGEP(V, Constant::getNullValue(IndexTy));
+ Type *ScalarTy;
+ if (cast<IntrinsicInst>(MemoryInst)->getIntrinsicID() ==
+ Intrinsic::masked_gather) {
+ ScalarTy = MemoryInst->getType()->getScalarType();
+ } else {
+ assert(cast<IntrinsicInst>(MemoryInst)->getIntrinsicID() ==
+ Intrinsic::masked_scatter);
+ ScalarTy = MemoryInst->getOperand(0)->getType()->getScalarType();
+ }
+ NewAddr = Builder.CreateGEP(ScalarTy, V, Constant::getNullValue(IndexTy));
} else {
// Constant, SelectionDAGBuilder knows to check if its a splat.
return false;
More information about the llvm-commits
mailing list