File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 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 {
@@ -690,7 +694,8 @@ bool StraightLineStrengthReduce::runOnFunction(Function &F) {
690694 while (!Candidates.empty ()) {
691695 const Candidate &C = Candidates.back ();
692696 if (C.Basis != nullptr ) {
693- rewriteCandidateWithBasis (C, *C.Basis );
697+ if (DebugCounter::shouldExecute (StraightLineStrengthReduceCounter))
698+ rewriteCandidateWithBasis (C, *C.Basis );
694699 }
695700 Candidates.pop_back ();
696701 }
Original file line number Diff line number Diff line change 1+ ; REQUIRES: asserts
2+ ; RUN: opt -passes=slsr,gvn -S -debug-counter=slsr-counter=1 < %s | FileCheck %s
3+
4+ ;; Test that, with debug counters on, we will skip the first slsr opportunity.
5+
6+ define void @stride_is_2s (i32 %b , i32 %s ) {
7+ ; CHECK-LABEL: @stride_is_2s(
8+ ; CHECK-NEXT: %s2 = shl i32 %s, 1
9+ ; CHECK-NEXT: %t1 = add i32 %b, %s2
10+ ; CHECK-NEXT: call void @foo(i32 %t1)
11+ ; CHECK-NEXT: %t2 = add i32 %t1, %s2
12+ ; CHECK-NEXT: call void @foo(i32 %t2)
13+ ; CHECK-NEXT: %s6 = mul i32 %s, 6
14+ ; CHECK-NEXT: %t3 = add i32 %b, %s6
15+ ; CHECK-NEXT: call void @foo(i32 %t3)
16+ ; CHECK-NEXT: ret void
17+ ;
18+ %s2 = shl i32 %s , 1
19+ %t1 = add i32 %b , %s2
20+ call void @foo (i32 %t1 )
21+ %s4 = shl i32 %s , 2
22+ %t2 = add i32 %b , %s4
23+ call void @foo (i32 %t2 )
24+ %s6 = mul i32 %s , 6
25+ %t3 = add i32 %b , %s6
26+ call void @foo (i32 %t3 )
27+ ret void
28+ }
29+
30+ declare void @foo (i32 )
You can’t perform that action at this time.
0 commit comments