[llvm] e6a5dd6 - [SCEV] Assert unique pointer base (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 29 11:06:35 PDT 2021
Author: Nikita Popov
Date: 2021-08-29T20:06:24+02:00
New Revision: e6a5dd60ffa3073c0ab69f9b1836cf2e743bcf0c
URL: https://github.com/llvm/llvm-project/commit/e6a5dd60ffa3073c0ab69f9b1836cf2e743bcf0c
DIFF: https://github.com/llvm/llvm-project/commit/e6a5dd60ffa3073c0ab69f9b1836cf2e743bcf0c.diff
LOG: [SCEV] Assert unique pointer base (NFC)
Add expressions can contain at most one pointer operand nowadays,
assert that in getPointerBase() and removePointerBase().
Added:
Modified:
llvm/lib/Analysis/ScalarEvolution.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index cc966497bb729..5539c620a93f5 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -4172,11 +4172,7 @@ static const SCEV *removePointerBase(ScalarEvolution *SE, const SCEV *P) {
const SCEV **PtrOp = nullptr;
for (const SCEV *&AddOp : Ops) {
if (AddOp->getType()->isPointerTy()) {
- // If we find an Add with multiple pointer operands, treat it as a
- // pointer base to be consistent with getPointerBase. Eventually
- // we should be able to assert this is impossible.
- if (PtrOp)
- return SE->getZero(P->getType());
+ assert(!PtrOp && "Cannot have multiple pointer ops");
PtrOp = &AddOp;
}
}
@@ -4367,14 +4363,11 @@ const SCEV *ScalarEvolution::getPointerBase(const SCEV *V) {
const SCEV *PtrOp = nullptr;
for (const SCEV *AddOp : Add->operands()) {
if (AddOp->getType()->isPointerTy()) {
- // Cannot find the base of an expression with multiple pointer ops.
- if (PtrOp)
- return V;
+ assert(!PtrOp && "Cannot have multiple pointer ops");
PtrOp = AddOp;
}
}
- if (!PtrOp) // All operands were non-pointer.
- return V;
+ assert(PtrOp && "Must have pointer op");
V = PtrOp;
} else // Not something we can look further into.
return V;
More information about the llvm-commits
mailing list