blob: 44d46086f02af4b59bfe27b3b1558ff48aec1f86 [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
Matt Arsenaultc10853f2014-08-06 00:29:43 +00003; FIXME: This currently doesn't do a great job of clustering the
4; loads, which end up with extra moves between them. Right now, it
5; seems the only things areLoadsFromSameBasePtr is accomplishing is
6; ordering the loads so that the lower address loads come first.
7
Tom Stellard79243d92014-10-01 17:15:17 +00008; FUNC-LABEL: {{^}}cluster_global_arg_loads:
Nikolay Haustov4f672a32016-04-29 09:02:30 +00009; SI-DAG: buffer_load_dword [[REG0:v[0-9]+]], off, s{{\[[0-9]+:[0-9]+\]}}, 0{{$}}
Matt Arsenault4578d6a2016-05-25 17:42:39 +000010; 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 +000011; SI: buffer_store_dword [[REG0]]
12; SI: buffer_store_dword [[REG1]]
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000013define amdgpu_kernel 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 +000014 %load0 = load i32, i32 addrspace(1)* %ptr, align 4
Matt Arsenault4578d6a2016-05-25 17:42:39 +000015 %gep = getelementptr i32, i32 addrspace(1)* %ptr, i32 2
David Blaikiea79ac142015-02-27 21:17:42 +000016 %load1 = load i32, i32 addrspace(1)* %gep, align 4
Matt Arsenaultc10853f2014-08-06 00:29:43 +000017 store i32 %load0, i32 addrspace(1)* %out0, align 4
18 store i32 %load1, i32 addrspace(1)* %out1, align 4
19 ret void
20}
21
Tom Stellard155bbb72014-08-11 22:18:17 +000022; Test for a crach in SIInstrInfo::areLoadsFromSameBasePtr() when checking
23; an MUBUF load which does not have a vaddr operand.
Tom Stellard79243d92014-10-01 17:15:17 +000024; FUNC-LABEL: {{^}}same_base_ptr_crash:
Tom Stellard326d6ec2014-11-05 14:50:53 +000025; SI: buffer_load_dword
26; SI: buffer_load_dword
Matt Arsenault3dbeefa2017-03-21 21:39:51 +000027define amdgpu_kernel void @same_base_ptr_crash(i32 addrspace(1)* %out, i32 addrspace(1)* %in, i32 %offset) {
Tom Stellard155bbb72014-08-11 22:18:17 +000028entry:
David Blaikie79e6c742015-02-27 19:29:02 +000029 %out1 = getelementptr i32, i32 addrspace(1)* %out, i32 %offset
David Blaikiea79ac142015-02-27 21:17:42 +000030 %tmp0 = load i32, i32 addrspace(1)* %out
31 %tmp1 = load i32, i32 addrspace(1)* %out1
Tom Stellard155bbb72014-08-11 22:18:17 +000032 %tmp2 = add i32 %tmp0, %tmp1
33 store i32 %tmp2, i32 addrspace(1)* %out
34 ret void
35}
36
Matt Arsenaultc10853f2014-08-06 00:29:43 +000037attributes #0 = { nounwind }
38attributes #1 = { nounwind readnone }