[llvm] [SeparateConstOffsetFromGEP] Support GEP reordering for different types (PR #90802)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed May 1 19:41:46 PDT 2024
================
@@ -1017,6 +1016,51 @@ bool SeparateConstOffsetFromGEP::reorderGEP(GetElementPtrInst *GEP,
IsChainInBounds &= KnownPtrGEPIdx.isNonNegative();
}
}
+ TypeSize GEPSize = DL->getTypeSizeInBits(GEP->getSourceElementType());
+ TypeSize PtrGEPSize = DL->getTypeSizeInBits(PtrGEP->getSourceElementType());
----------------
nikic wrote:
You're working on the wrong type sizes here. You need to use the alloc sizes.
But more generally, maybe I don't get what this code is doing, but can't you also swap the GEP source element types when swapping the indices? That's how you usually reassociate GEPs. Why do you need/want to rewrite them?
https://github.com/llvm/llvm-project/pull/90802
More information about the llvm-commits
mailing list