[llvm-branch-commits] [llvm-branch] r109612 - in /llvm/branches/Apple/williamson/lib/Analysis: ScalarEvolution.cpp ScalarEvolution.cpp.orig
Daniel Dunbar
daniel at zuster.org
Wed Jul 28 11:40:47 PDT 2010
Author: ddunbar
Date: Wed Jul 28 13:40:47 2010
New Revision: 109612
URL: http://llvm.org/viewvc/llvm-project?rev=109612&view=rev
Log:
Merge r109567:
--
Author: Dan Gohman <gohman at apple.com>
Date: Wed Jul 28 00:28:25 2010 +0000
Make SCEVCallbackVH::allUsesReplacedWith unconditionally delete
the old value.
Modified:
llvm/branches/Apple/williamson/lib/Analysis/ScalarEvolution.cpp
llvm/branches/Apple/williamson/lib/Analysis/ScalarEvolution.cpp.orig
Modified: llvm/branches/Apple/williamson/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/williamson/lib/Analysis/ScalarEvolution.cpp?rev=109612&r1=109611&r2=109612&view=diff
==============================================================================
--- llvm/branches/Apple/williamson/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/branches/Apple/williamson/lib/Analysis/ScalarEvolution.cpp Wed Jul 28 13:40:47 2010
@@ -5695,7 +5695,6 @@
SmallVector<User *, 16> Worklist;
SmallPtrSet<User *, 8> Visited;
Value *Old = getValPtr();
- bool DeleteOld = false;
for (Value::use_iterator UI = Old->use_begin(), UE = Old->use_end();
UI != UE; ++UI)
Worklist.push_back(*UI);
@@ -5703,10 +5702,8 @@
User *U = Worklist.pop_back_val();
// Deleting the Old value will cause this to dangle. Postpone
// that until everything else is done.
- if (U == Old) {
- DeleteOld = true;
+ if (U == Old)
continue;
- }
if (!Visited.insert(U))
continue;
if (PHINode *PN = dyn_cast<PHINode>(U))
@@ -5716,14 +5713,11 @@
UI != UE; ++UI)
Worklist.push_back(*UI);
}
- // Delete the Old value if it (indirectly) references itself.
- if (DeleteOld) {
- if (PHINode *PN = dyn_cast<PHINode>(Old))
- SE->ConstantEvolutionLoopExitValue.erase(PN);
- SE->Scalars.erase(Old);
- // this now dangles!
- }
- // this may dangle!
+ // Delete the Old value.
+ if (PHINode *PN = dyn_cast<PHINode>(Old))
+ SE->ConstantEvolutionLoopExitValue.erase(PN);
+ SE->Scalars.erase(Old);
+ // this now dangles!
}
ScalarEvolution::SCEVCallbackVH::SCEVCallbackVH(Value *V, ScalarEvolution *se)
Modified: llvm/branches/Apple/williamson/lib/Analysis/ScalarEvolution.cpp.orig
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/williamson/lib/Analysis/ScalarEvolution.cpp.orig?rev=109612&r1=109611&r2=109612&view=diff
==============================================================================
--- llvm/branches/Apple/williamson/lib/Analysis/ScalarEvolution.cpp.orig (original)
+++ llvm/branches/Apple/williamson/lib/Analysis/ScalarEvolution.cpp.orig Wed Jul 28 13:40:47 2010
@@ -495,9 +495,9 @@
/// than the complexity of the RHS. This comparator is used to canonicalize
/// expressions.
class SCEVComplexityCompare {
- LoopInfo *LI;
+ const LoopInfo *LI;
public:
- explicit SCEVComplexityCompare(LoopInfo *li) : LI(li) {}
+ explicit SCEVComplexityCompare(const LoopInfo *li) : LI(li) {}
bool operator()(const SCEV *LHS, const SCEV *RHS) const {
// Fast-path: SCEVs are uniqued so we can do a quick equality check.
@@ -505,8 +505,9 @@
return false;
// Primarily, sort the SCEVs by their getSCEVType().
- if (LHS->getSCEVType() != RHS->getSCEVType())
- return LHS->getSCEVType() < RHS->getSCEVType();
+ unsigned LType = LHS->getSCEVType(), RType = RHS->getSCEVType();
+ if (LType != RType)
+ return LType < RType;
// Aside from the getSCEVType() ordering, the particular ordering
// isn't very important except that it's beneficial to be consistent,
@@ -519,14 +520,16 @@
// Order pointer values after integer values. This helps SCEVExpander
// form GEPs.
- if (LU->getType()->isPointerTy() && !RU->getType()->isPointerTy())
- return false;
- if (RU->getType()->isPointerTy() && !LU->getType()->isPointerTy())
- return true;
+ bool LIsPointer = LU->getType()->isPointerTy(),
+ RIsPointer = RU->getType()->isPointerTy();
+ if (LIsPointer != RIsPointer)
+ return RIsPointer;
// Compare getValueID values.
- if (LU->getValue()->getValueID() != RU->getValue()->getValueID())
- return LU->getValue()->getValueID() < RU->getValue()->getValueID();
+ unsigned LID = LU->getValue()->getValueID(),
+ RID = RU->getValue()->getValueID();
+ if (LID != RID)
+ return LID < RID;
// Sort arguments by their position.
if (const Argument *LA = dyn_cast<Argument>(LU->getValue())) {
@@ -536,22 +539,20 @@
// For instructions, compare their loop depth, and their opcode.
// This is pretty loose.
- if (Instruction *LV = dyn_cast<Instruction>(LU->getValue())) {
- Instruction *RV = cast<Instruction>(RU->getValue());
+ if (const Instruction *LV = dyn_cast<Instruction>(LU->getValue())) {
+ const Instruction *RV = cast<Instruction>(RU->getValue());
// Compare loop depths.
- if (LI->getLoopDepth(LV->getParent()) !=
- LI->getLoopDepth(RV->getParent()))
- return LI->getLoopDepth(LV->getParent()) <
- LI->getLoopDepth(RV->getParent());
-
- // Compare opcodes.
- if (LV->getOpcode() != RV->getOpcode())
- return LV->getOpcode() < RV->getOpcode();
+ unsigned LDepth = LI->getLoopDepth(LV->getParent()),
+ RDepth = LI->getLoopDepth(RV->getParent());
+ if (LDepth != RDepth)
+ return LDepth < RDepth;
// Compare the number of operands.
- if (LV->getNumOperands() != RV->getNumOperands())
- return LV->getNumOperands() < RV->getNumOperands();
+ unsigned LNumOps = LV->getNumOperands(),
+ RNumOps = RV->getNumOperands();
+ if (LNumOps != RNumOps)
+ return LNumOps < RNumOps;
}
return false;
@@ -560,42 +561,51 @@
// Compare constant values.
if (const SCEVConstant *LC = dyn_cast<SCEVConstant>(LHS)) {
const SCEVConstant *RC = cast<SCEVConstant>(RHS);
- if (LC->getValue()->getBitWidth() != RC->getValue()->getBitWidth())
- return LC->getValue()->getBitWidth() < RC->getValue()->getBitWidth();
- return LC->getValue()->getValue().ult(RC->getValue()->getValue());
+ const ConstantInt *LCC = LC->getValue();
+ const ConstantInt *RCC = RC->getValue();
+ unsigned LBitWidth = LCC->getBitWidth(), RBitWidth = RCC->getBitWidth();
+ if (LBitWidth != RBitWidth)
+ return LBitWidth < RBitWidth;
+ return LCC->getValue().ult(RCC->getValue());
}
// Compare addrec loop depths.
if (const SCEVAddRecExpr *LA = dyn_cast<SCEVAddRecExpr>(LHS)) {
const SCEVAddRecExpr *RA = cast<SCEVAddRecExpr>(RHS);
- if (LA->getLoop()->getLoopDepth() != RA->getLoop()->getLoopDepth())
- return LA->getLoop()->getLoopDepth() < RA->getLoop()->getLoopDepth();
+ unsigned LDepth = LA->getLoop()->getLoopDepth(),
+ RDepth = RA->getLoop()->getLoopDepth();
+ if (LDepth != RDepth)
+ return LDepth < RDepth;
}
// Lexicographically compare n-ary expressions.
if (const SCEVNAryExpr *LC = dyn_cast<SCEVNAryExpr>(LHS)) {
const SCEVNAryExpr *RC = cast<SCEVNAryExpr>(RHS);
- for (unsigned i = 0, e = LC->getNumOperands(); i != e; ++i) {
- if (i >= RC->getNumOperands())
+ unsigned LNumOps = LC->getNumOperands(), RNumOps = RC->getNumOperands();
+ for (unsigned i = 0; i != LNumOps; ++i) {
+ if (i >= RNumOps)
return false;
- if (operator()(LC->getOperand(i), RC->getOperand(i)))
+ const SCEV *LOp = LC->getOperand(i), *ROp = RC->getOperand(i);
+ if (operator()(LOp, ROp))
return true;
- if (operator()(RC->getOperand(i), LC->getOperand(i)))
+ if (operator()(ROp, LOp))
return false;
}
- return LC->getNumOperands() < RC->getNumOperands();
+ return LNumOps < RNumOps;
}
// Lexicographically compare udiv expressions.
if (const SCEVUDivExpr *LC = dyn_cast<SCEVUDivExpr>(LHS)) {
const SCEVUDivExpr *RC = cast<SCEVUDivExpr>(RHS);
- if (operator()(LC->getLHS(), RC->getLHS()))
+ const SCEV *LL = LC->getLHS(), *LR = LC->getRHS(),
+ *RL = RC->getLHS(), *RR = RC->getRHS();
+ if (operator()(LL, RL))
return true;
- if (operator()(RC->getLHS(), LC->getLHS()))
+ if (operator()(RL, LL))
return false;
- if (operator()(LC->getRHS(), RC->getRHS()))
+ if (operator()(LR, RR))
return true;
- if (operator()(RC->getRHS(), LC->getRHS()))
+ if (operator()(RR, LR))
return false;
return false;
}
@@ -2584,7 +2594,7 @@
// Push the def-use children onto the Worklist stack.
for (Value::use_iterator UI = I->use_begin(), UE = I->use_end();
UI != UE; ++UI)
- Worklist.push_back(cast<Instruction>(UI));
+ Worklist.push_back(cast<Instruction>(*UI));
}
/// ForgetSymbolicValue - This looks up computed SCEV values for all
More information about the llvm-branch-commits
mailing list