[PATCH] D103480: [NFC][OpaquePtr] Explicitly pass GEP source type in optimizeGatherScatterInst()
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 11 11:31:25 PDT 2021
aeubanks updated this revision to Diff 351514.
aeubanks added a comment.
add assert
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D103480/new/
https://reviews.llvm.org/D103480
Files:
llvm/lib/CodeGen/CodeGenPrepare.cpp
Index: llvm/lib/CodeGen/CodeGenPrepare.cpp
===================================================================
--- llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -5558,7 +5558,10 @@
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 @@
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 @@
// 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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103480.351514.patch
Type: text/x-patch
Size: 2255 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210611/f43da053/attachment.bin>
More information about the llvm-commits
mailing list