blob: ccf11ad1490074691ecfd04b5f8fc31bbcabb272 [file] [log] [blame]
Konstantin Zhuravlyovc8c9d4a2017-09-07 16:14:21 +00001# RUN: llc -march=amdgcn -mcpu=gfx803 -run-pass si-memory-legalizer %s -o - | FileCheck %s
2
3--- |
4 ; ModuleID = 'memory-legalizer-multiple-mem-operands.ll'
5 source_filename = "memory-legalizer-multiple-mem-operands.ll"
Yaxun Liu2a22c5d2018-02-02 16:07:16 +00006 target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5"
Konstantin Zhuravlyovc8c9d4a2017-09-07 16:14:21 +00007
8 define amdgpu_kernel void @multiple_mem_operands(i32 addrspace(1)* %out, i32 %cond, i32 %if_offset, i32 %else_offset) #0 {
9 entry:
Yaxun Liu2a22c5d2018-02-02 16:07:16 +000010 %scratch0 = alloca [8192 x i32], addrspace(5)
11 %scratch1 = alloca [8192 x i32], addrspace(5)
12 %scratchptr01 = bitcast [8192 x i32] addrspace(5)* %scratch0 to i32 addrspace(5)*
13 store i32 1, i32 addrspace(5)* %scratchptr01
14 %scratchptr12 = bitcast [8192 x i32] addrspace(5)* %scratch1 to i32 addrspace(5)*
15 store i32 2, i32 addrspace(5)* %scratchptr12
Konstantin Zhuravlyovc8c9d4a2017-09-07 16:14:21 +000016 %cmp = icmp eq i32 %cond, 0
17 br i1 %cmp, label %if, label %else, !structurizecfg.uniform !0, !amdgpu.uniform !0
18
19 if: ; preds = %entry
Yaxun Liu2a22c5d2018-02-02 16:07:16 +000020 %if_ptr = getelementptr [8192 x i32], [8192 x i32] addrspace(5)* %scratch0, i32 0, i32 %if_offset, !amdgpu.uniform !0
21 %if_value = load atomic i32, i32 addrspace(5)* %if_ptr syncscope("workgroup") seq_cst, align 4
Konstantin Zhuravlyovc8c9d4a2017-09-07 16:14:21 +000022 br label %done, !structurizecfg.uniform !0
23
24 else: ; preds = %entry
Yaxun Liu2a22c5d2018-02-02 16:07:16 +000025 %else_ptr = getelementptr [8192 x i32], [8192 x i32] addrspace(5)* %scratch1, i32 0, i32 %else_offset, !amdgpu.uniform !0
26 %else_value = load atomic i32, i32 addrspace(5)* %else_ptr syncscope("agent") unordered, align 4
Konstantin Zhuravlyovc8c9d4a2017-09-07 16:14:21 +000027 br label %done, !structurizecfg.uniform !0
28
29 done: ; preds = %else, %if
30 %value = phi i32 [ %if_value, %if ], [ %else_value, %else ]
31 store i32 %value, i32 addrspace(1)* %out
32 ret void
33 }
34
35 ; Function Attrs: convergent nounwind
36 declare { i1, i64 } @llvm.amdgcn.if(i1) #1
37
38 ; Function Attrs: convergent nounwind
39 declare { i1, i64 } @llvm.amdgcn.else(i64) #1
40
41 ; Function Attrs: convergent nounwind readnone
42 declare i64 @llvm.amdgcn.break(i64) #2
43
44 ; Function Attrs: convergent nounwind readnone
45 declare i64 @llvm.amdgcn.if.break(i1, i64) #2
46
47 ; Function Attrs: convergent nounwind readnone
48 declare i64 @llvm.amdgcn.else.break(i64, i64) #2
49
50 ; Function Attrs: convergent nounwind
51 declare i1 @llvm.amdgcn.loop(i64) #1
52
53 ; Function Attrs: convergent nounwind
54 declare void @llvm.amdgcn.end.cf(i64) #1
55
56 attributes #0 = { "target-cpu"="gfx803" }
57 attributes #1 = { convergent nounwind }
58 attributes #2 = { convergent nounwind readnone }
59
60 !0 = !{}
61
62...
63---
64
65# CHECK-LABEL: name: multiple_mem_operands
66
67# CHECK-LABEL: bb.3.done:
68# CHECK: S_WAITCNT 3952
69# CHECK-NEXT: BUFFER_LOAD_DWORD_OFFEN
70# CHECK-NEXT: S_WAITCNT 3952
71# CHECK-NEXT: BUFFER_WBINVL1_VOL
72
73name: multiple_mem_operands
74alignment: 0
75exposesReturnsTwice: false
76legalized: false
77regBankSelected: false
78selected: false
79tracksRegLiveness: true
80registers:
81liveins:
Puyan Lotfi43e94b12018-01-31 22:04:26 +000082 - { reg: '$sgpr0_sgpr1', virtual-reg: '' }
83 - { reg: '$sgpr3', virtual-reg: '' }
Konstantin Zhuravlyovc8c9d4a2017-09-07 16:14:21 +000084frameInfo:
85 isFrameAddressTaken: false
86 isReturnAddressTaken: false
87 hasStackMap: false
88 hasPatchPoint: false
89 stackSize: 65540
90 offsetAdjustment: 0
91 maxAlignment: 4
92 adjustsStack: false
93 hasCalls: false
94 stackProtector: ''
95 maxCallFrameSize: 0
96 hasOpaqueSPAdjustment: false
97 hasVAStart: false
98 hasMustTailInVarArgFunc: false
99 savePoint: ''
100 restorePoint: ''
101fixedStack:
102 - { id: 0, type: default, offset: 0, size: 4, alignment: 4, stack-id: 0,
103 isImmutable: false, isAliased: false, callee-saved-register: '' }
104stack:
105 - { id: 0, name: scratch0, type: default, offset: 4, size: 32768, alignment: 4,
106 stack-id: 0, callee-saved-register: '', local-offset: 0, di-variable: '',
107 di-expression: '', di-location: '' }
108 - { id: 1, name: scratch1, type: default, offset: 32772, size: 32768,
109 alignment: 4, stack-id: 0, callee-saved-register: '', local-offset: 32768,
110 di-variable: '', di-expression: '', di-location: '' }
111constants:
112body: |
113 bb.0.entry:
114 successors: %bb.1.if(0x30000000), %bb.2.else(0x50000000)
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000115 liveins: $sgpr0_sgpr1, $sgpr3
Konstantin Zhuravlyovc8c9d4a2017-09-07 16:14:21 +0000116
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000117 $sgpr2 = S_LOAD_DWORD_IMM $sgpr0_sgpr1, 44, 0 :: (non-temporal dereferenceable invariant load 4 from `i32 addrspace(2)* undef`)
118 $sgpr8 = S_MOV_B32 &SCRATCH_RSRC_DWORD0, implicit-def $sgpr8_sgpr9_sgpr10_sgpr11
119 $sgpr4_sgpr5 = S_LOAD_DWORDX2_IMM $sgpr0_sgpr1, 36, 0 :: (non-temporal dereferenceable invariant load 8 from `i64 addrspace(2)* undef`)
120 $sgpr9 = S_MOV_B32 &SCRATCH_RSRC_DWORD1, implicit-def $sgpr8_sgpr9_sgpr10_sgpr11
121 $sgpr10 = S_MOV_B32 4294967295, implicit-def $sgpr8_sgpr9_sgpr10_sgpr11
122 $sgpr11 = S_MOV_B32 15204352, implicit-def $sgpr8_sgpr9_sgpr10_sgpr11
123 $vgpr0 = V_MOV_B32_e32 1, implicit $exec
124 BUFFER_STORE_DWORD_OFFSET killed $vgpr0, $sgpr8_sgpr9_sgpr10_sgpr11, $sgpr3, 4, 0, 0, 0, implicit $exec :: (store 4 into %ir.scratchptr01)
Konstantin Zhuravlyovc8c9d4a2017-09-07 16:14:21 +0000125 S_WAITCNT 127
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000126 S_CMP_LG_U32 killed $sgpr2, 0, implicit-def $scc
Konstantin Zhuravlyovc8c9d4a2017-09-07 16:14:21 +0000127 S_WAITCNT 3855
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000128 $vgpr0 = V_MOV_B32_e32 2, implicit $exec
129 $vgpr1 = V_MOV_B32_e32 32772, implicit $exec
130 BUFFER_STORE_DWORD_OFFEN killed $vgpr0, killed $vgpr1, $sgpr8_sgpr9_sgpr10_sgpr11, $sgpr3, 0, 0, 0, 0, implicit $exec :: (store 4 into %ir.scratchptr12)
131 S_CBRANCH_SCC0 %bb.1.if, implicit killed $scc
Konstantin Zhuravlyovc8c9d4a2017-09-07 16:14:21 +0000132
133 bb.2.else:
134 successors: %bb.3.done(0x80000000)
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000135 liveins: $sgpr0_sgpr1, $sgpr4_sgpr5, $sgpr3, $sgpr8_sgpr9_sgpr10_sgpr11
Konstantin Zhuravlyovc8c9d4a2017-09-07 16:14:21 +0000136
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000137 $sgpr0 = S_LOAD_DWORD_IMM killed $sgpr0_sgpr1, 52, 0 :: (non-temporal dereferenceable invariant load 4 from `i32 addrspace(2)* undef`)
Konstantin Zhuravlyovc8c9d4a2017-09-07 16:14:21 +0000138 S_WAITCNT 3855
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000139 $vgpr0 = V_MOV_B32_e32 32772, implicit $exec
Konstantin Zhuravlyovc8c9d4a2017-09-07 16:14:21 +0000140 S_BRANCH %bb.3.done
141
142 bb.1.if:
143 successors: %bb.3.done(0x80000000)
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000144 liveins: $sgpr0_sgpr1, $sgpr4_sgpr5, $sgpr3, $sgpr8_sgpr9_sgpr10_sgpr11
Konstantin Zhuravlyovc8c9d4a2017-09-07 16:14:21 +0000145
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000146 $sgpr0 = S_LOAD_DWORD_IMM killed $sgpr0_sgpr1, 48, 0 :: (non-temporal dereferenceable invariant load 4 from `i32 addrspace(2)* undef`)
Konstantin Zhuravlyovc8c9d4a2017-09-07 16:14:21 +0000147 S_WAITCNT 3855
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000148 $vgpr0 = V_MOV_B32_e32 4, implicit $exec
Konstantin Zhuravlyovc8c9d4a2017-09-07 16:14:21 +0000149
150 bb.3.done:
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000151 liveins: $sgpr3, $sgpr4_sgpr5, $sgpr8_sgpr9_sgpr10_sgpr11, $vgpr0, $sgpr0
Konstantin Zhuravlyovc8c9d4a2017-09-07 16:14:21 +0000152
153 S_WAITCNT 127
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000154 $sgpr0 = S_LSHL_B32 killed $sgpr0, 2, implicit-def dead $scc
155 $vgpr0 = V_ADD_I32_e32 killed $sgpr0, killed $vgpr0, implicit-def dead $vcc, implicit $exec
156 $vgpr0 = BUFFER_LOAD_DWORD_OFFEN killed $vgpr0, killed $sgpr8_sgpr9_sgpr10_sgpr11, $sgpr3, 0, 0, 0, 0, implicit $exec :: (load syncscope("agent") unordered 4 from %ir.else_ptr), (load syncscope("workgroup") seq_cst 4 from %ir.if_ptr)
157 $vgpr1 = V_MOV_B32_e32 $sgpr4, implicit $exec, implicit-def $vgpr1_vgpr2, implicit $sgpr4_sgpr5
158 $vgpr2 = V_MOV_B32_e32 killed $sgpr5, implicit $exec, implicit $sgpr4_sgpr5, implicit $exec
Konstantin Zhuravlyovc8c9d4a2017-09-07 16:14:21 +0000159 S_WAITCNT 3952
Puyan Lotfi43e94b12018-01-31 22:04:26 +0000160 FLAT_STORE_DWORD killed $vgpr1_vgpr2, killed $vgpr0, 0, 0, 0, implicit $exec, implicit $flat_scr :: (store 4 into %ir.out)
Konstantin Zhuravlyovc8c9d4a2017-09-07 16:14:21 +0000161 S_ENDPGM
162
163...