7878#include " llvm/InitializePasses.h"
7979#include " llvm/Pass.h"
8080#include " llvm/Support/Casting.h"
81+ #include " llvm/Support/DebugCounter.h"
8182#include " llvm/Support/ErrorHandling.h"
8283#include " llvm/Transforms/Scalar.h"
8384#include " llvm/Transforms/Utils/Local.h"
@@ -93,6 +94,9 @@ using namespace PatternMatch;
9394static const unsigned UnknownAddressSpace =
9495 std::numeric_limits<unsigned >::max();
9596
97+ DEBUG_COUNTER (StraightLineStrengthReduceCounter, " slsr-counter" ,
98+ " Controls whether rewriteCandidateWithBasis is executed." );
99+
96100namespace {
97101
98102class StraightLineStrengthReduceLegacyPass : public FunctionPass {
@@ -268,8 +272,8 @@ FunctionPass *llvm::createStraightLineStrengthReducePass() {
268272bool StraightLineStrengthReduce::isBasisFor (const Candidate &Basis,
269273 const Candidate &C) {
270274 return (Basis.Ins != C.Ins && // skip the same instruction
271- // They must have the same type too. Basis.Base == C.Base doesn't
272- // guarantee their types are the same (PR23975).
275+ // They must have the same type too. Basis.Base == C.Base
276+ // doesn't guarantee their types are the same (PR23975).
273277 Basis.Ins ->getType () == C.Ins ->getType () &&
274278 // Basis must dominate C in order to rewrite C with respect to Basis.
275279 DT->dominates (Basis.Ins ->getParent (), C.Ins ->getParent ()) &&
@@ -610,6 +614,9 @@ Value *StraightLineStrengthReduce::emitBump(const Candidate &Basis,
610614
611615void StraightLineStrengthReduce::rewriteCandidateWithBasis (
612616 const Candidate &C, const Candidate &Basis) {
617+ if (!DebugCounter::shouldExecute (StraightLineStrengthReduceCounter))
618+ return ;
619+
613620 assert (C.CandidateKind == Basis.CandidateKind && C.Base == Basis.Base &&
614621 C.Stride == Basis.Stride );
615622 // We run rewriteCandidateWithBasis on all candidates in a post-order, so the
0 commit comments