Skip to content

Commit f7493ba

Browse files
committed
[AMDGPU][StructurizeCFG] Maintain branch MD_prof metadata (#109813)
Currently `StructurizeCFG` drops branch_weight metadata . This metadata can be generated from user annotations in the source code like: ```cpp if (...) [[likely]] { } ```
1 parent 4edde84 commit f7493ba

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

llvm/test/CodeGen/AMDGPU/structurizer-keep-perf-md.ll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ define amdgpu_ps i32 @if_else(i32 %0) {
55
; OPT-LABEL: define amdgpu_ps i32 @if_else(
66
; OPT-SAME: i32 [[TMP0:%.*]]) {
77
; OPT-NEXT: [[C:%.*]] = icmp ne i32 [[TMP0]], 0
8-
; OPT-NEXT: br i1 [[C]], label %[[FALSE:.*]], label %[[FLOW:.*]]
8+
; OPT-NEXT: br i1 [[C]], label %[[FALSE:.*]], label %[[FLOW:.*]], !prof [[PROF0:![0-9]+]]
99
; OPT: [[FLOW]]:
1010
; OPT-NEXT: [[TMP2:%.*]] = phi i32 [ 33, %[[FALSE]] ], [ undef, [[TMP1:%.*]] ]
1111
; OPT-NEXT: [[TMP3:%.*]] = phi i1 [ false, %[[FALSE]] ], [ true, [[TMP1]] ]
@@ -40,7 +40,7 @@ define amdgpu_ps void @loop_if_break(i32 %n) {
4040
; OPT: [[LOOP]]:
4141
; OPT-NEXT: [[I:%.*]] = phi i32 [ [[N]], %[[ENTRY]] ], [ [[TMP0:%.*]], %[[FLOW:.*]] ]
4242
; OPT-NEXT: [[C:%.*]] = icmp ugt i32 [[I]], 0
43-
; OPT-NEXT: br i1 [[C]], label %[[LOOP_BODY:.*]], label %[[FLOW]]
43+
; OPT-NEXT: br i1 [[C]], label %[[LOOP_BODY:.*]], label %[[FLOW]], !prof [[PROF1:![0-9]+]]
4444
; OPT: [[LOOP_BODY]]:
4545
; OPT-NEXT: [[I_NEXT:%.*]] = sub i32 [[I]], 1
4646
; OPT-NEXT: br label %[[FLOW]]
@@ -70,3 +70,7 @@ exit: ; preds = %loop
7070
attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
7171

7272
!0 = !{!"branch_weights", i32 1000, i32 1}
73+
;.
74+
; OPT: [[PROF0]] = !{!"branch_weights", i32 1, i32 1000}
75+
; OPT: [[PROF1]] = !{!"branch_weights", i32 1000, i32 1}
76+
;.

0 commit comments

Comments
 (0)