1 # RUN: llc -march=amdgcn -run-pass=si-memory-legalizer %s -o - | FileCheck %s
4 declare i32 @llvm.amdgcn.workitem.id.x() #0
6 define amdgpu_kernel void @atomic_max_i32_noret(
11 %tid = call i32 @llvm.amdgcn.workitem.id.x()
12 %idxprom = sext i32 %tid to i64
13 %tid.gep = getelementptr ptr addrspace(1), ptr addrspace(1) %in, i64 %idxprom
14 %ptr = load volatile ptr addrspace(1), ptr addrspace(1) %tid.gep
15 %xor = xor i32 %tid, 1
16 %cmp = icmp ne i32 %xor, 0
17 %1 = call { i1, i64 } @llvm.amdgcn.if(i1 %cmp)
18 %2 = extractvalue { i1, i64 } %1, 0
19 %3 = extractvalue { i1, i64 } %1, 1
20 br i1 %2, label %atomic, label %exit
23 %gep = getelementptr i32, ptr addrspace(1) %ptr, i32 100
24 %ret = atomicrmw max ptr addrspace(1) %gep, i32 %y seq_cst
27 exit: ; preds = %atomic, %0
28 call void @llvm.amdgcn.end.cf(i64 %3)
32 declare { i1, i64 } @llvm.amdgcn.if(i1)
34 declare void @llvm.amdgcn.end.cf(i64)
36 attributes #0 = { nounwind readnone }
37 attributes #1 = { nounwind "target-cpu"="gfx803" }
42 # CHECK-LABEL: name: atomic_max_i32_noret
44 # CHECK-LABEL: bb.1.atomic:
45 # CHECK: BUFFER_ATOMIC_SMAX_ADDR64
46 # CHECK-NEXT: S_WAITCNT 3952
47 # CHECK-NEXT: BUFFER_WBINVL1_VOL
49 name: atomic_max_i32_noret
51 exposesReturnsTwice: false
53 regBankSelected: false
55 tracksRegLiveness: true
57 - { reg: '$sgpr0_sgpr1' }
60 isFrameAddressTaken: false
61 isReturnAddressTaken: false
70 hasOpaqueSPAdjustment: false
72 hasMustTailInVarArgFunc: false
75 successors: %bb.1.atomic(0x40000000), %bb.2.exit(0x40000000)
76 liveins: $vgpr0, $sgpr0_sgpr1
78 $sgpr4_sgpr5 = S_LOAD_DWORDX2_IMM $sgpr0_sgpr1, 11, 0 :: (non-temporal dereferenceable invariant load (s64) from `ptr addrspace(4) undef`)
79 $vgpr1 = V_ASHRREV_I32_e32 31, $vgpr0, implicit $exec
80 $vgpr1_vgpr2 = V_LSHL_B64_e64 $vgpr0_vgpr1, 3, implicit $exec
81 $sgpr7 = S_MOV_B32 61440
84 $vgpr1_vgpr2 = BUFFER_LOAD_DWORDX2_ADDR64 killed $vgpr1_vgpr2, $sgpr4_sgpr5_sgpr6_sgpr7, 0, 0, 0, 0, implicit $exec :: (volatile load (s64) from %ir.tid.gep)
85 $vgpr0 = V_XOR_B32_e32 1, killed $vgpr0, implicit $exec
86 V_CMP_NE_U32_e32 0, killed $vgpr0, implicit-def $vcc, implicit $exec
87 $sgpr2_sgpr3 = S_AND_SAVEEXEC_B64 killed $vcc, implicit-def $exec, implicit-def $scc, implicit $exec
88 $sgpr2_sgpr3 = S_XOR_B64 $exec, killed $sgpr2_sgpr3, implicit-def dead $scc
89 S_CBRANCH_EXECZ %bb.2.exit, implicit $exec
92 successors: %bb.2.exit(0x80000000)
93 liveins: $sgpr4_sgpr5_sgpr6_sgpr7:0x0000000C, $sgpr0_sgpr1, $sgpr2_sgpr3, $vgpr1_vgpr2_vgpr3_vgpr4:0x00000003
95 $sgpr0 = S_LOAD_DWORD_IMM killed $sgpr0_sgpr1, 15, 0 :: (non-temporal dereferenceable invariant load (s32) from `ptr addrspace(4) undef`)
96 dead $vgpr0 = V_MOV_B32_e32 -1, implicit $exec
97 dead $vgpr0 = V_MOV_B32_e32 61440, implicit $exec
98 $sgpr4_sgpr5 = S_MOV_B64 0
100 $vgpr0 = V_MOV_B32_e32 killed $sgpr0, implicit $exec, implicit $exec
102 BUFFER_ATOMIC_SMAX_ADDR64 killed $vgpr0, killed $vgpr1_vgpr2, killed $sgpr4_sgpr5_sgpr6_sgpr7, 0, 400, 0, implicit $exec :: (volatile load syncscope("one-as") seq_cst (s32) from %ir.gep)
105 liveins: $sgpr2_sgpr3
107 $exec = S_OR_B64 $exec, killed $sgpr2_sgpr3, implicit-def $scc