1 ; RUN: llc -mtriple=amdgcn -mcpu=gfx1030 -verify-machineinstrs -amdgpu-s-branch-bits=7 < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GFX1030 %s
2 ; RUN: llc -mtriple=amdgcn -mcpu=gfx1010 -verify-machineinstrs -amdgpu-s-branch-bits=7 < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GFX1010 %s
3 ; RUN: llc -mtriple=amdgcn -mcpu=gfx1100 -verify-machineinstrs -amdgpu-s-branch-bits=7 < %s | FileCheck -enable-var-scope -check-prefixes=GCN,GFX1030 %s
5 ; For gfx1010, overestimate the branch size in case we need to insert
6 ; a nop for the buggy offset.
8 ; GCN-LABEL: long_forward_scc_branch_3f_offset_bug:
9 ; GFX1030: s_cmp_lg_u32
10 ; GFX1030: s_cbranch_scc1 [[ENDBB:.LBB[0-9]+_[0-9]+]]
12 ; GFX1010: s_cmp_lg_u32
13 ; GFX1010-NEXT: s_cbranch_scc0 [[RELAX_BB:.LBB[0-9]+_[0-9]+]]
14 ; GFX1010: s_getpc_b64
15 ; GFX1010-NEXT: [[POST_GETPC:.Lpost_getpc[0-9]+]]:{{$}}
16 ; GFX1010-NEXT: s_add_u32 s{{[0-9]+}}, s{{[0-9]+}}, ([[ENDBB:.LBB[0-9]+_[0-9]+]]-[[POST_GETPC]])&4294967295
17 ; GFX1010-NEXT: s_addc_u32 s{{[0-9]+}}, s{{[0-9]+}}, ([[ENDBB:.LBB[0-9]+_[0-9]+]]-[[POST_GETPC]])>>32
18 ; GFX1010: [[RELAX_BB]]:
25 ; GCN: global_store_{{dword|b32}}
26 define amdgpu_kernel void @long_forward_scc_branch_3f_offset_bug(ptr addrspace(1) %arg, i32 %cnd0) #0 {
28 %cmp0 = icmp eq i32 %cnd0, 0
29 br i1 %cmp0, label %bb2, label %bb3
32 %val = call i32 asm sideeffect
44 v_nop_e64", "=s"() ; 20 * 12 = 240
45 call void @llvm.amdgcn.s.sleep(i32 0) ; +4 = 244
46 %cmp1 = icmp eq i32 %val, 0 ; +4 = 248
47 br i1 %cmp1, label %bb2, label %bb3 ; +4 (gfx1030), +8 with workaround (gfx1010)
50 store volatile i32 %cnd0, ptr addrspace(1) %arg
54 ; GCN-LABEL: {{^}}long_forward_exec_branch_3f_offset_bug:
56 ; GFX1030: v_cmpx_eq_u32
57 ; GFX1030: s_cbranch_execnz [[RELAX_BB:.LBB[0-9]+_[0-9]+]]
59 ; GFX1010: v_cmp_eq_u32
60 ; GFX1010: s_and_saveexec_b32
61 ; GFX1010-NEXT: s_cbranch_execnz [[RELAX_BB:.LBB[0-9]+_[0-9]+]]
64 ; GCN-NEXT: [[POST_GETPC:.Lpost_getpc[0-9]+]]:{{$}}
65 ; GCN-NEXT: s_add_u32 s{{[0-9]+}}, s{{[0-9]+}}, ([[ENDBB:.LBB[0-9]+_[0-9]+]]-[[POST_GETPC]])&4294967295
66 ; GCN-NEXT: s_addc_u32 s{{[0-9]+}}, s{{[0-9]+}}, ([[ENDBB:.LBB[0-9]+_[0-9]+]]-[[POST_GETPC]])>>32
71 ; GCN: s_cbranch_execz
74 ; GCN: global_store_{{dword|b32}}
75 define void @long_forward_exec_branch_3f_offset_bug(ptr addrspace(1) %arg, i32 %cnd0) #0 {
77 %cmp0 = icmp eq i32 %cnd0, 0
78 br i1 %cmp0, label %bb2, label %bb3
81 %val = call i32 asm sideeffect
93 v_nop_e64", "=v"() ; 20 * 12 = 240
94 call void @llvm.amdgcn.s.sleep(i32 0) ; +4 = 244
95 %cmp1 = icmp eq i32 %val, 0 ; +4 = 248
96 br i1 %cmp1, label %bb2, label %bb3 ; +4 (gfx1030), +8 with workaround (gfx1010)
99 store volatile i32 %cnd0, ptr addrspace(1) %arg
103 declare void @llvm.amdgcn.s.sleep(i32 immarg)