aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-06-26 22:53:46 +0000
committerDan Gohman <gohman@apple.com>2009-06-26 22:53:46 +0000
commit667d787c0a21cf3f5dfcde03ca471162ba35b614 (patch)
tree717e8620e15b156cca07901a296ab52ea05ac3c5 /include
parentacec7b35aa031a98dcd9ab9263445d1008ee60e5 (diff)
downloadexternal_llvm-667d787c0a21cf3f5dfcde03ca471162ba35b614.zip
external_llvm-667d787c0a21cf3f5dfcde03ca471162ba35b614.tar.gz
external_llvm-667d787c0a21cf3f5dfcde03ca471162ba35b614.tar.bz2
Incorporate the insertion point into the key of SCEVExpander's CSE map.
This helps it avoid reusing an instruction that doesn't dominate all of the users, in cases where the original instruction was inserted before all of the users were known. This may result in redundant expansions of sub-expressions that depend on loop-unpredictable values in some cases, however this isn't very common, and it primarily impacts IndVarSimplify, so GVN can be expected to clean these up. This eliminates the need for IndVarSimplify's FixUsesBeforeDefs, which fixes several bugs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74352 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Analysis/ScalarEvolutionExpander.h48
1 files changed, 16 insertions, 32 deletions
diff --git a/include/llvm/Analysis/ScalarEvolutionExpander.h b/include/llvm/Analysis/ScalarEvolutionExpander.h
index 730c97f..90dba8b 100644
--- a/include/llvm/Analysis/ScalarEvolutionExpander.h
+++ b/include/llvm/Analysis/ScalarEvolutionExpander.h
@@ -28,7 +28,8 @@ namespace llvm {
/// memory.
struct SCEVExpander : public SCEVVisitor<SCEVExpander, Value*> {
ScalarEvolution &SE;
- std::map<const SCEV*, AssertingVH<Value> > InsertedExpressions;
+ std::map<std::pair<const SCEV *, Instruction *>, AssertingVH<Value> >
+ InsertedExpressions;
std::set<Value*> InsertedValues;
BasicBlock::iterator InsertPt;
@@ -43,48 +44,18 @@ namespace llvm {
/// different places within the same BasicBlock can do so.
void clear() { InsertedExpressions.clear(); }
- /// isInsertedInstruction - Return true if the specified instruction was
- /// inserted by the code rewriter. If so, the client should not modify the
- /// instruction.
- bool isInsertedInstruction(Instruction *I) const {
- return InsertedValues.count(I);
- }
-
- /// isInsertedExpression - Return true if the the code rewriter has a
- /// Value* recorded for the given expression.
- bool isInsertedExpression(const SCEV *S) const {
- return InsertedExpressions.count(S);
- }
-
/// getOrInsertCanonicalInductionVariable - This method returns the
/// canonical induction variable of the specified type for the specified
/// loop (inserting one if there is none). A canonical induction variable
/// starts at zero and steps by one on each iteration.
Value *getOrInsertCanonicalInductionVariable(const Loop *L, const Type *Ty);
- /// addInsertedValue - Remember the specified instruction as being the
- /// canonical form for the specified SCEV.
- void addInsertedValue(Value *V, const SCEV *S) {
- InsertedExpressions[S] = V;
- InsertedValues.insert(V);
- }
-
- void setInsertionPoint(BasicBlock::iterator NewIP) { InsertPt = NewIP; }
-
- BasicBlock::iterator getInsertionPoint() const { return InsertPt; }
-
- /// expandCodeFor - Insert code to directly compute the specified SCEV
- /// expression into the program. The inserted code is inserted into the
- /// SCEVExpander's current insertion point. If a type is specified, the
- /// result will be expanded to have that type, with a cast if necessary.
- Value *expandCodeFor(const SCEV* SH, const Type *Ty = 0);
-
/// expandCodeFor - Insert code to directly compute the specified SCEV
/// expression into the program. The inserted code is inserted into the
/// specified block.
Value *expandCodeFor(const SCEV* SH, const Type *Ty,
BasicBlock::iterator IP) {
- setInsertionPoint(IP);
+ InsertPt = IP;
return expandCodeFor(SH, Ty);
}
@@ -111,6 +82,19 @@ namespace llvm {
Value *expand(const SCEV *S);
+ /// expandCodeFor - Insert code to directly compute the specified SCEV
+ /// expression into the program. The inserted code is inserted into the
+ /// SCEVExpander's current insertion point. If a type is specified, the
+ /// result will be expanded to have that type, with a cast if necessary.
+ Value *expandCodeFor(const SCEV* SH, const Type *Ty = 0);
+
+ /// isInsertedInstruction - Return true if the specified instruction was
+ /// inserted by the code rewriter. If so, the client should not modify the
+ /// instruction.
+ bool isInsertedInstruction(Instruction *I) const {
+ return InsertedValues.count(I);
+ }
+
Value *visitConstant(const SCEVConstant *S) {
return S->getValue();
}