1# RUN: llc -march=amdgcn -run-pass=si-memory-legalizer %s -o - | FileCheck %s 2 3--- | 4 declare i32 @llvm.amdgcn.workitem.id.x() #0 5 6 define amdgpu_kernel void @atomic_max_i32_noret( 7 i32 addrspace(1)* %out, 8 i32 addrspace(1)* addrspace(1)* %in, 9 i32 addrspace(1)* %x, 10 i32 %y) #1 { 11 %tid = call i32 @llvm.amdgcn.workitem.id.x() 12 %idxprom = sext i32 %tid to i64 13 %tid.gep = getelementptr i32 addrspace(1)*, i32 addrspace(1)* addrspace(1)* %in, i64 %idxprom 14 %ptr = load volatile i32 addrspace(1)*, i32 addrspace(1)* 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 21 22 atomic: ; preds = %0 23 %gep = getelementptr i32, i32 addrspace(1)* %ptr, i32 100 24 %ret = atomicrmw max i32 addrspace(1)* %gep, i32 %y seq_cst 25 br label %exit 26 27 exit: ; preds = %atomic, %0 28 call void @llvm.amdgcn.end.cf(i64 %3) 29 ret void 30 } 31 32 declare { i1, i64 } @llvm.amdgcn.if(i1) 33 34 declare void @llvm.amdgcn.end.cf(i64) 35 36 attributes #0 = { nounwind readnone } 37 attributes #1 = { nounwind "target-cpu"="gfx803" } 38 39... 40--- 41 42# CHECK-LABEL: name: atomic_max_i32_noret 43 44# CHECK-LABEL: bb.1.atomic: 45# CHECK: BUFFER_ATOMIC_SMAX_ADDR64 46# CHECK-NEXT: S_WAITCNT 3952 47# CHECK-NEXT: BUFFER_WBINVL1_VOL 48 49name: atomic_max_i32_noret 50alignment: 1 51exposesReturnsTwice: false 52legalized: false 53regBankSelected: false 54selected: false 55tracksRegLiveness: true 56liveins: 57 - { reg: '$sgpr0_sgpr1' } 58 - { reg: '$vgpr0' } 59frameInfo: 60 isFrameAddressTaken: false 61 isReturnAddressTaken: false 62 hasStackMap: false 63 hasPatchPoint: false 64 stackSize: 0 65 offsetAdjustment: 0 66 maxAlignment: 0 67 adjustsStack: false 68 hasCalls: false 69 maxCallFrameSize: 0 70 hasOpaqueSPAdjustment: false 71 hasVAStart: false 72 hasMustTailInVarArgFunc: false 73body: | 74 bb.0 (%ir-block.0): 75 successors: %bb.1.atomic(0x40000000), %bb.2.exit(0x40000000) 76 liveins: $vgpr0, $sgpr0_sgpr1 77 78 $sgpr4_sgpr5 = S_LOAD_DWORDX2_IMM $sgpr0_sgpr1, 11, 0, 0 :: (non-temporal dereferenceable invariant load 8 from `i64 addrspace(4)* undef`) 79 $vgpr1 = V_ASHRREV_I32_e32 31, $vgpr0, implicit $exec 80 $vgpr1_vgpr2 = V_LSHL_B64 $vgpr0_vgpr1, 3, implicit $exec 81 $sgpr7 = S_MOV_B32 61440 82 $sgpr6 = S_MOV_B32 0 83 S_WAITCNT 127 84 $vgpr1_vgpr2 = BUFFER_LOAD_DWORDX2_ADDR64 killed $vgpr1_vgpr2, $sgpr4_sgpr5_sgpr6_sgpr7, 0, 0, 0, 0, 0, 0, 0, implicit $exec :: (volatile load 8 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 SI_MASK_BRANCH %bb.2.exit, implicit $exec 90 91 bb.1.atomic: 92 successors: %bb.2.exit(0x80000000) 93 liveins: $sgpr4_sgpr5_sgpr6_sgpr7:0x0000000C, $sgpr0_sgpr1, $sgpr2_sgpr3, $vgpr1_vgpr2_vgpr3_vgpr4:0x00000003 94 95 $sgpr0 = S_LOAD_DWORD_IMM killed $sgpr0_sgpr1, 15, 0, 0 :: (non-temporal dereferenceable invariant load 4 from `i32 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 99 S_WAITCNT 127 100 $vgpr0 = V_MOV_B32_e32 killed $sgpr0, implicit $exec, implicit $exec 101 S_WAITCNT 3952 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 4 from %ir.gep) 103 104 bb.2.exit: 105 liveins: $sgpr2_sgpr3 106 107 $exec = S_OR_B64 $exec, killed $sgpr2_sgpr3, implicit-def $scc 108 S_ENDPGM 0 109 110... 111 112