[llvm] [SeparateConstOffsetFromGEP] Support GEP reordering for different types (PR #90802)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon May 6 18:38:06 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:
I'm not suggesting that you perform an in-place rewrite, but rather than you preserve the original element types of the GEPs. If you have `gep t2, (gep t1, p, i1), i2`, you should be able to rewrite it to `gep t1 (gep t2, p, i2), i1` without changing types or index values.
https://github.com/llvm/llvm-project/pull/90802
More information about the llvm-commits
mailing list