blob: 63909f0b094bc0bd1670648d9dd4df57fd6baa21 [file] [log] [blame]
Tom Stellard70f13db2013-10-10 17:11:46 +00001; RUN: llc < %s -march=r600 -mcpu=verde -verify-machineinstrs | FileCheck %s
Tom Stellardfd155822013-08-26 15:05:36 +00002
3; On Southern Islands GPUs the local address space(3) uses 32-bit pointers and
4; the global address space(1) uses 64-bit pointers. These tests check to make sure
5; the correct pointer size is used for the local address space.
6
7; The e{{32|64}} suffix on the instructions refers to the encoding size and not
8; the size of the operands. The operand size is denoted in the instruction name.
9; Instructions with B32, U32, and I32 in their name take 32-bit operands, while
10; instructions with B64, U64, and I64 take 64-bit operands.
11
12; CHECK-LABEL: @local_address_load
Matt Arsenault72b31ee2013-11-12 02:35:51 +000013; CHECK: V_MOV_B32_e{{32|64}} [[PTR:v[0-9]]]
Tom Stellardfd155822013-08-26 15:05:36 +000014; CHECK: DS_READ_B32 [[PTR]]
15define void @local_address_load(i32 addrspace(1)* %out, i32 addrspace(3)* %in) {
16entry:
17 %0 = load i32 addrspace(3)* %in
18 store i32 %0, i32 addrspace(1)* %out
19 ret void
20}
21
22; CHECK-LABEL: @local_address_gep
Matt Arsenault72b31ee2013-11-12 02:35:51 +000023; CHECK: V_ADD_I32_e{{32|64}} [[PTR:v[0-9]]]
Tom Stellardfd155822013-08-26 15:05:36 +000024; CHECK: DS_READ_B32 [[PTR]]
25define void @local_address_gep(i32 addrspace(1)* %out, i32 addrspace(3)* %in, i32 %offset) {
26entry:
27 %0 = getelementptr i32 addrspace(3)* %in, i32 %offset
28 %1 = load i32 addrspace(3)* %0
29 store i32 %1, i32 addrspace(1)* %out
30 ret void
31}
32
33; CHECK-LABEL: @local_address_gep_const_offset
Matt Arsenault72b31ee2013-11-12 02:35:51 +000034; CHECK: V_ADD_I32_e{{32|64}} [[PTR:v[0-9]]]
Tom Stellardfd155822013-08-26 15:05:36 +000035; CHECK: DS_READ_B32 [[PTR]]
36define void @local_address_gep_const_offset(i32 addrspace(1)* %out, i32 addrspace(3)* %in) {
37entry:
38 %0 = getelementptr i32 addrspace(3)* %in, i32 1
39 %1 = load i32 addrspace(3)* %0
40 store i32 %1, i32 addrspace(1)* %out
41 ret void
42}
Matt Arsenault19231e62013-11-16 20:24:41 +000043
44; CHECK-LABEL: @null_32bit_lds_ptr:
45; CHECK: V_CMP_NE_I32
46; CHECK-NOT: V_CMP_NE_I32
47; CHECK: V_CNDMASK_B32
48define void @null_32bit_lds_ptr(i32 addrspace(1)* %out, i32 addrspace(3)* %lds) nounwind {
49 %cmp = icmp ne i32 addrspace(3)* %lds, null
50 %x = select i1 %cmp, i32 123, i32 456
51 store i32 %x, i32 addrspace(1)* %out
52 ret void
Matt Arsenaultdfb3e702013-11-16 20:50:54 +000053}
54
55; CHECK-LABEL: @mul_32bit_ptr:
56; CHECK: V_MUL_LO_I32
57; CHECK-NEXT: V_ADD_I32_e32
58; CHECK-NEXT: DS_READ_B32
59define void @mul_32bit_ptr(float addrspace(1)* %out, [3 x float] addrspace(3)* %lds, i32 %tid) {
60 %ptr = getelementptr [3 x float] addrspace(3)* %lds, i32 %tid, i32 0
61 %val = load float addrspace(3)* %ptr
62 store float %val, float addrspace(1)* %out
63 ret void
64}
65
66@g_lds = addrspace(3) global float zeroinitializer, align 4
67
68; CHECK-LABEL: @infer_ptr_alignment_global_offset:
69; CHECK: V_MOV_B32_e32 [[REG:v[0-9]+]], 0
70; CHECK: DS_READ_B32 v{{[0-9]+}}, 0, [[REG]]
71define void @infer_ptr_alignment_global_offset(float addrspace(1)* %out, i32 %tid) {
72 %val = load float addrspace(3)* @g_lds
73 store float %val, float addrspace(1)* %out
74 ret void
75}
Matt Arsenault36f5eb52013-11-17 00:06:39 +000076
77
78@ptr = addrspace(3) global i32 addrspace(3)* null
79@dst = addrspace(3) global [16384 x i32] zeroinitializer
80
81; SI-LABEL: @global_ptr:
82; SI-CHECK: DS_WRITE_B32
83define void @global_ptr() nounwind {
84 store i32 addrspace(3)* getelementptr ([16384 x i32] addrspace(3)* @dst, i32 0, i32 16), i32 addrspace(3)* addrspace(3)* @ptr
85 ret void
86}