diff options
author | Dan Gohman <gohman@apple.com> | 2009-05-19 02:15:55 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-05-19 02:15:55 +0000 |
commit | 5be18e84766fb495b0bde3c8244c1df459a18683 (patch) | |
tree | 77d5bd8b1b5961b4ed2fd11e271e32fe9ce2fd99 /lib/Analysis/ScalarEvolution.cpp | |
parent | fb57f1c8ec95714f7eb4650004539e004bb2db02 (diff) |
Teach SCEVExpander to expand arithmetic involving pointers into GEP
instructions. It attempts to create high-level multi-operand GEPs,
though in cases where this isn't possible it falls back to casting
the pointer to i8* and emitting a GEP with that. Using GEP instructions
instead of ptrtoint+arithmetic+inttoptr helps pointer analyses that
don't use ScalarEvolution, such as BasicAliasAnalysis.
Also, make the AddrModeMatcher more aggressive in handling GEPs.
Previously it assumed that operand 0 of a GEP would require a register
in almost all cases. It now does extra checking and can do more
matching if operand 0 of the GEP is foldable. This fixes a problem
that was exposed by SCEVExpander using GEPs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72093 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolution.cpp')
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index eaa847aa10..0857014863 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -456,6 +456,13 @@ namespace { if (const SCEVUnknown *LU = dyn_cast<SCEVUnknown>(LHS)) { const SCEVUnknown *RU = cast<SCEVUnknown>(RHS); + // Order pointer values after integer values. This helps SCEVExpander + // form GEPs. + if (isa<PointerType>(LU->getType()) && !isa<PointerType>(RU->getType())) + return false; + if (isa<PointerType>(RU->getType()) && !isa<PointerType>(LU->getType())) + return true; + // Compare getValueID values. if (LU->getValue()->getValueID() != RU->getValue()->getValueID()) return LU->getValue()->getValueID() < RU->getValue()->getValueID(); |