Skip to content

Commit d7c6e94

Browse files
authored
[AMDGPU][StructurizeCFG] pre-commit tests: maintain branch_weights metadata (#109812)
1 parent 7c825f0 commit d7c6e94

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt -S -mtriple=amdgcn-- -passes=structurizecfg %s | FileCheck -check-prefix=OPT %s
3+
4+
define amdgpu_ps i32 @if_else(i32 %0) {
5+
; OPT-LABEL: define amdgpu_ps i32 @if_else(
6+
; OPT-SAME: i32 [[TMP0:%.*]]) {
7+
; OPT-NEXT: [[C:%.*]] = icmp ne i32 [[TMP0]], 0
8+
; OPT-NEXT: br i1 [[C]], label %[[FALSE:.*]], label %[[FLOW:.*]]
9+
; OPT: [[FLOW]]:
10+
; OPT-NEXT: [[TMP2:%.*]] = phi i32 [ 33, %[[FALSE]] ], [ undef, [[TMP1:%.*]] ]
11+
; OPT-NEXT: [[TMP3:%.*]] = phi i1 [ false, %[[FALSE]] ], [ true, [[TMP1]] ]
12+
; OPT-NEXT: br i1 [[TMP3]], label %[[TRUE:.*]], label %[[EXIT:.*]]
13+
; OPT: [[TRUE]]:
14+
; OPT-NEXT: br label %[[EXIT]]
15+
; OPT: [[FALSE]]:
16+
; OPT-NEXT: br label %[[FLOW]]
17+
; OPT: [[EXIT]]:
18+
; OPT-NEXT: [[RET:%.*]] = phi i32 [ [[TMP2]], %[[FLOW]] ], [ 42, %[[TRUE]] ]
19+
; OPT-NEXT: ret i32 [[RET]]
20+
;
21+
%c = icmp eq i32 %0, 0
22+
br i1 %c, label %true, label %false, !prof !0
23+
24+
true: ; preds = %1
25+
br label %exit
26+
27+
false: ; preds = %1
28+
br label %exit
29+
30+
exit: ; preds = %false, %true
31+
%ret = phi i32 [ 42, %true ], [ 33, %false ]
32+
ret i32 %ret
33+
}
34+
35+
define amdgpu_ps void @loop_if_break(i32 %n) {
36+
; OPT-LABEL: define amdgpu_ps void @loop_if_break(
37+
; OPT-SAME: i32 [[N:%.*]]) {
38+
; OPT-NEXT: [[ENTRY:.*]]:
39+
; OPT-NEXT: br label %[[LOOP:.*]]
40+
; OPT: [[LOOP]]:
41+
; OPT-NEXT: [[I:%.*]] = phi i32 [ [[N]], %[[ENTRY]] ], [ [[TMP0:%.*]], %[[FLOW:.*]] ]
42+
; OPT-NEXT: [[C:%.*]] = icmp ugt i32 [[I]], 0
43+
; OPT-NEXT: br i1 [[C]], label %[[LOOP_BODY:.*]], label %[[FLOW]]
44+
; OPT: [[LOOP_BODY]]:
45+
; OPT-NEXT: [[I_NEXT:%.*]] = sub i32 [[I]], 1
46+
; OPT-NEXT: br label %[[FLOW]]
47+
; OPT: [[FLOW]]:
48+
; OPT-NEXT: [[TMP0]] = phi i32 [ [[I_NEXT]], %[[LOOP_BODY]] ], [ undef, %[[LOOP]] ]
49+
; OPT-NEXT: [[TMP1:%.*]] = phi i1 [ false, %[[LOOP_BODY]] ], [ true, %[[LOOP]] ]
50+
; OPT-NEXT: br i1 [[TMP1]], label %[[EXIT:.*]], label %[[LOOP]]
51+
; OPT: [[EXIT]]:
52+
; OPT-NEXT: ret void
53+
;
54+
entry:
55+
br label %loop
56+
57+
loop: ; preds = %loop_body, %entry
58+
%i = phi i32 [ %n, %entry ], [ %i.next, %loop_body ]
59+
%c = icmp ugt i32 %i, 0
60+
br i1 %c, label %loop_body, label %exit, !prof !0
61+
62+
loop_body: ; preds = %loop
63+
%i.next = sub i32 %i, 1
64+
br label %loop
65+
66+
exit: ; preds = %loop
67+
ret void
68+
}
69+
70+
attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
71+
72+
!0 = !{!"branch_weights", i32 1000, i32 1}

0 commit comments

Comments
 (0)