blob: 1bf109dec0323f1d98eff540af4fdf230afdf714 [file] [log] [blame]
Matt Arsenault9c47dd52016-02-11 06:02:01 +00001; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=FUNC -check-prefix=SI %s
Matt Arsenaultc10853f2014-08-06 00:29:43 +00002
3
Matt Arsenaultc10853f2014-08-06 00:29:43 +00004; FIXME: This currently doesn't do a great job of clustering the
5; loads, which end up with extra moves between them. Right now, it
6; seems the only things areLoadsFromSameBasePtr is accomplishing is
7; ordering the loads so that the lower address loads come first.
8
Tom Stellard79243d92014-10-01 17:15:17 +00009; FUNC-LABEL: {{^}}cluster_global_arg_loads:
Nikolay Haustov4f672a32016-04-29 09:02:30 +000010; SI-DAG: buffer_load_dword [[REG0:v[0-9]+]], off, s{{\[[0-9]+:[0-9]+\]}}, 0{{$}}
Matt Arsenault4578d6a2016-05-25 17:42:39 +000011; SI-DAG: buffer_load_dword [[REG1:v[0-9]+]], off, s{{\[[0-9]+:[0-9]+\]}}, 0 offset:8
Tom Stellard326d6ec2014-11-05 14:50:53 +000012; SI: buffer_store_dword [[REG0]]
13; SI: buffer_store_dword [[REG1]]
Matt Arsenaultc10853f2014-08-06 00:29:43 +000014define void @cluster_global_arg_loads(i32 addrspace(1)* %out0, i32 addrspace(1)* %out1, i32 addrspace(1)* %ptr) #0 {
David Blaikiea79ac142015-02-27 21:17:42 +000015 %load0 = load i32, i32 addrspace(1)* %ptr, align 4
Matt Arsenault4578d6a2016-05-25 17:42:39 +000016 %gep = getelementptr i32, i32 addrspace(1)* %ptr, i32 2
David Blaikiea79ac142015-02-27 21:17:42 +000017 %load1 = load i32, i32 addrspace(1)* %gep, align 4
Matt Arsenaultc10853f2014-08-06 00:29:43 +000018 store i32 %load0, i32 addrspace(1)* %out0, align 4
19 store i32 %load1, i32 addrspace(1)* %out1, align 4
20 ret void
21}
22
Tom Stellard155bbb72014-08-11 22:18:17 +000023; Test for a crach in SIInstrInfo::areLoadsFromSameBasePtr() when checking
24; an MUBUF load which does not have a vaddr operand.
Tom Stellard79243d92014-10-01 17:15:17 +000025; FUNC-LABEL: {{^}}same_base_ptr_crash:
Tom Stellard326d6ec2014-11-05 14:50:53 +000026; SI: buffer_load_dword
27; SI: buffer_load_dword
Tom Stellard155bbb72014-08-11 22:18:17 +000028define void @same_base_ptr_crash(i32 addrspace(1)* %out, i32 addrspace(1)* %in, i32 %offset) {
29entry:
David Blaikie79e6c742015-02-27 19:29:02 +000030 %out1 = getelementptr i32, i32 addrspace(1)* %out, i32 %offset
David Blaikiea79ac142015-02-27 21:17:42 +000031 %tmp0 = load i32, i32 addrspace(1)* %out
32 %tmp1 = load i32, i32 addrspace(1)* %out1
Tom Stellard155bbb72014-08-11 22:18:17 +000033 %tmp2 = add i32 %tmp0, %tmp1
34 store i32 %tmp2, i32 addrspace(1)* %out
35 ret void
36}
37
Matt Arsenaultc10853f2014-08-06 00:29:43 +000038attributes #0 = { nounwind }
39attributes #1 = { nounwind readnone }