diff options
author | Dan Gohman <gohman@apple.com> | 2009-04-16 03:18:22 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-04-16 03:18:22 +0000 |
commit | 01c2ee779d0fe270c3378c2aba4de9ea94bb3b34 (patch) | |
tree | fa16eff022c8808a5eb6aedb159ea653af0faae9 /include | |
parent | 4cd1c584bfda4e9c560f08884ff48556ec869d80 (diff) | |
download | external_llvm-01c2ee779d0fe270c3378c2aba4de9ea94bb3b34.zip external_llvm-01c2ee779d0fe270c3378c2aba4de9ea94bb3b34.tar.gz external_llvm-01c2ee779d0fe270c3378c2aba4de9ea94bb3b34.tar.bz2 |
Expand GEPs in ScalarEvolution expressions. SCEV expressions can now
have pointer types, though in contrast to C pointer types, SCEV
addition is never implicitly scaled. This not only eliminates the
need for special code like IndVars' EliminatePointerRecurrence
and LSR's own GEP expansion code, it also does a better job because
it lets the normal optimizations handle pointer expressions just
like integer expressions.
Also, since LLVM IR GEPs can't directly index into multi-dimensional
VLAs, moving the GEP analysis out of client code and into the SCEV
framework makes it easier for clients to handle multi-dimensional
VLAs the same way as other arrays.
Some existing regression tests show improved optimization.
test/CodeGen/ARM/2007-03-13-InstrSched.ll in particular improved to
the point where if-conversion started kicking in; I turned it off
for this test to preserve the intent of the test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@69258 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Analysis/ScalarEvolution.h | 9 | ||||
-rw-r--r-- | include/llvm/Analysis/ScalarEvolutionExpander.h | 10 |
2 files changed, 12 insertions, 7 deletions
diff --git a/include/llvm/Analysis/ScalarEvolution.h b/include/llvm/Analysis/ScalarEvolution.h index 0b148da..e923ae5 100644 --- a/include/llvm/Analysis/ScalarEvolution.h +++ b/include/llvm/Analysis/ScalarEvolution.h @@ -32,6 +32,7 @@ namespace llvm { class Type; class SCEVHandle; class ScalarEvolution; + class TargetData; /// SCEV - This class represent an analyzed expression in the program. These /// are reference counted opaque objects that the client is not allowed to @@ -71,10 +72,6 @@ namespace llvm { /// virtual const Type *getType() const = 0; - /// getBitWidth - Get the bit width of the type, if it has one, 0 otherwise. - /// - uint32_t getBitWidth() const; - /// isZero - Return true if the expression is a constant zero. /// bool isZero() const; @@ -199,6 +196,10 @@ namespace llvm { static char ID; // Pass identification, replacement for typeid ScalarEvolution() : FunctionPass(&ID), Impl(0) {} + // getTargetData - Return the TargetData object contained in this + // ScalarEvolution. + const TargetData &getTargetData() const; + /// getSCEV - Return a SCEV expression handle for the full generality of the /// specified expression. SCEVHandle getSCEV(Value *V) const; diff --git a/include/llvm/Analysis/ScalarEvolutionExpander.h b/include/llvm/Analysis/ScalarEvolutionExpander.h index cd075ef..8126a58 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpander.h +++ b/include/llvm/Analysis/ScalarEvolutionExpander.h @@ -20,6 +20,8 @@ #include "llvm/Analysis/ScalarEvolutionExpressions.h" namespace llvm { + class TargetData; + /// SCEVExpander - This class uses information about analyze scalars to /// rewrite expressions in canonical form. /// @@ -29,6 +31,7 @@ namespace llvm { struct SCEVExpander : public SCEVVisitor<SCEVExpander, Value*> { ScalarEvolution &SE; LoopInfo &LI; + const TargetData &TD; std::map<SCEVHandle, Value*> InsertedExpressions; std::set<Instruction*> InsertedInstructions; @@ -36,7 +39,8 @@ namespace llvm { friend struct SCEVVisitor<SCEVExpander, Value*>; public: - SCEVExpander(ScalarEvolution &se, LoopInfo &li) : SE(se), LI(li) {} + SCEVExpander(ScalarEvolution &se, LoopInfo &li, const TargetData &td) + : SE(se), LI(li), TD(td) {} LoopInfo &getLoopInfo() const { return LI; } @@ -75,7 +79,7 @@ namespace llvm { /// expandCodeFor - Insert code to directly compute the specified SCEV /// expression into the program. The inserted code is inserted into the /// specified block. - Value *expandCodeFor(SCEVHandle SH, Instruction *IP); + Value *expandCodeFor(SCEVHandle SH, const Type *Ty, Instruction *IP); /// InsertCastOfTo - Insert a cast of V to the specified type, doing what /// we can to share the casts. @@ -87,7 +91,7 @@ namespace llvm { Value *RHS, Instruction *InsertPt); protected: Value *expand(SCEV *S); - + Value *visitConstant(SCEVConstant *S) { return S->getValue(); } |