blob: 03d99baaafab4afe8c277f5158d62c89029152b2 [file] [log] [blame]
Matt Arsenault7aad8fd2017-01-24 22:02:15 +00001; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=GCN -check-prefix=FUNC %s
2; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefix=VI -check-prefix=GCN -check-prefix=FUNC %s
Matt Arsenault310f7612014-05-21 22:42:38 +00003; RUN: llc -march=r600 -mcpu=redwood < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
Jan Veselyf97de002016-05-13 20:39:29 +00004; RUN: llc -march=r600 -mcpu=cayman < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s
Matt Arsenault310f7612014-05-21 22:42:38 +00005
6
Yaxun Liu0124b542018-02-13 18:00:25 +00007@b = internal addrspace(4) constant [1 x i16] [ i16 7 ], align 2
Tom Stellard04c0e982014-01-22 19:24:21 +00008
Yaxun Liu0124b542018-02-13 18:00:25 +00009@float_gv = internal unnamed_addr addrspace(4) constant [5 x float] [float 0.0, float 1.0, float 2.0, float 3.0, float 4.0], align 4
Tom Stellard04c0e982014-01-22 19:24:21 +000010
Tom Stellard79243d92014-10-01 17:15:17 +000011; FUNC-LABEL: {{^}}float:
Marek Olsak93df0602015-07-27 18:16:08 +000012; GCN: s_load_dword
Tom Stellard04c0e982014-01-22 19:24:21 +000013
Jan Veselyf97de002016-05-13 20:39:29 +000014; EG: VTX_READ_32
15; EG: @float_gv
16; EG-NOT: MOVA_INT
Jan Vesely16800392016-05-13 20:39:31 +000017; EG-NOT: MOV
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000018define amdgpu_kernel void @float(float addrspace(1)* %out, i32 %index) {
Tom Stellard04c0e982014-01-22 19:24:21 +000019entry:
Yaxun Liu0124b542018-02-13 18:00:25 +000020 %0 = getelementptr inbounds [5 x float], [5 x float] addrspace(4)* @float_gv, i32 0, i32 %index
21 %1 = load float, float addrspace(4)* %0
Tom Stellard04c0e982014-01-22 19:24:21 +000022 store float %1, float addrspace(1)* %out
23 ret void
24}
25
Yaxun Liu0124b542018-02-13 18:00:25 +000026@i32_gv = internal unnamed_addr addrspace(4) constant [5 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4], align 4
Tom Stellard04c0e982014-01-22 19:24:21 +000027
Tom Stellard79243d92014-10-01 17:15:17 +000028; FUNC-LABEL: {{^}}i32:
Tom Stellard04c0e982014-01-22 19:24:21 +000029
Marek Olsak93df0602015-07-27 18:16:08 +000030; GCN: s_load_dword
Tom Stellard067c8152014-07-21 14:01:14 +000031
Jan Veselyf97de002016-05-13 20:39:29 +000032; EG: VTX_READ_32
33; EG: @i32_gv
34; EG-NOT: MOVA_INT
Jan Vesely16800392016-05-13 20:39:31 +000035; EG-NOT: MOV
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000036define amdgpu_kernel void @i32(i32 addrspace(1)* %out, i32 %index) {
Tom Stellard04c0e982014-01-22 19:24:21 +000037entry:
Yaxun Liu0124b542018-02-13 18:00:25 +000038 %0 = getelementptr inbounds [5 x i32], [5 x i32] addrspace(4)* @i32_gv, i32 0, i32 %index
39 %1 = load i32, i32 addrspace(4)* %0
Tom Stellard04c0e982014-01-22 19:24:21 +000040 store i32 %1, i32 addrspace(1)* %out
41 ret void
42}
Matt Arsenault6a57fd82014-05-21 22:42:42 +000043
44
45%struct.foo = type { float, [5 x i32] }
46
Yaxun Liu0124b542018-02-13 18:00:25 +000047@struct_foo_gv = internal unnamed_addr addrspace(4) constant [1 x %struct.foo] [ %struct.foo { float 16.0, [5 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4] } ]
Matt Arsenault6a57fd82014-05-21 22:42:42 +000048
Tom Stellard79243d92014-10-01 17:15:17 +000049; FUNC-LABEL: {{^}}struct_foo_gv_load:
Marek Olsakfa6607d2015-02-11 14:26:46 +000050; GCN: s_load_dword
Matt Arsenault6a57fd82014-05-21 22:42:42 +000051
Jan Veselyf97de002016-05-13 20:39:29 +000052; EG: VTX_READ_32
53; EG: @struct_foo_gv
54; EG-NOT: MOVA_INT
Jan Vesely16800392016-05-13 20:39:31 +000055; EG-NOT: MOV
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000056define amdgpu_kernel void @struct_foo_gv_load(i32 addrspace(1)* %out, i32 %index) {
Yaxun Liu0124b542018-02-13 18:00:25 +000057 %gep = getelementptr inbounds [1 x %struct.foo], [1 x %struct.foo] addrspace(4)* @struct_foo_gv, i32 0, i32 0, i32 1, i32 %index
58 %load = load i32, i32 addrspace(4)* %gep, align 4
Matt Arsenault6a57fd82014-05-21 22:42:42 +000059 store i32 %load, i32 addrspace(1)* %out, align 4
60 ret void
61}
62
Yaxun Liu0124b542018-02-13 18:00:25 +000063@array_v1_gv = internal addrspace(4) constant [4 x <1 x i32>] [ <1 x i32> <i32 1>,
Matt Arsenault6a57fd82014-05-21 22:42:42 +000064 <1 x i32> <i32 2>,
65 <1 x i32> <i32 3>,
66 <1 x i32> <i32 4> ]
67
Tom Stellard79243d92014-10-01 17:15:17 +000068; FUNC-LABEL: {{^}}array_v1_gv_load:
Marek Olsak93df0602015-07-27 18:16:08 +000069; GCN: s_load_dword
Jan Veselyf97de002016-05-13 20:39:29 +000070
71; EG: VTX_READ_32
72; EG: @array_v1_gv
73; EG-NOT: MOVA_INT
Jan Vesely16800392016-05-13 20:39:31 +000074; EG-NOT: MOV
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000075define amdgpu_kernel void @array_v1_gv_load(<1 x i32> addrspace(1)* %out, i32 %index) {
Yaxun Liu0124b542018-02-13 18:00:25 +000076 %gep = getelementptr inbounds [4 x <1 x i32>], [4 x <1 x i32>] addrspace(4)* @array_v1_gv, i32 0, i32 %index
77 %load = load <1 x i32>, <1 x i32> addrspace(4)* %gep, align 4
Matt Arsenault6a57fd82014-05-21 22:42:42 +000078 store <1 x i32> %load, <1 x i32> addrspace(1)* %out, align 4
79 ret void
80}
Tom Stellardb02094e2014-07-21 15:45:01 +000081
Jan Veselyf97de002016-05-13 20:39:29 +000082; FUNC-LABEL: {{^}}gv_addressing_in_branch:
83
84; EG: VTX_READ_32
85; EG: @float_gv
86; EG-NOT: MOVA_INT
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000087define amdgpu_kernel void @gv_addressing_in_branch(float addrspace(1)* %out, i32 %index, i32 %a) {
Tom Stellardb02094e2014-07-21 15:45:01 +000088entry:
89 %0 = icmp eq i32 0, %a
90 br i1 %0, label %if, label %else
91
92if:
Yaxun Liu0124b542018-02-13 18:00:25 +000093 %1 = getelementptr inbounds [5 x float], [5 x float] addrspace(4)* @float_gv, i32 0, i32 %index
94 %2 = load float, float addrspace(4)* %1
Tom Stellardb02094e2014-07-21 15:45:01 +000095 store float %2, float addrspace(1)* %out
96 br label %endif
97
98else:
99 store float 1.0, float addrspace(1)* %out
100 br label %endif
101
102endif:
103 ret void
104}