1
- ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
1
+ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals all -- version 5
2
2
; RUN: opt %s -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S | FileCheck %s --check-prefixes=NORMAL,BASELINE
3
3
; RUN: opt %s -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S -bonus-inst-threshold=2 | FileCheck %s --check-prefixes=NORMAL,AGGRESSIVE
4
4
; RUN: opt %s -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -S -bonus-inst-threshold=4 | FileCheck %s --check-prefixes=WAYAGGRESSIVE
@@ -11,12 +11,12 @@ define i32 @foo(i32 %a, i32 %b, i32 %c, i32 %d, ptr %input) {
11
11
; BASELINE-SAME: i32 [[A:%.*]], i32 [[B:%.*]], i32 [[C:%.*]], i32 [[D:%.*]], ptr [[INPUT:%.*]]) {
12
12
; BASELINE-NEXT: [[ENTRY:.*]]:
13
13
; BASELINE-NEXT: [[CMP:%.*]] = icmp sgt i32 [[D]], 3
14
- ; BASELINE-NEXT: br i1 [[CMP]], label %[[COND_END:.*]], label %[[LOR_LHS_FALSE:.*]]
14
+ ; BASELINE-NEXT: br i1 [[CMP]], label %[[COND_END:.*]], label %[[LOR_LHS_FALSE:.*]], !prof [[PROF0:![0-9]+]]
15
15
; BASELINE: [[LOR_LHS_FALSE]]:
16
16
; BASELINE-NEXT: [[MUL:%.*]] = shl i32 [[C]], 1
17
17
; BASELINE-NEXT: [[ADD:%.*]] = add nsw i32 [[MUL]], [[A]]
18
18
; BASELINE-NEXT: [[CMP1:%.*]] = icmp slt i32 [[ADD]], [[B]]
19
- ; BASELINE-NEXT: br i1 [[CMP1]], label %[[COND_FALSE:.*]], label %[[COND_END]]
19
+ ; BASELINE-NEXT: br i1 [[CMP1]], label %[[COND_FALSE:.*]], label %[[COND_END]], !prof [[PROF1:![0-9]+]]
20
20
; BASELINE: [[COND_FALSE]]:
21
21
; BASELINE-NEXT: [[TMP0:%.*]] = load i32, ptr [[INPUT]], align 4
22
22
; BASELINE-NEXT: br label %[[COND_END]]
@@ -31,8 +31,8 @@ define i32 @foo(i32 %a, i32 %b, i32 %c, i32 %d, ptr %input) {
31
31
; AGGRESSIVE-NEXT: [[MUL:%.*]] = shl i32 [[C]], 1
32
32
; AGGRESSIVE-NEXT: [[ADD:%.*]] = add nsw i32 [[MUL]], [[A]]
33
33
; AGGRESSIVE-NEXT: [[CMP1:%.*]] = icmp slt i32 [[ADD]], [[B]]
34
- ; AGGRESSIVE-NEXT: [[OR_COND:%.*]] = select i1 [[CMP]], i1 [[CMP1]], i1 false
35
- ; AGGRESSIVE-NEXT: br i1 [[OR_COND]], label %[[COND_FALSE:.*]], label %[[COND_END:.*]]
34
+ ; AGGRESSIVE-NEXT: [[OR_COND:%.*]] = select i1 [[CMP]], i1 [[CMP1]], i1 false, !prof [[PROF0:![0-9]+]]
35
+ ; AGGRESSIVE-NEXT: br i1 [[OR_COND]], label %[[COND_FALSE:.*]], label %[[COND_END:.*]], !prof [[PROF0]]
36
36
; AGGRESSIVE: [[COND_FALSE]]:
37
37
; AGGRESSIVE-NEXT: [[TMP0:%.*]] = load i32, ptr [[INPUT]], align 4
38
38
; AGGRESSIVE-NEXT: br label %[[COND_END]]
@@ -47,8 +47,8 @@ define i32 @foo(i32 %a, i32 %b, i32 %c, i32 %d, ptr %input) {
47
47
; WAYAGGRESSIVE-NEXT: [[MUL:%.*]] = shl i32 [[C]], 1
48
48
; WAYAGGRESSIVE-NEXT: [[ADD:%.*]] = add nsw i32 [[MUL]], [[A]]
49
49
; WAYAGGRESSIVE-NEXT: [[CMP1:%.*]] = icmp slt i32 [[ADD]], [[B]]
50
- ; WAYAGGRESSIVE-NEXT: [[OR_COND:%.*]] = select i1 [[CMP]], i1 [[CMP1]], i1 false
51
- ; WAYAGGRESSIVE-NEXT: br i1 [[OR_COND]], label %[[COND_FALSE:.*]], label %[[COND_END:.*]]
50
+ ; WAYAGGRESSIVE-NEXT: [[OR_COND:%.*]] = select i1 [[CMP]], i1 [[CMP1]], i1 false, !prof [[PROF0:![0-9]+]]
51
+ ; WAYAGGRESSIVE-NEXT: br i1 [[OR_COND]], label %[[COND_FALSE:.*]], label %[[COND_END:.*]], !prof [[PROF0]]
52
52
; WAYAGGRESSIVE: [[COND_FALSE]]:
53
53
; WAYAGGRESSIVE-NEXT: [[TMP0:%.*]] = load i32, ptr [[INPUT]], align 4
54
54
; WAYAGGRESSIVE-NEXT: br label %[[COND_END]]
@@ -58,13 +58,13 @@ define i32 @foo(i32 %a, i32 %b, i32 %c, i32 %d, ptr %input) {
58
58
;
59
59
entry:
60
60
%cmp = icmp sgt i32 %d , 3
61
- br i1 %cmp , label %cond.end , label %lor.lhs.false
61
+ br i1 %cmp , label %cond.end , label %lor.lhs.false , !prof !0
62
62
63
63
lor.lhs.false:
64
64
%mul = shl i32 %c , 1
65
65
%add = add nsw i32 %mul , %a
66
66
%cmp1 = icmp slt i32 %add , %b
67
- br i1 %cmp1 , label %cond.false , label %cond.end
67
+ br i1 %cmp1 , label %cond.false , label %cond.end , !prof !1
68
68
69
69
cond.false:
70
70
%0 = load i32 , ptr %input , align 4
@@ -160,3 +160,14 @@ cond.end:
160
160
%cond = phi i32 [ %0 , %cond.false ], [ 0 , %lor.lhs.false ],[ 0 , %pred_a ],[ 0 , %pred_b ]
161
161
ret i32 %cond
162
162
}
163
+
164
+ !0 = !{!"branch_weights" , i32 7 , i32 11 }
165
+ !1 = !{!"branch_weights" , i32 13 , i32 5 }
166
+ ;.
167
+ ; BASELINE: [[PROF0]] = !{!"branch_weights", i32 7, i32 11}
168
+ ; BASELINE: [[PROF1]] = !{!"branch_weights", i32 13, i32 5}
169
+ ;.
170
+ ; AGGRESSIVE: [[PROF0]] = !{!"branch_weights", i32 143, i32 181}
171
+ ;.
172
+ ; WAYAGGRESSIVE: [[PROF0]] = !{!"branch_weights", i32 143, i32 181}
173
+ ;.
0 commit comments