78
78
#include " llvm/InitializePasses.h"
79
79
#include " llvm/Pass.h"
80
80
#include " llvm/Support/Casting.h"
81
+ #include " llvm/Support/DebugCounter.h"
81
82
#include " llvm/Support/ErrorHandling.h"
82
83
#include " llvm/Transforms/Scalar.h"
83
84
#include " llvm/Transforms/Utils/Local.h"
@@ -93,6 +94,9 @@ using namespace PatternMatch;
93
94
static const unsigned UnknownAddressSpace =
94
95
std::numeric_limits<unsigned >::max();
95
96
97
+ DEBUG_COUNTER (StraightLineStrengthReduceCounter, " slsr-counter" ,
98
+ " Controls whether rewriteCandidateWithBasis is executed." );
99
+
96
100
namespace {
97
101
98
102
class StraightLineStrengthReduceLegacyPass : public FunctionPass {
@@ -268,8 +272,8 @@ FunctionPass *llvm::createStraightLineStrengthReducePass() {
268
272
bool StraightLineStrengthReduce::isBasisFor (const Candidate &Basis,
269
273
const Candidate &C) {
270
274
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).
273
277
Basis.Ins ->getType () == C.Ins ->getType () &&
274
278
// Basis must dominate C in order to rewrite C with respect to Basis.
275
279
DT->dominates (Basis.Ins ->getParent (), C.Ins ->getParent ()) &&
@@ -610,6 +614,9 @@ Value *StraightLineStrengthReduce::emitBump(const Candidate &Basis,
610
614
611
615
void StraightLineStrengthReduce::rewriteCandidateWithBasis (
612
616
const Candidate &C, const Candidate &Basis) {
617
+ if (!DebugCounter::shouldExecute (StraightLineStrengthReduceCounter))
618
+ return ;
619
+
613
620
assert (C.CandidateKind == Basis.CandidateKind && C.Base == Basis.Base &&
614
621
C.Stride == Basis.Stride );
615
622
// We run rewriteCandidateWithBasis on all candidates in a post-order, so the
0 commit comments