1 # RUN: llc -march=amdgcn -mcpu=gfx803 -verify-machineinstrs -run-pass si-load-store-opt -o - %s | FileCheck -check-prefixes=GCN,VI %s
2 # RUN: llc -march=amdgcn -mcpu=gfx900 -verify-machineinstrs -run-pass si-load-store-opt -o - %s | FileCheck -check-prefixes=GCN,GFX9 %s
4 # If there's a base offset, check that SILoadStoreOptimizer creates
5 # V_ADD_{I|U}32_e64 for that offset; _e64 uses a vreg for the carry (rather than
6 # $vcc, which is used in _e32); this ensures that $vcc is not inadvertently
9 # GCN-LABEL: name: ds_combine_base_offset{{$}}
11 # VI: V_ADD_I32_e64 %6, %0,
12 # VI-NEXT: DS_WRITE2_B32 killed %7, %0, %3, 0, 8,
13 # VI: V_ADD_I32_e64 %10, %3,
14 # VI-NEXT: DS_READ2_B32 killed %11, 0, 8,
16 # GFX9: V_ADD_U32_e64 %6, %0,
17 # GFX9-NEXT: DS_WRITE2_B32_gfx9 killed %7, %0, %3, 0, 8,
18 # GFX9: V_ADD_U32_e64 %9, %3,
19 # GFX9-NEXT: DS_READ2_B32_gfx9 killed %10, 0, 8,
22 @0 = internal unnamed_addr addrspace(3) global [256 x float] undef, align 4
24 define amdgpu_kernel void @ds_combine_base_offset() {
32 %tmp = getelementptr inbounds [256 x float], [256 x float] addrspace(3)* @0, i32 0, i32 0
33 %tmp1 = getelementptr inbounds float, float addrspace(3)* %tmp, i32 8
34 %tmp2 = getelementptr inbounds float, float addrspace(3)* %tmp, i32 16
35 %tmp3 = getelementptr inbounds float, float addrspace(3)* %tmp, i32 24
39 define amdgpu_kernel void @ds_combine_base_offset_subreg() {
47 %tmp = getelementptr inbounds [256 x float], [256 x float] addrspace(3)* @0, i32 0, i32 0
48 %tmp1 = getelementptr inbounds float, float addrspace(3)* %tmp, i32 8
49 %tmp2 = getelementptr inbounds float, float addrspace(3)* %tmp, i32 16
50 %tmp3 = getelementptr inbounds float, float addrspace(3)* %tmp, i32 24
54 define amdgpu_kernel void @ds_combine_subreg() {
62 %tmp = getelementptr inbounds [256 x float], [256 x float] addrspace(3)* @0, i32 0, i32 0
63 %tmp1 = getelementptr inbounds float, float addrspace(3)* %tmp, i32 8
64 %tmp2 = getelementptr inbounds float, float addrspace(3)* %tmp, i32 16
65 %tmp3 = getelementptr inbounds float, float addrspace(3)* %tmp, i32 24
69 name: ds_combine_base_offset
72 %0:vgpr_32 = IMPLICIT_DEF
79 %1:sreg_64_xexec = V_CMP_NE_U32_e64 %0, 0, implicit $exec
80 %2:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, %1, implicit $exec
81 V_CMP_NE_U32_e32 1, %2, implicit-def $vcc, implicit $exec
82 DS_WRITE_B32 %0, %0, 1024, 0, implicit $m0, implicit $exec :: (store 4 into %ir.tmp)
83 %3:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
84 DS_WRITE_B32 %0, %3, 1056, 0, implicit $m0, implicit $exec :: (store 4 into %ir.tmp1)
85 %4:vgpr_32 = DS_READ_B32 %3, 1088, 0, implicit $m0, implicit $exec :: (load 4 from %ir.tmp2)
86 %5:vgpr_32 = DS_READ_B32 %3, 1120, 0, implicit $m0, implicit $exec :: (load 4 from %ir.tmp3)
87 $vcc = S_AND_B64 $exec, $vcc, implicit-def $scc
88 S_CBRANCH_VCCNZ %bb.1, implicit $vcc
92 # GCN-LABEL: name: ds_combine_base_offset_subreg{{$}}
94 # VI: V_ADD_I32_e64 %6, %0.sub0,
95 # VI-NEXT: DS_WRITE2_B32 killed %7, %0.sub0, %3.sub0, 0, 8,
96 # VI: V_ADD_I32_e64 %10, %3.sub0,
97 # VI-NEXT: DS_READ2_B32 killed %11, 0, 8,
99 # GFX9: V_ADD_U32_e64 %6, %0.sub0,
100 # GFX9-NEXT: DS_WRITE2_B32_gfx9 killed %7, %0.sub0, %3.sub0, 0, 8,
101 # GFX9: V_ADD_U32_e64 %9, %3.sub0,
102 # GFX9-NEXT: DS_READ2_B32_gfx9 killed %10, 0, 8,
104 name: ds_combine_base_offset_subreg
107 %0:vreg_64 = IMPLICIT_DEF
114 %1:sreg_64_xexec = V_CMP_NE_U32_e64 %0.sub0, 0, implicit $exec
115 %2:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, %1, implicit $exec
116 V_CMP_NE_U32_e32 1, %2, implicit-def $vcc, implicit $exec
117 DS_WRITE_B32 %0.sub0, %0.sub0, 1024, 0, implicit $m0, implicit $exec :: (store 4 into %ir.tmp)
118 undef %3.sub0:vreg_64 = V_MOV_B32_e32 0, implicit $exec
119 DS_WRITE_B32 %0.sub0, %3.sub0, 1056, 0, implicit $m0, implicit $exec :: (store 4 into %ir.tmp1)
120 %4:vgpr_32 = DS_READ_B32 %3.sub0, 1088, 0, implicit $m0, implicit $exec :: (load 4 from %ir.tmp2)
121 %5:vgpr_32 = DS_READ_B32 %3.sub0, 1120, 0, implicit $m0, implicit $exec :: (load 4 from %ir.tmp3)
122 $vcc = S_AND_B64 $exec, $vcc, implicit-def $scc
123 S_CBRANCH_VCCNZ %bb.1, implicit $vcc
127 # GCN-LABEL: name: ds_combine_subreg{{$}}
129 # VI: DS_WRITE2_B32 %0.sub0, %0.sub0, %3.sub0, 0, 8,
130 # VI: DS_READ2_B32 %3.sub0, 0, 8,
132 # GFX9: DS_WRITE2_B32_gfx9 %0.sub0, %0.sub0, %3.sub0, 0, 8,
133 # GFX9: DS_READ2_B32_gfx9 %3.sub0, 0, 8,
135 name: ds_combine_subreg
138 %0:vreg_64 = IMPLICIT_DEF
145 %1:sreg_64_xexec = V_CMP_NE_U32_e64 %0.sub0, 0, implicit $exec
146 %2:vgpr_32 = V_CNDMASK_B32_e64 0, 0, 0, 1, %1, implicit $exec
147 V_CMP_NE_U32_e32 1, %2, implicit-def $vcc, implicit $exec
148 DS_WRITE_B32 %0.sub0, %0.sub0, 0, 0, implicit $m0, implicit $exec :: (store 4 into %ir.tmp)
149 undef %3.sub0:vreg_64 = V_MOV_B32_e32 0, implicit $exec
150 DS_WRITE_B32 %0.sub0, %3.sub0, 32, 0, implicit $m0, implicit $exec :: (store 4 into %ir.tmp1)
151 %4:vgpr_32 = DS_READ_B32 %3.sub0, 0, 0, implicit $m0, implicit $exec :: (load 4 from %ir.tmp2)
152 %5:vgpr_32 = DS_READ_B32 %3.sub0, 32, 0, implicit $m0, implicit $exec :: (load 4 from %ir.tmp3)
153 $vcc = S_AND_B64 $exec, $vcc, implicit-def $scc
154 S_CBRANCH_VCCNZ %bb.1, implicit $vcc