summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ScalarEvolution.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-02-11 21:43:33 +0000
committerChris Lattner <sabre@nondot.org>2011-02-11 21:43:33 +0000
commit7936a8a488c8f967cf42b9b5ef8c30b3a989e345 (patch)
treecbe68cb6c3f509c40a32689d657ea4814cfd8c4a /llvm/lib/Analysis/ScalarEvolution.cpp
parentd3c0e05f51d7db1fc3d3af89c2c7ce10c5957354 (diff)
downloadbcm5719-llvm-7936a8a488c8f967cf42b9b5ef8c30b3a989e345.tar.gz
bcm5719-llvm-7936a8a488c8f967cf42b9b5ef8c30b3a989e345.zip
Per discussion with Dan G, inbounds geps *certainly* can have
unsigned overflow (e.g. "gep P, -1"), and while they can have signed wrap in theoretical situations, modelling an AddRec as not having signed wrap is going enough for any case we can think of today. In the future if this isn't enough, we can revisit this. Modeling them as having NUW isn't causing any known problems either FWIW. llvm-svn: 125410
Diffstat (limited to 'llvm/lib/Analysis/ScalarEvolution.cpp')
-rw-r--r--llvm/lib/Analysis/ScalarEvolution.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp
index c2f3ac071de..aab95ae1f64 100644
--- a/llvm/lib/Analysis/ScalarEvolution.cpp
+++ b/llvm/lib/Analysis/ScalarEvolution.cpp
@@ -2785,10 +2785,21 @@ const SCEV *ScalarEvolution::createNodeForPHI(PHINode *PN) {
HasNSW = true;
} else if (const GEPOperator *GEP =
dyn_cast<GEPOperator>(BEValueV)) {
- // If the increment is a GEP, then we know it won't perform an
- // unsigned overflow, because the address space cannot be
+ // If the increment is a GEP, then we know it won't perform a
+ // signed overflow, because the address space cannot be
// wrapped around.
- HasNUW |= GEP->isInBounds();
+ //
+ // NOTE: This isn't strictly true, because you could have an
+ // object straddling the 2G address boundary in a 32-bit address
+ // space (for example). We really want to model this as a "has
+ // no signed/unsigned wrap" where the base pointer is treated as
+ // unsigned and the increment is known to not have signed
+ // wrapping.
+ //
+ // This is a highly theoretical concern though, and this is good
+ // enough for all cases we know of at this point. :)
+ //
+ HasNSW |= GEP->isInBounds();
}
const SCEV *StartVal = getSCEV(StartValueV);
OpenPOWER on IntegriCloud