[llvm] [InstCombine] Make indexed compare fold GEP source type independent (PR #71663)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 21 10:24:08 PST 2023
================
@@ -609,23 +597,14 @@ static Value *rewriteGEPAsOffset(Type *ElemTy, Value *Start, Value *Base,
}
}
- PointerType *PtrTy = PointerType::get(
- Base->getContext(), Start->getType()->getPointerAddressSpace());
for (Value *Val : Explored) {
if (Val == Base)
continue;
- // Depending on the type, for external users we have to emit
- // a GEP or a GEP + ptrtoint.
setInsertionPoint(Builder, Val, false);
-
- // Cast base to the expected type.
- Value *NewVal = Builder.CreateBitOrPointerCast(
- Base, PtrTy, Start->getName() + "to.ptr");
- NewVal = Builder.CreateInBoundsGEP(ElemTy, NewVal, ArrayRef(NewInsts[Val]),
- Val->getName() + ".ptr");
- NewVal = Builder.CreateBitOrPointerCast(
- NewVal, Val->getType(), Val->getName() + ".conv");
+ // Create GEP for external users.
----------------
goldsteinn wrote:
I'm clearly missing something as its not there in original, but would expect a check that `Val` is not a phi node here.
https://github.com/llvm/llvm-project/pull/71663
More information about the llvm-commits
mailing list