llvm.org GIT mirror llvm / 0da0037
Revert r338431: "Add DebugCounters to DivRemPairs" This reverts r338431; the test it added is making buildbots unhappy. Locally, I can repro the failure on reverse-iteration builds. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338442 91177308-0d34-0410-b5e6-96231b3b80d8 George Burgess IV 1 year, 1 month ago
2 changed file(s) with 0 addition(s) and 96 deletion(s). Raw diff Collapse all Expand all
2020 #include "llvm/IR/Dominators.h"
2121 #include "llvm/IR/Function.h"
2222 #include "llvm/Pass.h"
23 #include "llvm/Support/DebugCounter.h"
2423 #include "llvm/Transforms/Scalar.h"
2524 #include "llvm/Transforms/Utils/BypassSlowDivision.h"
2625 using namespace llvm;
2928 STATISTIC(NumPairs, "Number of div/rem pairs");
3029 STATISTIC(NumHoisted, "Number of instructions hoisted");
3130 STATISTIC(NumDecomposed, "Number of instructions decomposed");
32 DEBUG_COUNTER(DRPCounter, "div-rem-pairs-transform",
33 "Controls transformations in div-rem-pairs pass");
3431
3532 /// Find matching pairs of integer div/rem ops (they have the same numerator,
3633 /// denominator, and signedness). If they exist in different basic blocks, bring
9592 if (!DivDominates && !DT.dominates(RemInst, DivInst))
9693 continue;
9794
98 if (!DebugCounter::shouldExecute(DRPCounter))
99 continue;
100
10195 if (HasDivRemOp) {
10296 // The target has a single div/rem operation. Hoist the lower instruction
10397 // to make the matched pair visible to the backend.
+0
-90
test/Other/debugcounter-divrempairs.ll less more
None ; RUN: opt < %s -div-rem-pairs -debug-counter=div-rem-pairs-transform-skip=1,div-rem-pairs-transform-count=1 \
1 ; RUN: -S -mtriple=x86_64-unknown-unknown | FileCheck %s
2 ;; Test that, with debug counters on, we only skip the first div-rem-pairs opportunity, optimize one after it,
3 ;; and then ignore all the others. There is 1 optimization opportunity in f1, 2 in f2, and another 1 in f3,
4 ;; only the first one in f2 will be performed.
5
6 define i64 @f1(i64 %a, i64 %b) {
7 ; CHECK-LABEL: @f1(
8 ; CHECK-NEXT: entry:
9 ; CHECK-NEXT: [[REM:%.*]] = urem i64 %a, %b
10 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i64 [[REM]], 42
11 ; CHECK-NEXT: br i1 [[CMP]], label %if, label %end
12 ; CHECK: if:
13 ; CHECK-NEXT: [[DIV:%.*]] = udiv i64 %a, %b
14 ; CHECK-NEXT: br label %end
15 ; CHECK: end:
16 ; CHECK-NEXT: [[RET:%.*]] = phi i64 [ [[DIV]], %if ], [ 3, %entry ]
17 ; CHECK-NEXT: ret i64 [[RET]]
18 ;
19 entry:
20 %rem = urem i64 %a, %b
21 %cmp = icmp eq i64 %rem, 42
22 br i1 %cmp, label %if, label %end
23
24 if:
25 %div = udiv i64 %a, %b
26 br label %end
27
28 end:
29 %ret = phi i64 [ %div, %if ], [ 3, %entry ]
30 ret i64 %ret
31 }
32
33 define i16 @f2(i16 %a, i16 %b) {
34 ; CHECK-LABEL: @f2(
35 ; CHECK-NEXT: entry:
36 ; CHECK-NEXT: [[DIV1:%.*]] = sdiv i16 %a, %b
37 ; CHECK-NEXT: [[REM1:%.*]] = srem i16 %a, %b
38 ; CHECK-NEXT: [[DIV2:%.*]] = udiv i16 %a, %b
39 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i16 [[DIV1]], 42
40 ; CHECK-NEXT: br i1 [[CMP]], label %if, label %end
41 ; CHECK: if:
42 ; CHECK-NEXT: [[REM2:%.*]] = urem i16 %a, %b
43 ; CHECK-NEXT: br label %end
44 ; CHECK: end:
45 ; CHECK-NEXT: [[RET:%.*]] = phi i16 [ [[REM1]], %if ], [ 3, %entry ]
46 ; CHECK-NEXT: ret i16 [[RET]]
47 ;
48 entry:
49 %div1 = sdiv i16 %a, %b
50 %div2 = udiv i16 %a, %b
51 %cmp = icmp eq i16 %div1, 42
52 br i1 %cmp, label %if, label %end
53
54 if:
55 %rem1 = srem i16 %a, %b
56 %rem2 = urem i16 %a, %b
57 br label %end
58
59 end:
60 %ret = phi i16 [ %rem1, %if ], [ 3, %entry ]
61 ret i16 %ret
62 }
63
64 define i32 @f3(i32 %a, i32 %b) {
65 ; CHECK-LABEL: @f3(
66 ; CHECK-NEXT: entry:
67 ; CHECK-NEXT: [[REM:%.*]] = srem i32 %a, %b
68 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[REM]], 42
69 ; CHECK-NEXT: br i1 [[CMP]], label %if, label %end
70 ; CHECK: if:
71 ; CHECK-NEXT: [[DIV:%.*]] = sdiv i32 %a, %b
72 ; CHECK-NEXT: br label %end
73 ; CHECK: end:
74 ; CHECK-NEXT: [[RET:%.*]] = phi i32 [ [[DIV]], %if ], [ 3, %entry ]
75 ; CHECK-NEXT: ret i32 [[RET]]
76 ;
77 entry:
78 %rem = srem i32 %a, %b
79 %cmp = icmp eq i32 %rem, 42
80 br i1 %cmp, label %if, label %end
81
82 if:
83 %div = sdiv i32 %a, %b
84 br label %end
85
86 end:
87 %ret = phi i32 [ %div, %if ], [ 3, %entry ]
88 ret i32 %ret
89 }