1; RUN: llc -march=amdgcn -mcpu=tahiti -verify-machineinstrs -amdgpu-s-branch-bits=4 < %s | FileCheck -enable-var-scope -check-prefix=GCN %s 2 3 4; FIXME: We should use llvm-mc for this, but we can't even parse our own output. 5; See PR33579. 6; RUN: llc -march=amdgcn -verify-machineinstrs -amdgpu-s-branch-bits=4 -o %t.o -filetype=obj %s 7; RUN: llvm-readobj -r %t.o | FileCheck --check-prefix=OBJ %s 8 9; OBJ: Relocations [ 10; OBJ-NEXT: ] 11 12; Restrict maximum branch to between +7 and -8 dwords 13 14; Used to emit an always 4 byte instruction. Inline asm always assumes 15; each instruction is the maximum size. 16declare void @llvm.amdgcn.s.sleep(i32) #0 17 18declare i32 @llvm.amdgcn.workitem.id.x() #1 19 20 21; GCN-LABEL: {{^}}uniform_conditional_max_short_forward_branch: 22; GCN: s_load_dword [[CND:s[0-9]+]] 23; GCN: s_cmp_eq_u32 [[CND]], 0 24; GCN-NEXT: s_cbranch_scc1 [[BB3:BB[0-9]+_[0-9]+]] 25 26 27; GCN-NEXT: ; %bb.1: ; %bb2 28; GCN-NEXT: ;;#ASMSTART 29; GCN-NEXT: v_nop_e64 30; GCN-NEXT: v_nop_e64 31; GCN-NEXT: v_nop_e64 32; GCN-NEXT: ;;#ASMEND 33; GCN-NEXT: s_sleep 0 34 35; GCN-NEXT: [[BB3]]: ; %bb3 36; GCN: v_mov_b32_e32 [[V_CND:v[0-9]+]], [[CND]] 37; GCN: buffer_store_dword [[V_CND]] 38; GCN: s_endpgm 39define amdgpu_kernel void @uniform_conditional_max_short_forward_branch(i32 addrspace(1)* %arg, i32 %cnd) #0 { 40bb: 41 %cmp = icmp eq i32 %cnd, 0 42 br i1 %cmp, label %bb3, label %bb2 ; +8 dword branch 43 44bb2: 45; 24 bytes 46 call void asm sideeffect 47 "v_nop_e64 48 v_nop_e64 49 v_nop_e64", ""() #0 50 call void @llvm.amdgcn.s.sleep(i32 0) 51 br label %bb3 52 53bb3: 54 store volatile i32 %cnd, i32 addrspace(1)* %arg 55 ret void 56} 57 58; GCN-LABEL: {{^}}uniform_conditional_min_long_forward_branch: 59; GCN: s_load_dword [[CND:s[0-9]+]] 60; GCN: s_cmp_eq_u32 [[CND]], 0 61; GCN-NEXT: s_cbranch_scc0 [[LONGBB:BB[0-9]+_[0-9]+]] 62 63; GCN-NEXT: [[LONG_JUMP:BB[0-9]+_[0-9]+]]: ; %bb0 64; GCN-NEXT: s_getpc_b64 s{{\[}}[[PC_LO:[0-9]+]]:[[PC_HI:[0-9]+]]{{\]}} 65; GCN-NEXT: s_add_u32 s[[PC_LO]], s[[PC_LO]], [[ENDBB:BB[0-9]+_[0-9]+]]-([[LONG_JUMP]]+4) 66; GCN-NEXT: s_addc_u32 s[[PC_HI]], s[[PC_HI]], 0 67; GCN-NEXT: s_setpc_b64 s{{\[}}[[PC_LO]]:[[PC_HI]]{{\]}} 68 69; GCN-NEXT: [[LONGBB]]: 70; GCN-NEXT: ;;#ASMSTART 71; GCN: v_nop_e64 72; GCN: v_nop_e64 73; GCN: v_nop_e64 74; GCN: v_nop_e64 75; GCN-NEXT: ;;#ASMEND 76 77; GCN-NEXT: [[ENDBB]]: 78; GCN: v_mov_b32_e32 [[V_CND:v[0-9]+]], [[CND]] 79; GCN: buffer_store_dword [[V_CND]] 80; GCN: s_endpgm 81define amdgpu_kernel void @uniform_conditional_min_long_forward_branch(i32 addrspace(1)* %arg, i32 %cnd) #0 { 82bb0: 83 %cmp = icmp eq i32 %cnd, 0 84 br i1 %cmp, label %bb3, label %bb2 ; +9 dword branch 85 86bb2: 87; 32 bytes 88 call void asm sideeffect 89 "v_nop_e64 90 v_nop_e64 91 v_nop_e64 92 v_nop_e64", ""() #0 93 br label %bb3 94 95bb3: 96 store volatile i32 %cnd, i32 addrspace(1)* %arg 97 ret void 98} 99 100; GCN-LABEL: {{^}}uniform_conditional_min_long_forward_vcnd_branch: 101; GCN: s_load_dword [[CND:s[0-9]+]] 102; GCN-DAG: v_mov_b32_e32 [[V_CND:v[0-9]+]], [[CND]] 103; GCN-DAG: v_cmp_eq_f32_e64 [[UNMASKED:s\[[0-9]+:[0-9]+\]]], [[CND]], 0 104; GCN-DAG: s_and_b64 vcc, exec, [[UNMASKED]] 105; GCN: s_cbranch_vccz [[LONGBB:BB[0-9]+_[0-9]+]] 106 107; GCN-NEXT: [[LONG_JUMP:BB[0-9]+_[0-9]+]]: ; %bb0 108; GCN-NEXT: s_getpc_b64 s{{\[}}[[PC_LO:[0-9]+]]:[[PC_HI:[0-9]+]]{{\]}} 109; GCN-NEXT: s_add_u32 s[[PC_LO]], s[[PC_LO]], [[ENDBB:BB[0-9]+_[0-9]+]]-([[LONG_JUMP]]+4) 110; GCN-NEXT: s_addc_u32 s[[PC_HI]], s[[PC_HI]], 0 111; GCN-NEXT: s_setpc_b64 s{{\[}}[[PC_LO]]:[[PC_HI]]{{\]}} 112 113; GCN-NEXT: [[LONGBB]]: 114; GCN: v_nop_e64 115; GCN: v_nop_e64 116; GCN: v_nop_e64 117; GCN: v_nop_e64 118 119; GCN: [[ENDBB]]: 120; GCN: buffer_store_dword [[V_CND]] 121; GCN: s_endpgm 122define amdgpu_kernel void @uniform_conditional_min_long_forward_vcnd_branch(float addrspace(1)* %arg, float %cnd) #0 { 123bb0: 124 %cmp = fcmp oeq float %cnd, 0.0 125 br i1 %cmp, label %bb3, label %bb2 ; + 8 dword branch 126 127bb2: 128 call void asm sideeffect " ; 32 bytes 129 v_nop_e64 130 v_nop_e64 131 v_nop_e64 132 v_nop_e64", ""() #0 133 br label %bb3 134 135bb3: 136 store volatile float %cnd, float addrspace(1)* %arg 137 ret void 138} 139 140; GCN-LABEL: {{^}}min_long_forward_vbranch: 141 142; GCN: buffer_load_dword 143; GCN: v_cmp_ne_u32_e32 vcc, 0, v{{[0-9]+}} 144; GCN: s_and_saveexec_b64 [[SAVE:s\[[0-9]+:[0-9]+\]]], vcc 145 146; GCN: v_nop_e64 147; GCN: v_nop_e64 148; GCN: v_nop_e64 149; GCN: v_nop_e64 150 151; GCN: s_or_b64 exec, exec, [[SAVE]] 152; GCN: buffer_store_dword 153; GCN: s_endpgm 154define amdgpu_kernel void @min_long_forward_vbranch(i32 addrspace(1)* %arg) #0 { 155bb: 156 %tid = call i32 @llvm.amdgcn.workitem.id.x() 157 %tid.ext = zext i32 %tid to i64 158 %gep = getelementptr inbounds i32, i32 addrspace(1)* %arg, i64 %tid.ext 159 %load = load volatile i32, i32 addrspace(1)* %gep 160 %cmp = icmp eq i32 %load, 0 161 br i1 %cmp, label %bb3, label %bb2 ; + 8 dword branch 162 163bb2: 164 call void asm sideeffect " ; 32 bytes 165 v_nop_e64 166 v_nop_e64 167 v_nop_e64 168 v_nop_e64", ""() #0 169 br label %bb3 170 171bb3: 172 store volatile i32 %load, i32 addrspace(1)* %gep 173 ret void 174} 175 176; GCN-LABEL: {{^}}long_backward_sbranch: 177; GCN: s_mov_b32 [[LOOPIDX:s[0-9]+]], 0{{$}} 178 179; GCN: [[LOOPBB:BB[0-9]+_[0-9]+]]: ; %bb2 180; GCN-NEXT: ; =>This Inner Loop Header: Depth=1 181; GCN-NEXT: s_add_i32 [[INC:s[0-9]+]], [[LOOPIDX]], 1 182; GCN-NEXT: s_cmp_lt_i32 [[INC]], 10 183 184; GCN-NEXT: ;;#ASMSTART 185; GCN-NEXT: v_nop_e64 186; GCN-NEXT: v_nop_e64 187; GCN-NEXT: v_nop_e64 188; GCN-NEXT: ;;#ASMEND 189 190; GCN-NEXT: s_cbranch_scc0 [[ENDBB:BB[0-9]+_[0-9]+]] 191 192; GCN-NEXT: [[LONG_JUMP:BB[0-9]+_[0-9]+]]: ; %bb2 193; GCN-NEXT: ; in Loop: Header=[[LOOPBB]] Depth=1 194 195; GCN-NEXT: s_getpc_b64 s{{\[}}[[PC_LO:[0-9]+]]:[[PC_HI:[0-9]+]]{{\]}} 196; GCN-NEXT: s_sub_u32 s[[PC_LO]], s[[PC_LO]], ([[LONG_JUMP]]+4)-[[LOOPBB]] 197; GCN-NEXT: s_subb_u32 s[[PC_HI]], s[[PC_HI]], 0 198; GCN-NEXT: s_setpc_b64 s{{\[}}[[PC_LO]]:[[PC_HI]]{{\]}} 199 200; GCN-NEXT: [[ENDBB]]: 201; GCN-NEXT: s_endpgm 202define amdgpu_kernel void @long_backward_sbranch(i32 addrspace(1)* %arg) #0 { 203bb: 204 br label %bb2 205 206bb2: 207 %loop.idx = phi i32 [ 0, %bb ], [ %inc, %bb2 ] 208 ; 24 bytes 209 call void asm sideeffect 210 "v_nop_e64 211 v_nop_e64 212 v_nop_e64", ""() #0 213 %inc = add nsw i32 %loop.idx, 1 ; add cost 4 214 %cmp = icmp slt i32 %inc, 10 ; condition cost = 8 215 br i1 %cmp, label %bb2, label %bb3 ; - 216 217bb3: 218 ret void 219} 220 221; Requires expansion of unconditional branch from %bb2 to %bb4 (and 222; expansion of conditional branch from %bb to %bb3. 223 224; GCN-LABEL: {{^}}uniform_unconditional_min_long_forward_branch: 225; GCN: s_cmp_eq_u32 226; GCN-NEXT: s_cbranch_scc0 [[BB2:BB[0-9]+_[0-9]+]] 227 228; GCN-NEXT: [[LONG_JUMP0:BB[0-9]+_[0-9]+]]: ; %bb0 229; GCN-NEXT: s_getpc_b64 s{{\[}}[[PC0_LO:[0-9]+]]:[[PC0_HI:[0-9]+]]{{\]}} 230; GCN-NEXT: s_add_u32 s[[PC0_LO]], s[[PC0_LO]], [[BB3:BB[0-9]_[0-9]+]]-([[LONG_JUMP0]]+4) 231; GCN-NEXT: s_addc_u32 s[[PC0_HI]], s[[PC0_HI]], 0{{$}} 232; GCN-NEXT: s_setpc_b64 s{{\[}}[[PC0_LO]]:[[PC0_HI]]{{\]}} 233 234; GCN-NEXT: [[BB2]]: ; %bb2 235; GCN: v_mov_b32_e32 [[BB2_K:v[0-9]+]], 17 236; GCN: buffer_store_dword [[BB2_K]] 237 238; GCN-NEXT: [[LONG_JUMP1:BB[0-9]+_[0-9]+]]: ; %bb2 239; GCN-NEXT: s_getpc_b64 s{{\[}}[[PC1_LO:[0-9]+]]:[[PC1_HI:[0-9]+]]{{\]}} 240; GCN-NEXT: s_add_u32 s[[PC1_LO]], s[[PC1_LO]], [[BB4:BB[0-9]_[0-9]+]]-([[LONG_JUMP1]]+4) 241; GCN-NEXT: s_addc_u32 s[[PC1_HI]], s[[PC1_HI]], 0{{$}} 242; GCN-NEXT: s_setpc_b64 s{{\[}}[[PC1_LO]]:[[PC1_HI]]{{\]}} 243 244; GCN: [[BB3]]: ; %bb3 245; GCN: v_nop_e64 246; GCN: v_nop_e64 247; GCN: v_nop_e64 248; GCN: v_nop_e64 249; GCN: ;;#ASMEND 250 251; GCN-NEXT: [[BB4]]: ; %bb4 252; GCN: v_mov_b32_e32 [[BB4_K:v[0-9]+]], 63 253; GCN: buffer_store_dword [[BB4_K]] 254; GCN-NEXT: s_endpgm 255; GCN-NEXT: .Lfunc_end{{[0-9]+}}: 256define amdgpu_kernel void @uniform_unconditional_min_long_forward_branch(i32 addrspace(1)* %arg, i32 %arg1) { 257bb0: 258 %tmp = icmp ne i32 %arg1, 0 259 br i1 %tmp, label %bb2, label %bb3 260 261bb2: 262 store volatile i32 17, i32 addrspace(1)* undef 263 br label %bb4 264 265bb3: 266 ; 32 byte asm 267 call void asm sideeffect 268 "v_nop_e64 269 v_nop_e64 270 v_nop_e64 271 v_nop_e64", ""() #0 272 br label %bb4 273 274bb4: 275 store volatile i32 63, i32 addrspace(1)* %arg 276 ret void 277} 278 279; GCN-LABEL: {{^}}uniform_unconditional_min_long_backward_branch: 280; GCN-NEXT: ; %bb.0: ; %entry 281 282; GCN-NEXT: [[LOOP:BB[0-9]_[0-9]+]]: ; %loop 283; GCN-NEXT: ; =>This Inner Loop Header: Depth=1 284; GCN-NEXT: ;;#ASMSTART 285; GCN-NEXT: v_nop_e64 286; GCN-NEXT: v_nop_e64 287; GCN-NEXT: v_nop_e64 288; GCN-NEXT: v_nop_e64 289; GCN-NEXT: ;;#ASMEND 290 291; GCN-NEXT: [[LONGBB:BB[0-9]+_[0-9]+]]: ; %loop 292; GCN-NEXT: ; in Loop: Header=[[LOOP]] Depth=1 293 294; GCN-NEXT: s_getpc_b64 s{{\[}}[[PC_LO:[0-9]+]]:[[PC_HI:[0-9]+]]{{\]}} 295; GCN-NEXT: s_sub_u32 s[[PC_LO]], s[[PC_LO]], ([[LONGBB]]+4)-[[LOOP]] 296; GCN-NEXT: s_subb_u32 s[[PC_HI]], s[[PC_HI]], 0{{$}} 297; GCN-NEXT: s_setpc_b64 s{{\[}}[[PC_LO]]:[[PC_HI]]{{\]}} 298; GCN-NEXT .Lfunc_end{{[0-9]+}}: 299define amdgpu_kernel void @uniform_unconditional_min_long_backward_branch(i32 addrspace(1)* %arg, i32 %arg1) { 300entry: 301 br label %loop 302 303loop: 304 ; 32 byte asm 305 call void asm sideeffect 306 "v_nop_e64 307 v_nop_e64 308 v_nop_e64 309 v_nop_e64", ""() #0 310 br label %loop 311} 312 313; Expansion of branch from %bb1 to %bb3 introduces need to expand 314; branch from %bb0 to %bb2 315 316; GCN-LABEL: {{^}}expand_requires_expand: 317; GCN-NEXT: ; %bb.0: ; %bb0 318; GCN: s_load_dword 319; GCN: s_cmp_lt_i32 s{{[0-9]+}}, 0{{$}} 320; GCN-NEXT: s_cbranch_scc0 [[BB1:BB[0-9]+_[0-9]+]] 321 322; GCN-NEXT: [[LONGBB0:BB[0-9]+_[0-9]+]]: ; %bb0 323 324; GCN-NEXT: s_getpc_b64 s{{\[}}[[PC0_LO:[0-9]+]]:[[PC0_HI:[0-9]+]]{{\]}} 325; GCN-NEXT: s_add_u32 s[[PC0_LO]], s[[PC0_LO]], [[BB2:BB[0-9]_[0-9]+]]-([[LONGBB0]]+4) 326; GCN-NEXT: s_addc_u32 s[[PC0_HI]], s[[PC0_HI]], 0{{$}} 327; GCN-NEXT: s_setpc_b64 s{{\[}}[[PC0_LO]]:[[PC0_HI]]{{\]}} 328 329; GCN-NEXT: [[BB1]]: ; %bb1 330; GCN-NEXT: s_load_dword 331; GCN-NEXT: s_waitcnt lgkmcnt(0) 332; GCN-NEXT: s_cmp_eq_u32 s{{[0-9]+}}, 3{{$}} 333; GCN-NEXT: s_cbranch_scc0 [[BB2:BB[0-9]_[0-9]+]] 334 335; GCN-NEXT: [[LONGBB1:BB[0-9]+_[0-9]+]]: ; %bb1 336; GCN-NEXT: s_getpc_b64 s{{\[}}[[PC1_LO:[0-9]+]]:[[PC1_HI:[0-9]+]]{{\]}} 337; GCN-NEXT: s_add_u32 s[[PC1_LO]], s[[PC1_LO]], [[BB3:BB[0-9]+_[0-9]+]]-([[LONGBB1]]+4) 338; GCN-NEXT: s_addc_u32 s[[PC1_HI]], s[[PC1_HI]], 0{{$}} 339; GCN-NEXT: s_setpc_b64 s{{\[}}[[PC1_LO]]:[[PC1_HI]]{{\]}} 340 341; GCN-NEXT: [[BB2]]: ; %bb2 342; GCN-NEXT: ;;#ASMSTART 343; GCN-NEXT: v_nop_e64 344; GCN-NEXT: v_nop_e64 345; GCN-NEXT: v_nop_e64 346; GCN-NEXT: v_nop_e64 347; GCN-NEXT: ;;#ASMEND 348 349; GCN-NEXT: [[BB3]]: ; %bb3 350; GCN-NEXT: ;;#ASMSTART 351; GCN-NEXT: v_nop_e64 352; GCN-NEXT: ;;#ASMEND 353; GCN-NEXT: ;;#ASMSTART 354; GCN-NEXT: v_nop_e64 355; GCN-NEXT: ;;#ASMEND 356; GCN-NEXT: s_endpgm 357define amdgpu_kernel void @expand_requires_expand(i32 %cond0) #0 { 358bb0: 359 %tmp = tail call i32 @llvm.amdgcn.workitem.id.x() #0 360 %cmp0 = icmp slt i32 %cond0, 0 361 br i1 %cmp0, label %bb2, label %bb1 362 363bb1: 364 %val = load volatile i32, i32 addrspace(4)* undef 365 %cmp1 = icmp eq i32 %val, 3 366 br i1 %cmp1, label %bb3, label %bb2 367 368bb2: 369 call void asm sideeffect 370 "v_nop_e64 371 v_nop_e64 372 v_nop_e64 373 v_nop_e64", ""() #0 374 br label %bb3 375 376bb3: 377; These NOPs prevent tail-duplication-based outlining 378; from firing, which defeats the need to expand the branches and this test. 379 call void asm sideeffect 380 "v_nop_e64", ""() #0 381 call void asm sideeffect 382 "v_nop_e64", ""() #0 383 ret void 384} 385 386; Requires expanding of required skip branch. 387 388; GCN-LABEL: {{^}}uniform_inside_divergent: 389; GCN: v_cmp_gt_u32_e32 vcc, 16, v{{[0-9]+}} 390; GCN-NEXT: s_and_saveexec_b64 [[MASK:s\[[0-9]+:[0-9]+\]]], vcc 391; GCN-NEXT: ; mask branch [[ENDIF:BB[0-9]+_[0-9]+]] 392; GCN-NEXT: s_cbranch_execnz [[IF:BB[0-9]+_[0-9]+]] 393 394; GCN-NEXT: [[LONGBB:BB[0-9]+_[0-9]+]]: ; %entry 395; GCN-NEXT: s_getpc_b64 s{{\[}}[[PC_LO:[0-9]+]]:[[PC_HI:[0-9]+]]{{\]}} 396; GCN-NEXT: s_add_u32 s[[PC_LO]], s[[PC_LO]], [[BB2:BB[0-9]_[0-9]+]]-([[LONGBB]]+4) 397; GCN-NEXT: s_addc_u32 s[[PC_HI]], s[[PC_HI]], 0{{$}} 398; GCN-NEXT: s_setpc_b64 s{{\[}}[[PC_LO]]:[[PC_HI]]{{\]}} 399 400; GCN-NEXT: [[IF]]: ; %if 401; GCN: buffer_store_dword 402; GCN: s_cmp_lg_u32 403; GCN: s_cbranch_scc1 [[ENDIF]] 404 405; GCN-NEXT: ; %bb.2: ; %if_uniform 406; GCN: buffer_store_dword 407 408; GCN-NEXT: [[ENDIF]]: ; %endif 409; GCN-NEXT: s_or_b64 exec, exec, [[MASK]] 410; GCN-NEXT: s_sleep 5 411; GCN-NEXT: s_endpgm 412define amdgpu_kernel void @uniform_inside_divergent(i32 addrspace(1)* %out, i32 %cond) #0 { 413entry: 414 %tid = call i32 @llvm.amdgcn.workitem.id.x() 415 %d_cmp = icmp ult i32 %tid, 16 416 br i1 %d_cmp, label %if, label %endif 417 418if: 419 store i32 0, i32 addrspace(1)* %out 420 %u_cmp = icmp eq i32 %cond, 0 421 br i1 %u_cmp, label %if_uniform, label %endif 422 423if_uniform: 424 store i32 1, i32 addrspace(1)* %out 425 br label %endif 426 427endif: 428 ; layout can remove the split branch if it can copy the return block. 429 ; This call makes the return block long enough that it doesn't get copied. 430 call void @llvm.amdgcn.s.sleep(i32 5); 431 ret void 432} 433 434; si_mask_branch 435 436; GCN-LABEL: {{^}}analyze_mask_branch: 437; GCN: v_cmp_nlt_f32_e32 vcc 438; GCN-NEXT: s_and_saveexec_b64 [[TEMP_MASK:s\[[0-9]+:[0-9]+\]]], vcc 439; GCN-NEXT: s_xor_b64 [[MASK:s\[[0-9]+:[0-9]+\]]], exec, [[TEMP_MASK]] 440; GCN-NEXT: ; mask branch [[FLOW:BB[0-9]+_[0-9]+]] 441 442; GCN: [[FLOW]]: ; %Flow 443; GCN-NEXT: s_or_saveexec_b64 [[TEMP_MASK1:s\[[0-9]+:[0-9]+\]]], [[MASK]] 444; GCN-NEXT: s_xor_b64 exec, exec, [[TEMP_MASK1]] 445; GCN-NEXT: ; mask branch [[RET:BB[0-9]+_[0-9]+]] 446 447; GCN: [[LOOP_BODY:BB[0-9]+_[0-9]+]]: ; %loop 448; GCN: ;;#ASMSTART 449; GCN: v_nop_e64 450; GCN: v_nop_e64 451; GCN: v_nop_e64 452; GCN: v_nop_e64 453; GCN: v_nop_e64 454; GCN: v_nop_e64 455; GCN: ;;#ASMEND 456; GCN: s_cbranch_vccz [[RET]] 457 458; GCN-NEXT: [[LONGBB:BB[0-9]+_[0-9]+]]: ; %loop 459; GCN-NEXT: ; in Loop: Header=[[LOOP_BODY]] Depth=1 460; GCN-NEXT: s_getpc_b64 s{{\[}}[[PC_LO:[0-9]+]]:[[PC_HI:[0-9]+]]{{\]}} 461; GCN-NEXT: s_sub_u32 s[[PC_LO]], s[[PC_LO]], ([[LONGBB]]+4)-[[LOOP_BODY]] 462; GCN-NEXT: s_subb_u32 s[[PC_HI]], s[[PC_HI]], 0 463; GCN-NEXT: s_setpc_b64 s{{\[}}[[PC_LO]]:[[PC_HI]]{{\]}} 464 465; GCN-NEXT: [[RET]]: ; %UnifiedReturnBlock 466; GCN-NEXT: s_endpgm 467define amdgpu_kernel void @analyze_mask_branch() #0 { 468entry: 469 %reg = call float asm sideeffect "v_mov_b32_e64 $0, 0", "=v"() 470 %cmp0 = fcmp ogt float %reg, 0.000000e+00 471 br i1 %cmp0, label %loop, label %ret 472 473loop: 474 %phi = phi float [ 0.000000e+00, %loop_body ], [ 1.000000e+00, %entry ] 475 call void asm sideeffect 476 "v_nop_e64 477 v_nop_e64", ""() #0 478 %cmp1 = fcmp olt float %phi, 8.0 479 br i1 %cmp1, label %loop_body, label %ret 480 481loop_body: 482 call void asm sideeffect 483 "v_nop_e64 484 v_nop_e64 485 v_nop_e64 486 v_nop_e64", ""() #0 487 br label %loop 488 489ret: 490 store volatile i32 7, i32 addrspace(1)* undef 491 ret void 492} 493 494; GCN-LABEL: {{^}}long_branch_hang: 495; GCN: s_cmp_lt_i32 s{{[0-9]+}}, 6 496; GCN: s_cbranch_scc1 {{BB[0-9]+_[0-9]+}} 497; GCN-NEXT: s_branch [[LONG_BR_0:BB[0-9]+_[0-9]+]] 498; GCN-NEXT: BB{{[0-9]+_[0-9]+}}: 499 500; GCN: s_add_u32 s{{[0-9]+}}, s{{[0-9]+}}, [[LONG_BR_DEST0:BB[0-9]+_[0-9]+]]-( 501; GCN-NEXT: s_addc_u32 502; GCN-NEXT: s_setpc_b64 503 504; GCN-NEXT: [[LONG_BR_0]]: 505; GCN-DAG: v_cmp_lt_i32 506; GCN-DAG: v_cmp_gt_i32 507; GCN: s_cbranch_vccnz 508 509; GCN: s_setpc_b64 510; GCN: s_setpc_b64 511 512; GCN: [[LONG_BR_DEST0]] 513; GCN: s_cbranch_vccz 514; GCN: s_setpc_b64 515 516; GCN: s_endpgm 517define amdgpu_kernel void @long_branch_hang(i32 addrspace(1)* nocapture %arg, i32 %arg1, i32 %arg2, i32 %arg3, i32 %arg4, i64 %arg5) #0 { 518bb: 519 %tmp = icmp slt i32 %arg2, 9 520 %tmp6 = icmp eq i32 %arg1, 0 521 %tmp7 = icmp sgt i32 %arg4, 0 522 %tmp8 = icmp sgt i32 %arg4, 5 523 br i1 %tmp8, label %bb9, label %bb13 524 525bb9: ; preds = %bb 526 %tmp10 = and i1 %tmp7, %tmp 527 %tmp11 = icmp slt i32 %arg3, %arg4 528 %tmp12 = or i1 %tmp11, %tmp7 529 br i1 %tmp12, label %bb19, label %bb14 530 531bb13: ; preds = %bb 532 call void asm sideeffect 533 "v_nop_e64 534 v_nop_e64 535 v_nop_e64 536 v_nop_e64", ""() #0 537 br i1 %tmp6, label %bb19, label %bb14 538 539bb14: ; preds = %bb13, %bb9 540 %tmp15 = icmp slt i32 %arg3, %arg4 541 %tmp16 = or i1 %tmp15, %tmp 542 %tmp17 = and i1 %tmp6, %tmp16 543 %tmp18 = zext i1 %tmp17 to i32 544 br label %bb19 545 546bb19: ; preds = %bb14, %bb13, %bb9 547 %tmp20 = phi i32 [ undef, %bb9 ], [ undef, %bb13 ], [ %tmp18, %bb14 ] 548 %tmp21 = getelementptr inbounds i32, i32 addrspace(1)* %arg, i64 %arg5 549 store i32 %tmp20, i32 addrspace(1)* %tmp21, align 4 550 ret void 551} 552 553attributes #0 = { nounwind } 554attributes #1 = { nounwind readnone } 555