@@ -271,9 +271,10 @@ FunctionPass *llvm::createStraightLineStrengthReducePass() {
271271
272272bool StraightLineStrengthReduce::isBasisFor (const Candidate &Basis,
273273 const Candidate &C) {
274- return (Basis.Ins != C.Ins && // skip the same instruction
275- // They must have the same type too. Basis.Base == C.Base doesn't
276- // guarantee their types are the same (PR23975).
274+ return (Basis.Ins !=
275+ C.Ins && // skip the same instruction
276+ // They must have the same type too. Basis.Base == C.Base
277+ // doesn't guarantee their types are the same (PR23975).
277278 Basis.Ins ->getType () == C.Ins ->getType () &&
278279 // Basis must dominate C in order to rewrite C with respect to Basis.
279280 DT->dominates (Basis.Ins ->getParent (), C.Ins ->getParent ()) &&
@@ -614,6 +615,9 @@ Value *StraightLineStrengthReduce::emitBump(const Candidate &Basis,
614615
615616void StraightLineStrengthReduce::rewriteCandidateWithBasis (
616617 const Candidate &C, const Candidate &Basis) {
618+ if (!DebugCounter::shouldExecute (StraightLineStrengthReduceCounter))
619+ return ;
620+
617621 assert (C.CandidateKind == Basis.CandidateKind && C.Base == Basis.Base &&
618622 C.Stride == Basis.Stride );
619623 // We run rewriteCandidateWithBasis on all candidates in a post-order, so the
@@ -694,8 +698,7 @@ bool StraightLineStrengthReduce::runOnFunction(Function &F) {
694698 while (!Candidates.empty ()) {
695699 const Candidate &C = Candidates.back ();
696700 if (C.Basis != nullptr ) {
697- if (DebugCounter::shouldExecute (StraightLineStrengthReduceCounter))
698- rewriteCandidateWithBasis (C, *C.Basis );
701+ rewriteCandidateWithBasis (C, *C.Basis );
699702 }
700703 Candidates.pop_back ();
701704 }
0 commit comments