blob: 3763237100cc3ad1ea903b171586d8ea55b74bed [file] [log] [blame]
Tom Stellard49f8bfd2015-01-06 18:00:21 +00001; RUN: llc -march=amdgcn -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=FUNC -check-prefix=SI %s
Matt Arsenaultc10853f2014-08-06 00:29:43 +00002
3
4declare i32 @llvm.r600.read.tidig.x() #1
5
6; FIXME: This currently doesn't do a great job of clustering the
7; loads, which end up with extra moves between them. Right now, it
8; seems the only things areLoadsFromSameBasePtr is accomplishing is
9; ordering the loads so that the lower address loads come first.
10
Tom Stellard79243d92014-10-01 17:15:17 +000011; FUNC-LABEL: {{^}}cluster_global_arg_loads:
Tom Stellard326d6ec2014-11-05 14:50:53 +000012; SI-DAG: buffer_load_dword [[REG0:v[0-9]+]], s{{\[[0-9]+:[0-9]+\]}}, 0{{$}}
Matt Arsenaultfb13b222014-12-03 03:12:13 +000013; SI-DAG: buffer_load_dword [[REG1:v[0-9]+]], s{{\[[0-9]+:[0-9]+\]}}, 0 offset:4
Tom Stellard326d6ec2014-11-05 14:50:53 +000014; SI: buffer_store_dword [[REG0]]
15; SI: buffer_store_dword [[REG1]]
Matt Arsenaultc10853f2014-08-06 00:29:43 +000016define void @cluster_global_arg_loads(i32 addrspace(1)* %out0, i32 addrspace(1)* %out1, i32 addrspace(1)* %ptr) #0 {
17 %load0 = load i32 addrspace(1)* %ptr, align 4
David Blaikie79e6c742015-02-27 19:29:02 +000018 %gep = getelementptr i32, i32 addrspace(1)* %ptr, i32 1
Matt Arsenaultc10853f2014-08-06 00:29:43 +000019 %load1 = load i32 addrspace(1)* %gep, align 4
20 store i32 %load0, i32 addrspace(1)* %out0, align 4
21 store i32 %load1, i32 addrspace(1)* %out1, align 4
22 ret void
23}
24
Tom Stellard155bbb72014-08-11 22:18:17 +000025; Test for a crach in SIInstrInfo::areLoadsFromSameBasePtr() when checking
26; an MUBUF load which does not have a vaddr operand.
Tom Stellard79243d92014-10-01 17:15:17 +000027; FUNC-LABEL: {{^}}same_base_ptr_crash:
Tom Stellard326d6ec2014-11-05 14:50:53 +000028; SI: buffer_load_dword
29; SI: buffer_load_dword
Tom Stellard155bbb72014-08-11 22:18:17 +000030define void @same_base_ptr_crash(i32 addrspace(1)* %out, i32 addrspace(1)* %in, i32 %offset) {
31entry:
David Blaikie79e6c742015-02-27 19:29:02 +000032 %out1 = getelementptr i32, i32 addrspace(1)* %out, i32 %offset
Tom Stellard155bbb72014-08-11 22:18:17 +000033 %tmp0 = load i32 addrspace(1)* %out
34 %tmp1 = load i32 addrspace(1)* %out1
35 %tmp2 = add i32 %tmp0, %tmp1
36 store i32 %tmp2, i32 addrspace(1)* %out
37 ret void
38}
39
Matt Arsenaultc10853f2014-08-06 00:29:43 +000040attributes #0 = { nounwind }
41attributes #1 = { nounwind readnone }