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
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:.*]], !prof [[PROF0:![0-9]+]]
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:.*]]
14 ; OPT-NEXT: br label %[[EXIT]]
16 ; OPT-NEXT: br label %[[FLOW]]
18 ; OPT-NEXT: [[RET:%.*]] = phi i32 [ [[TMP2]], %[[FLOW]] ], [ 42, %[[TRUE]] ]
19 ; OPT-NEXT: ret i32 [[RET]]
21 %c = icmp eq i32 %0, 0
22 br i1 %c, label %true, label %false, !prof !0
30 exit: ; preds = %false, %true
31 %ret = phi i32 [ 42, %true ], [ 33, %false ]
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:.*]]
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]], !prof [[PROF1:![0-9]+]]
45 ; OPT-NEXT: [[I_NEXT:%.*]] = sub i32 [[I]], 1
46 ; OPT-NEXT: br label %[[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]]
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
62 loop_body: ; preds = %loop
63 %i.next = sub i32 %i, 1
70 attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
72 !0 = !{!"branch_weights", i32 1000, i32 1}
74 ; OPT: [[PROF0]] = !{!"branch_weights", i32 1, i32 1000}
75 ; OPT: [[PROF1]] = !{!"branch_weights", i32 1000, i32 1}