blob: 790715cda728e27f575b5b36d1170a1420b5802d [file] [log] [blame]
Scott Linderc6c62722018-10-31 18:54:06 +00001;RUN: llc < %s -march=amdgcn -mcpu=verde -mattr=-promote-alloca -verify-machineinstrs | FileCheck %s -check-prefix=CHECK
2;RUN: llc < %s -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -mattr=-promote-alloca -verify-machineinstrs | FileCheck %s -check-prefix=CHECK
Nicolai Haehnle2857dc32016-12-08 14:08:02 +00003
4; Allocate two stack slots of 2052 bytes each requiring a total of 4104 bytes.
5; Extracting the last element of each does not fit into the offset field of
6; MUBUF instructions, so a new base register is needed. This used to not
7; happen, leading to an assertion.
8
9; CHECK-LABEL: {{^}}main:
10; CHECK: buffer_store_dword
11; CHECK: buffer_store_dword
12; CHECK: buffer_load_dword
13; CHECK: buffer_load_dword
14define amdgpu_gs float @main(float %v1, float %v2, i32 %idx1, i32 %idx2) {
15main_body:
Yaxun Liu2a22c5d2018-02-02 16:07:16 +000016 %m1 = alloca [513 x float], addrspace(5)
17 %m2 = alloca [513 x float], addrspace(5)
Nicolai Haehnle2857dc32016-12-08 14:08:02 +000018
Yaxun Liu2a22c5d2018-02-02 16:07:16 +000019 %gep1.store = getelementptr [513 x float], [513 x float] addrspace(5)* %m1, i32 0, i32 %idx1
20 store float %v1, float addrspace(5)* %gep1.store
Nicolai Haehnle2857dc32016-12-08 14:08:02 +000021
Yaxun Liu2a22c5d2018-02-02 16:07:16 +000022 %gep2.store = getelementptr [513 x float], [513 x float] addrspace(5)* %m2, i32 0, i32 %idx2
23 store float %v2, float addrspace(5)* %gep2.store
Nicolai Haehnle2857dc32016-12-08 14:08:02 +000024
25; This used to use a base reg equal to 0.
Yaxun Liu2a22c5d2018-02-02 16:07:16 +000026 %gep1.load = getelementptr [513 x float], [513 x float] addrspace(5)* %m1, i32 0, i32 0
27 %out1 = load float, float addrspace(5)* %gep1.load
Nicolai Haehnle2857dc32016-12-08 14:08:02 +000028
29; This used to attempt to re-use the base reg at 0, generating an out-of-bounds instruction offset.
Yaxun Liu2a22c5d2018-02-02 16:07:16 +000030 %gep2.load = getelementptr [513 x float], [513 x float] addrspace(5)* %m2, i32 0, i32 512
31 %out2 = load float, float addrspace(5)* %gep2.load
Nicolai Haehnle2857dc32016-12-08 14:08:02 +000032
33 %r = fadd float %out1, %out2
34 ret float %r
35}