[llvm] [SeparateConstOffsetFromGEP] Support multiple indices in reorderGEP (PR #92339)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon May 20 22:56:31 PDT 2024
================
@@ -997,14 +992,12 @@ bool SeparateConstOffsetFromGEP::reorderGEP(GetElementPtrInst *GEP,
bool PtrGEPInBounds = PtrGEP->isInBounds();
bool IsChainInBounds = GEPInBounds && PtrGEPInBounds;
if (IsChainInBounds) {
- auto GEPIdx = GEP->indices().begin();
- auto KnownGEPIdx = computeKnownBits(GEPIdx->get(), *DL);
- IsChainInBounds &= KnownGEPIdx.isNonNegative();
- if (IsChainInBounds) {
- auto PtrGEPIdx = PtrGEP->indices().begin();
- auto KnownPtrGEPIdx = computeKnownBits(PtrGEPIdx->get(), *DL);
- IsChainInBounds &= KnownPtrGEPIdx.isNonNegative();
- }
+ auto IsKnownNonNegative = [&](Value *V) {
+ return isKnownNonNegative(V, *DL);
+ };
+ IsChainInBounds &= all_of(GEP->indices(), IsKnownNonNegative);
+ if (IsChainInBounds)
+ IsChainInBounds &= all_of(PtrGEP->indices(), IsKnownNonNegative);
----------------
nikic wrote:
That doesn't work, and I couldn't figure out how to make it to work.
https://github.com/llvm/llvm-project/pull/92339
More information about the llvm-commits
mailing list