Remove unused variables and parameters.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96780 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman
2010-02-22 04:11:59 +00:00
parent fb76fe0929
commit 454d26dc43
4 changed files with 28 additions and 50 deletions

View File

@@ -142,8 +142,7 @@ static bool getSCEVStartAndStride(const SCEV *&SH, Loop *L, Loop *UseLoop,
/// the loop, resulting in reg-reg copies (if we use the pre-inc value when we /// the loop, resulting in reg-reg copies (if we use the pre-inc value when we
/// should use the post-inc value). /// should use the post-inc value).
static bool IVUseShouldUsePostIncValue(Instruction *User, Instruction *IV, static bool IVUseShouldUsePostIncValue(Instruction *User, Instruction *IV,
Loop *L, LoopInfo *LI, DominatorTree *DT, Loop *L, DominatorTree *DT) {
Pass *P) {
// If the user is in the loop, use the preinc value. // If the user is in the loop, use the preinc value.
if (L->contains(User)) return false; if (L->contains(User)) return false;
@@ -245,7 +244,7 @@ bool IVUsers::AddUsersIfInteresting(Instruction *I) {
// Okay, we found a user that we cannot reduce. Analyze the instruction // Okay, we found a user that we cannot reduce. Analyze the instruction
// and decide what to do with it. If we are a use inside of the loop, use // and decide what to do with it. If we are a use inside of the loop, use
// the value before incrementation, otherwise use it after incrementation. // the value before incrementation, otherwise use it after incrementation.
if (IVUseShouldUsePostIncValue(User, I, L, LI, DT, this)) { if (IVUseShouldUsePostIncValue(User, I, L, DT)) {
// The value used will be incremented by the stride more than we are // The value used will be incremented by the stride more than we are
// expecting, so subtract this off. // expecting, so subtract this off.
const SCEV *NewStart = SE->getMinusSCEV(Start, Stride); const SCEV *NewStart = SE->getMinusSCEV(Start, Stride);

View File

@@ -2564,7 +2564,7 @@ ScalarEvolution::ForgetSymbolicName(Instruction *I, const SCEV *SymName) {
SmallPtrSet<Instruction *, 8> Visited; SmallPtrSet<Instruction *, 8> Visited;
Visited.insert(I); Visited.insert(I);
while (!Worklist.empty()) { while (!Worklist.empty()) {
Instruction *I = Worklist.pop_back_val(); I = Worklist.pop_back_val();
if (!Visited.insert(I)) continue; if (!Visited.insert(I)) continue;
std::map<SCEVCallbackVH, const SCEV *>::iterator It = std::map<SCEVCallbackVH, const SCEV *>::iterator It =
@@ -2942,7 +2942,6 @@ ScalarEvolution::getUnsignedRange(const SCEV *S) {
if (const SCEVUnknown *U = dyn_cast<SCEVUnknown>(S)) { if (const SCEVUnknown *U = dyn_cast<SCEVUnknown>(S)) {
// For a SCEVUnknown, ask ValueTracking. // For a SCEVUnknown, ask ValueTracking.
unsigned BitWidth = getTypeSizeInBits(U->getType());
APInt Mask = APInt::getAllOnesValue(BitWidth); APInt Mask = APInt::getAllOnesValue(BitWidth);
APInt Zeros(BitWidth, 0), Ones(BitWidth, 0); APInt Zeros(BitWidth, 0), Ones(BitWidth, 0);
ComputeMaskedBits(U->getValue(), Mask, Zeros, Ones, TD); ComputeMaskedBits(U->getValue(), Mask, Zeros, Ones, TD);
@@ -5367,8 +5366,8 @@ ScalarEvolution::ScalarEvolution()
bool ScalarEvolution::runOnFunction(Function &F) { bool ScalarEvolution::runOnFunction(Function &F) {
this->F = &F; this->F = &F;
LI = &getAnalysis<LoopInfo>(); LI = &getAnalysis<LoopInfo>();
DT = &getAnalysis<DominatorTree>();
TD = getAnalysisIfAvailable<TargetData>(); TD = getAnalysisIfAvailable<TargetData>();
DT = &getAnalysis<DominatorTree>();
return false; return false;
} }

View File

@@ -103,11 +103,9 @@ namespace {
BasicBlock *ExitingBlock, BasicBlock *ExitingBlock,
BranchInst *BI, BranchInst *BI,
SCEVExpander &Rewriter); SCEVExpander &Rewriter);
void RewriteLoopExitValues(Loop *L, const SCEV *BackedgeTakenCount, void RewriteLoopExitValues(Loop *L, SCEVExpander &Rewriter);
SCEVExpander &Rewriter);
void RewriteIVExpressions(Loop *L, const Type *LargestType, void RewriteIVExpressions(Loop *L, SCEVExpander &Rewriter);
SCEVExpander &Rewriter);
void SinkUnusedInvariants(Loop *L); void SinkUnusedInvariants(Loop *L);
@@ -215,7 +213,6 @@ ICmpInst *IndVarSimplify::LinearFunctionTestReplace(Loop *L,
/// able to brute-force evaluate arbitrary instructions as long as they have /// able to brute-force evaluate arbitrary instructions as long as they have
/// constant operands at the beginning of the loop. /// constant operands at the beginning of the loop.
void IndVarSimplify::RewriteLoopExitValues(Loop *L, void IndVarSimplify::RewriteLoopExitValues(Loop *L,
const SCEV *BackedgeTakenCount,
SCEVExpander &Rewriter) { SCEVExpander &Rewriter) {
// Verify the input to the pass in already in LCSSA form. // Verify the input to the pass in already in LCSSA form.
assert(L->isLCSSAForm()); assert(L->isLCSSAForm());
@@ -358,7 +355,7 @@ bool IndVarSimplify::runOnLoop(Loop *L, LPPassManager &LPM) {
// the current expressions. // the current expressions.
// //
if (!isa<SCEVCouldNotCompute>(BackedgeTakenCount)) if (!isa<SCEVCouldNotCompute>(BackedgeTakenCount))
RewriteLoopExitValues(L, BackedgeTakenCount, Rewriter); RewriteLoopExitValues(L, Rewriter);
// Compute the type of the largest recurrence expression, and decide whether // Compute the type of the largest recurrence expression, and decide whether
// a canonical induction variable should be inserted. // a canonical induction variable should be inserted.
@@ -427,7 +424,7 @@ bool IndVarSimplify::runOnLoop(Loop *L, LPPassManager &LPM) {
} }
// Rewrite IV-derived expressions. Clears the rewriter cache. // Rewrite IV-derived expressions. Clears the rewriter cache.
RewriteIVExpressions(L, LargestType, Rewriter); RewriteIVExpressions(L, Rewriter);
// The Rewriter may not be used from this point on. // The Rewriter may not be used from this point on.
@@ -447,8 +444,7 @@ bool IndVarSimplify::runOnLoop(Loop *L, LPPassManager &LPM) {
return Changed; return Changed;
} }
void IndVarSimplify::RewriteIVExpressions(Loop *L, const Type *LargestType, void IndVarSimplify::RewriteIVExpressions(Loop *L, SCEVExpander &Rewriter) {
SCEVExpander &Rewriter) {
SmallVector<WeakVH, 16> DeadInsts; SmallVector<WeakVH, 16> DeadInsts;
// Rewrite all induction variable expressions in terms of the canonical // Rewrite all induction variable expressions in terms of the canonical

View File

@@ -912,7 +912,7 @@ public:
MaxOffset(INT64_MIN), MaxOffset(INT64_MIN),
AllFixupsOutsideLoop(true) {} AllFixupsOutsideLoop(true) {}
bool InsertFormula(size_t LUIdx, const Formula &F); bool InsertFormula(const Formula &F);
void check() const; void check() const;
@@ -922,7 +922,7 @@ public:
/// InsertFormula - If the given formula has not yet been inserted, add it to /// InsertFormula - If the given formula has not yet been inserted, add it to
/// the list, and return true. Return false otherwise. /// the list, and return true. Return false otherwise.
bool LSRUse::InsertFormula(size_t LUIdx, const Formula &F) { bool LSRUse::InsertFormula(const Formula &F) {
SmallVector<const SCEV *, 2> Key = F.BaseRegs; SmallVector<const SCEV *, 2> Key = F.BaseRegs;
if (F.ScaledReg) Key.push_back(F.ScaledReg); if (F.ScaledReg) Key.push_back(F.ScaledReg);
// Unstable sort by host order ok, because this is only used for uniquifying. // Unstable sort by host order ok, because this is only used for uniquifying.
@@ -1057,8 +1057,7 @@ static bool isAlwaysFoldable(int64_t BaseOffs,
GlobalValue *BaseGV, GlobalValue *BaseGV,
bool HasBaseReg, bool HasBaseReg,
LSRUse::KindType Kind, const Type *AccessTy, LSRUse::KindType Kind, const Type *AccessTy,
const TargetLowering *TLI, const TargetLowering *TLI) {
ScalarEvolution &SE) {
// Fast-path: zero is always foldable. // Fast-path: zero is always foldable.
if (BaseOffs == 0 && !BaseGV) return true; if (BaseOffs == 0 && !BaseGV) return true;
@@ -1186,7 +1185,7 @@ class LSRInstance {
const Type *AccessTy); const Type *AccessTy);
public: public:
void InsertInitialFormula(const SCEV *S, Loop *L, LSRUse &LU, size_t LUIdx); void InsertInitialFormula(const SCEV *S, LSRUse &LU, size_t LUIdx);
void InsertSupplementalFormula(const SCEV *S, LSRUse &LU, size_t LUIdx); void InsertSupplementalFormula(const SCEV *S, LSRUse &LU, size_t LUIdx);
void CountRegisters(const Formula &F, size_t LUIdx); void CountRegisters(const Formula &F, size_t LUIdx);
bool InsertFormula(LSRUse &LU, unsigned LUIdx, const Formula &F); bool InsertFormula(LSRUse &LU, unsigned LUIdx, const Formula &F);
@@ -1217,23 +1216,18 @@ public:
Value *Expand(const LSRFixup &LF, Value *Expand(const LSRFixup &LF,
const Formula &F, const Formula &F,
BasicBlock::iterator IP, Loop *L, Instruction *IVIncInsertPos, BasicBlock::iterator IP,
SCEVExpander &Rewriter, SCEVExpander &Rewriter,
SmallVectorImpl<WeakVH> &DeadInsts, SmallVectorImpl<WeakVH> &DeadInsts) const;
ScalarEvolution &SE, DominatorTree &DT) const;
void RewriteForPHI(PHINode *PN, const LSRFixup &LF, void RewriteForPHI(PHINode *PN, const LSRFixup &LF,
const Formula &F, const Formula &F,
Loop *L, Instruction *IVIncInsertPos,
SCEVExpander &Rewriter, SCEVExpander &Rewriter,
SmallVectorImpl<WeakVH> &DeadInsts, SmallVectorImpl<WeakVH> &DeadInsts,
ScalarEvolution &SE, DominatorTree &DT,
Pass *P) const; Pass *P) const;
void Rewrite(const LSRFixup &LF, void Rewrite(const LSRFixup &LF,
const Formula &F, const Formula &F,
Loop *L, Instruction *IVIncInsertPos,
SCEVExpander &Rewriter, SCEVExpander &Rewriter,
SmallVectorImpl<WeakVH> &DeadInsts, SmallVectorImpl<WeakVH> &DeadInsts,
ScalarEvolution &SE, DominatorTree &DT,
Pass *P) const; Pass *P) const;
void ImplementSolution(const SmallVectorImpl<const Formula *> &Solution, void ImplementSolution(const SmallVectorImpl<const Formula *> &Solution,
Pass *P); Pass *P);
@@ -1655,12 +1649,12 @@ LSRInstance::reconcileNewOffset(LSRUse &LU, int64_t NewOffset,
// Conservatively assume HasBaseReg is true for now. // Conservatively assume HasBaseReg is true for now.
if (NewOffset < LU.MinOffset) { if (NewOffset < LU.MinOffset) {
if (!isAlwaysFoldable(LU.MaxOffset - NewOffset, 0, /*HasBaseReg=*/true, if (!isAlwaysFoldable(LU.MaxOffset - NewOffset, 0, /*HasBaseReg=*/true,
Kind, AccessTy, TLI, SE)) Kind, AccessTy, TLI))
return false; return false;
NewMinOffset = NewOffset; NewMinOffset = NewOffset;
} else if (NewOffset > LU.MaxOffset) { } else if (NewOffset > LU.MaxOffset) {
if (!isAlwaysFoldable(NewOffset - LU.MinOffset, 0, /*HasBaseReg=*/true, if (!isAlwaysFoldable(NewOffset - LU.MinOffset, 0, /*HasBaseReg=*/true,
Kind, AccessTy, TLI, SE)) Kind, AccessTy, TLI))
return false; return false;
NewMaxOffset = NewOffset; NewMaxOffset = NewOffset;
} }
@@ -1687,8 +1681,7 @@ LSRInstance::getUse(const SCEV *&Expr,
int64_t Offset = ExtractImmediate(Expr, SE); int64_t Offset = ExtractImmediate(Expr, SE);
// Basic uses can't accept any offset, for example. // Basic uses can't accept any offset, for example.
if (!isAlwaysFoldable(Offset, 0, /*HasBaseReg=*/true, if (!isAlwaysFoldable(Offset, 0, /*HasBaseReg=*/true, Kind, AccessTy, TLI)) {
Kind, AccessTy, TLI, SE)) {
Expr = Copy; Expr = Copy;
Offset = 0; Offset = 0;
} }
@@ -1761,7 +1754,8 @@ void LSRInstance::CollectInterestingTypesAndFactors() {
if (Factor->getValue()->getValue().getMinSignedBits() <= 64) if (Factor->getValue()->getValue().getMinSignedBits() <= 64)
Factors.insert(Factor->getValue()->getValue().getSExtValue()); Factors.insert(Factor->getValue()->getValue().getSExtValue());
} else if (const SCEVConstant *Factor = } else if (const SCEVConstant *Factor =
dyn_cast_or_null<SCEVConstant>(getExactSDiv(OldStride, NewStride, dyn_cast_or_null<SCEVConstant>(getExactSDiv(OldStride,
NewStride,
SE, true))) { SE, true))) {
if (Factor->getValue()->getValue().getMinSignedBits() <= 64) if (Factor->getValue()->getValue().getMinSignedBits() <= 64)
Factors.insert(Factor->getValue()->getValue().getSExtValue()); Factors.insert(Factor->getValue()->getValue().getSExtValue());
@@ -1834,7 +1828,7 @@ void LSRInstance::CollectFixupsAndInitialFormulae() {
// If this is the first use of this LSRUse, give it a formula. // If this is the first use of this LSRUse, give it a formula.
if (LU.Formulae.empty()) { if (LU.Formulae.empty()) {
InsertInitialFormula(S, L, LU, LF.LUIdx); InsertInitialFormula(S, LU, LF.LUIdx);
CountRegisters(LU.Formulae.back(), LF.LUIdx); CountRegisters(LU.Formulae.back(), LF.LUIdx);
} }
} }
@@ -1843,8 +1837,7 @@ void LSRInstance::CollectFixupsAndInitialFormulae() {
} }
void void
LSRInstance::InsertInitialFormula(const SCEV *S, Loop *L, LSRInstance::InsertInitialFormula(const SCEV *S, LSRUse &LU, size_t LUIdx) {
LSRUse &LU, size_t LUIdx) {
Formula F; Formula F;
F.InitialMatch(S, L, SE, DT); F.InitialMatch(S, L, SE, DT);
bool Inserted = InsertFormula(LU, LUIdx, F); bool Inserted = InsertFormula(LU, LUIdx, F);
@@ -1874,7 +1867,7 @@ void LSRInstance::CountRegisters(const Formula &F, size_t LUIdx) {
/// InsertFormula - If the given formula has not yet been inserted, add it to /// InsertFormula - If the given formula has not yet been inserted, add it to
/// the list, and return true. Return false otherwise. /// the list, and return true. Return false otherwise.
bool LSRInstance::InsertFormula(LSRUse &LU, unsigned LUIdx, const Formula &F) { bool LSRInstance::InsertFormula(LSRUse &LU, unsigned LUIdx, const Formula &F) {
if (!LU.InsertFormula(LUIdx, F)) if (!LU.InsertFormula(F))
return false; return false;
CountRegisters(F, LUIdx); CountRegisters(F, LUIdx);
@@ -2786,10 +2779,8 @@ static BasicBlock *getImmediateDominator(BasicBlock *BB, DominatorTree &DT) {
Value *LSRInstance::Expand(const LSRFixup &LF, Value *LSRInstance::Expand(const LSRFixup &LF,
const Formula &F, const Formula &F,
BasicBlock::iterator IP, BasicBlock::iterator IP,
Loop *L, Instruction *IVIncInsertPos,
SCEVExpander &Rewriter, SCEVExpander &Rewriter,
SmallVectorImpl<WeakVH> &DeadInsts, SmallVectorImpl<WeakVH> &DeadInsts) const {
ScalarEvolution &SE, DominatorTree &DT) const {
const LSRUse &LU = Uses[LF.LUIdx]; const LSRUse &LU = Uses[LF.LUIdx];
// Then, collect some instructions which we will remain dominated by when // Then, collect some instructions which we will remain dominated by when
@@ -2979,10 +2970,8 @@ Value *LSRInstance::Expand(const LSRFixup &LF,
void LSRInstance::RewriteForPHI(PHINode *PN, void LSRInstance::RewriteForPHI(PHINode *PN,
const LSRFixup &LF, const LSRFixup &LF,
const Formula &F, const Formula &F,
Loop *L, Instruction *IVIncInsertPos,
SCEVExpander &Rewriter, SCEVExpander &Rewriter,
SmallVectorImpl<WeakVH> &DeadInsts, SmallVectorImpl<WeakVH> &DeadInsts,
ScalarEvolution &SE, DominatorTree &DT,
Pass *P) const { Pass *P) const {
DenseMap<BasicBlock *, Value *> Inserted; DenseMap<BasicBlock *, Value *> Inserted;
for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i)
@@ -3016,8 +3005,7 @@ void LSRInstance::RewriteForPHI(PHINode *PN,
if (!Pair.second) if (!Pair.second)
PN->setIncomingValue(i, Pair.first->second); PN->setIncomingValue(i, Pair.first->second);
else { else {
Value *FullV = Expand(LF, F, BB->getTerminator(), L, IVIncInsertPos, Value *FullV = Expand(LF, F, BB->getTerminator(), Rewriter, DeadInsts);
Rewriter, DeadInsts, SE, DT);
// If this is reuse-by-noop-cast, insert the noop cast. // If this is reuse-by-noop-cast, insert the noop cast.
const Type *OpTy = LF.OperandValToReplace->getType(); const Type *OpTy = LF.OperandValToReplace->getType();
@@ -3039,18 +3027,15 @@ void LSRInstance::RewriteForPHI(PHINode *PN,
/// the newly expanded value. /// the newly expanded value.
void LSRInstance::Rewrite(const LSRFixup &LF, void LSRInstance::Rewrite(const LSRFixup &LF,
const Formula &F, const Formula &F,
Loop *L, Instruction *IVIncInsertPos,
SCEVExpander &Rewriter, SCEVExpander &Rewriter,
SmallVectorImpl<WeakVH> &DeadInsts, SmallVectorImpl<WeakVH> &DeadInsts,
ScalarEvolution &SE, DominatorTree &DT,
Pass *P) const { Pass *P) const {
// First, find an insertion point that dominates UserInst. For PHI nodes, // First, find an insertion point that dominates UserInst. For PHI nodes,
// find the nearest block which dominates all the relevant uses. // find the nearest block which dominates all the relevant uses.
if (PHINode *PN = dyn_cast<PHINode>(LF.UserInst)) { if (PHINode *PN = dyn_cast<PHINode>(LF.UserInst)) {
RewriteForPHI(PN, LF, F, L, IVIncInsertPos, Rewriter, DeadInsts, SE, DT, P); RewriteForPHI(PN, LF, F, Rewriter, DeadInsts, P);
} else { } else {
Value *FullV = Expand(LF, F, LF.UserInst, L, IVIncInsertPos, Value *FullV = Expand(LF, F, LF.UserInst, Rewriter, DeadInsts);
Rewriter, DeadInsts, SE, DT);
// If this is reuse-by-noop-cast, insert the noop cast. // If this is reuse-by-noop-cast, insert the noop cast.
const Type *OpTy = LF.OperandValToReplace->getType(); const Type *OpTy = LF.OperandValToReplace->getType();
@@ -3090,8 +3075,7 @@ LSRInstance::ImplementSolution(const SmallVectorImpl<const Formula *> &Solution,
for (size_t i = 0, e = Fixups.size(); i != e; ++i) { for (size_t i = 0, e = Fixups.size(); i != e; ++i) {
size_t LUIdx = Fixups[i].LUIdx; size_t LUIdx = Fixups[i].LUIdx;
Rewrite(Fixups[i], *Solution[LUIdx], L, IVIncInsertPos, Rewriter, Rewrite(Fixups[i], *Solution[LUIdx], Rewriter, DeadInsts, P);
DeadInsts, SE, DT, P);
Changed = true; Changed = true;
} }