1 # RUN: llc -mtriple=amdgcn -mcpu=gfx803 -run-pass si-memory-legalizer %s -o - | FileCheck %s
4 define amdgpu_kernel void @multiple_mem_operands(ptr addrspace(1) %out, i32 %cond, i32 %if_offset, i32 %else_offset) #0 {
6 %scratch0 = alloca [8192 x i32], addrspace(5)
7 %scratch1 = alloca [8192 x i32], addrspace(5)
8 %scratchptr01 = bitcast ptr addrspace(5) %scratch0 to ptr addrspace(5)
9 store i32 1, ptr addrspace(5) %scratchptr01
10 %scratchptr12 = bitcast ptr addrspace(5) %scratch1 to ptr addrspace(5)
11 store i32 2, ptr addrspace(5) %scratchptr12
12 %cmp = icmp eq i32 %cond, 0
13 br i1 %cmp, label %if, label %else, !structurizecfg.uniform !0, !amdgpu.uniform !0
16 %if_ptr = getelementptr [8192 x i32], ptr addrspace(5) %scratch0, i32 0, i32 %if_offset, !amdgpu.uniform !0
17 %if_value = load i32, ptr addrspace(5) %if_ptr, align 4, !nontemporal !1
18 br label %done, !structurizecfg.uniform !0
20 else: ; preds = %entry
21 %else_ptr = getelementptr [8192 x i32], ptr addrspace(5) %scratch1, i32 0, i32 %else_offset, !amdgpu.uniform !0
22 %else_value = load i32, ptr addrspace(5) %else_ptr, align 4, !nontemporal !1
23 br label %done, !structurizecfg.uniform !0
25 done: ; preds = %else, %if
26 %value = phi i32 [ %if_value, %if ], [ %else_value, %else ]
27 store i32 %value, ptr addrspace(1) %out
31 ; Function Attrs: convergent nounwind
32 declare { i1, i64 } @llvm.amdgcn.if(i1) #1
34 ; Function Attrs: convergent nounwind
35 declare { i1, i64 } @llvm.amdgcn.else(i64) #1
37 ; Function Attrs: convergent nounwind readnone
38 declare i64 @llvm.amdgcn.break(i64) #2
40 ; Function Attrs: convergent nounwind readnone
41 declare i64 @llvm.amdgcn.if.break(i1, i64) #2
43 ; Function Attrs: convergent nounwind readnone
44 declare i64 @llvm.amdgcn.else.break(i64, i64) #2
46 ; Function Attrs: convergent nounwind
47 declare i1 @llvm.amdgcn.loop(i64) #1
49 ; Function Attrs: convergent nounwind
50 declare void @llvm.amdgcn.end.cf(i64) #1
52 attributes #0 = { "target-cpu"="gfx803" }
53 attributes #1 = { convergent nounwind }
54 attributes #2 = { convergent nounwind readnone }
62 # CHECK-LABEL: name: multiple_mem_operands
64 # CHECK-LABEL: bb.3.done:
65 # CHECK: BUFFER_LOAD_DWORD_OFFEN killed $vgpr0, killed $sgpr8_sgpr9_sgpr10_sgpr11, $sgpr3, 0, 3
67 name: multiple_mem_operands
69 exposesReturnsTwice: false
71 regBankSelected: false
73 tracksRegLiveness: true
76 - { reg: '$sgpr0_sgpr1', virtual-reg: '' }
77 - { reg: '$sgpr3', virtual-reg: '' }
79 isFrameAddressTaken: false
80 isReturnAddressTaken: false
90 hasOpaqueSPAdjustment: false
92 hasMustTailInVarArgFunc: false
96 - { id: 0, type: default, offset: 0, size: 4, alignment: 4, stack-id: default,
97 isImmutable: false, isAliased: false, callee-saved-register: '' }
99 - { id: 0, name: scratch0, type: default, offset: 4, size: 32768, alignment: 4,
100 stack-id: default, callee-saved-register: '', local-offset: 0,
101 debug-info-variable: '', debug-info-expression: '',
102 debug-info-location: '' }
103 - { id: 1, name: scratch1, type: default, offset: 32772, size: 32768,
104 alignment: 4, stack-id: default, callee-saved-register: '', local-offset: 32768,
105 debug-info-variable: '', debug-info-expression: '',
106 debug-info-location: '' }
110 successors: %bb.1.if(0x30000000), %bb.2.else(0x50000000)
111 liveins: $sgpr0_sgpr1, $sgpr3
113 $sgpr2 = S_LOAD_DWORD_IMM $sgpr0_sgpr1, 44, 0 :: (non-temporal dereferenceable invariant load (s32) from `ptr addrspace(4) undef`)
114 $sgpr8 = S_MOV_B32 &SCRATCH_RSRC_DWORD0, implicit-def $sgpr8_sgpr9_sgpr10_sgpr11
115 $sgpr4_sgpr5 = S_LOAD_DWORDX2_IMM $sgpr0_sgpr1, 36, 0 :: (non-temporal dereferenceable invariant load (s64) from `ptr addrspace(4) undef`)
116 $sgpr9 = S_MOV_B32 &SCRATCH_RSRC_DWORD1, implicit-def $sgpr8_sgpr9_sgpr10_sgpr11
117 $sgpr10 = S_MOV_B32 4294967295, implicit-def $sgpr8_sgpr9_sgpr10_sgpr11
118 $sgpr11 = S_MOV_B32 15204352, implicit-def $sgpr8_sgpr9_sgpr10_sgpr11
119 $vgpr0 = V_MOV_B32_e32 1, implicit $exec
120 BUFFER_STORE_DWORD_OFFSET killed $vgpr0, $sgpr8_sgpr9_sgpr10_sgpr11, $sgpr3, 4, 0, 0, implicit $exec :: (store (s32) into %ir.scratchptr01)
122 S_CMP_LG_U32 killed $sgpr2, 0, implicit-def $scc
124 $vgpr0 = V_MOV_B32_e32 2, implicit $exec
125 $vgpr1 = V_MOV_B32_e32 32772, implicit $exec
126 BUFFER_STORE_DWORD_OFFEN killed $vgpr0, killed $vgpr1, $sgpr8_sgpr9_sgpr10_sgpr11, $sgpr3, 0, 0, 0, implicit $exec :: (store (s32) into %ir.scratchptr12)
127 S_CBRANCH_SCC0 %bb.1.if, implicit killed $scc
130 successors: %bb.3.done(0x80000000)
131 liveins: $sgpr0_sgpr1, $sgpr4_sgpr5, $sgpr3, $sgpr8_sgpr9_sgpr10_sgpr11
133 $sgpr0 = S_LOAD_DWORD_IMM killed $sgpr0_sgpr1, 52, 0 :: (non-temporal dereferenceable invariant load (s32) from `ptr addrspace(4) undef`)
135 $vgpr0 = V_MOV_B32_e32 32772, implicit $exec
139 successors: %bb.3.done(0x80000000)
140 liveins: $sgpr0_sgpr1, $sgpr4_sgpr5, $sgpr3, $sgpr8_sgpr9_sgpr10_sgpr11
142 $sgpr0 = S_LOAD_DWORD_IMM killed $sgpr0_sgpr1, 48, 0 :: (non-temporal dereferenceable invariant load (s32) from `ptr addrspace(4) undef`)
144 $vgpr0 = V_MOV_B32_e32 4, implicit $exec
147 liveins: $sgpr3, $sgpr4_sgpr5, $sgpr8_sgpr9_sgpr10_sgpr11, $vgpr0, $sgpr0
150 $sgpr0 = S_LSHL_B32 killed $sgpr0, 2, implicit-def dead $scc
151 $vgpr0 = V_ADD_CO_U32_e32 killed $sgpr0, killed $vgpr0, implicit-def dead $vcc, implicit $exec
152 $vgpr0 = BUFFER_LOAD_DWORD_OFFEN killed $vgpr0, killed $sgpr8_sgpr9_sgpr10_sgpr11, $sgpr3, 0, 0, 0, implicit $exec :: (non-temporal load (s32) from %ir.else_ptr), (non-temporal load (s32) from %ir.if_ptr)
153 $vgpr1 = V_MOV_B32_e32 $sgpr4, implicit $exec, implicit-def $vgpr1_vgpr2, implicit $sgpr4_sgpr5
154 $vgpr2 = V_MOV_B32_e32 killed $sgpr5, implicit $exec, implicit $sgpr4_sgpr5, implicit $exec
156 FLAT_STORE_DWORD killed $vgpr1_vgpr2, killed $vgpr0, 0, 0, implicit $exec, implicit $flat_scr :: (store (s32) into %ir.out)