aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/CodeGenPrepare.cpp
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-03-11 18:59:49 +0100
committerNikita Popov <nikita.ppv@gmail.com>2021-03-12 21:01:16 +0100
commit42eb658f656c43ee63e25222f32abbbbcb86ad7b (patch)
tree42f25f9b87040f2e894efccf389ae676f52175c1 /llvm/lib/CodeGen/CodeGenPrepare.cpp
parent51151828acad6b1e5b0719285ce7172506877fd1 (diff)
downloadllvm-42eb658f656c43ee63e25222f32abbbbcb86ad7b.zip
llvm-42eb658f656c43ee63e25222f32abbbbcb86ad7b.tar.gz
llvm-42eb658f656c43ee63e25222f32abbbbcb86ad7b.tar.bz2
[OpaquePtrs] Remove some uses of type-less CreateGEP() (NFC)
This removes some (but not all) uses of type-less CreateGEP() and CreateInBoundsGEP() APIs, which are incompatible with opaque pointers. There are a still a number of tricky uses left, as well as many more variation APIs for CreateGEP.
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 9de4261..0f698dd 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -5526,12 +5526,14 @@ bool CodeGenPrepare::optimizeGatherScatterInst(Instruction *MemoryInst,
IRBuilder<> Builder(MemoryInst);
+ Type *SourceTy = GEP->getSourceElementType();
Type *ScalarIndexTy = DL->getIndexType(Ops[0]->getType()->getScalarType());
// If the final index isn't a vector, emit a scalar GEP containing all ops
// and a vector GEP with all zeroes final index.
if (!Ops[FinalIndex]->getType()->isVectorTy()) {
- NewAddr = Builder.CreateGEP(Ops[0], makeArrayRef(Ops).drop_front());
+ NewAddr = Builder.CreateGEP(SourceTy, Ops[0],
+ makeArrayRef(Ops).drop_front());
auto *IndexTy = VectorType::get(ScalarIndexTy, NumElts);
NewAddr = Builder.CreateGEP(NewAddr, Constant::getNullValue(IndexTy));
} else {
@@ -5542,7 +5544,8 @@ bool CodeGenPrepare::optimizeGatherScatterInst(Instruction *MemoryInst,
if (Ops.size() != 2) {
// Replace the last index with 0.
Ops[FinalIndex] = Constant::getNullValue(ScalarIndexTy);
- Base = Builder.CreateGEP(Base, makeArrayRef(Ops).drop_front());
+ Base = Builder.CreateGEP(SourceTy, Base,
+ makeArrayRef(Ops).drop_front());
}
// Now create the GEP with scalar pointer and vector index.