blob: 6b70c931feb337685da3cbb79b00b3c34413b4e3 [file] [log] [blame]
Matt Arsenaultf43c2a02016-03-23 21:49:25 +00001; RUN: llc -march=amdgcn -mattr=-promote-alloca -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
2
3; GCN-LABEL: {{^}}stored_fi_to_lds:
4; GCN: s_load_dword [[LDSPTR:s[0-9]+]]
5; GCN: v_mov_b32_e32 [[ZERO0:v[0-9]+]], 0{{$}}
6; GCN: v_mov_b32_e32 [[ZERO1:v[0-9]+]], 0{{$}}
7; GCN: buffer_store_dword v{{[0-9]+}}, [[ZERO1]]
8
9; GCN: v_mov_b32_e32 [[VLDSPTR:v[0-9]+]], [[LDSPTR]]
10
11; GCN: ds_write_b32 [[VLDSPTR]], [[ZERO0]]
12define void @stored_fi_to_lds(float* addrspace(3)* %ptr) #0 {
13 %tmp = alloca float
14 store float 4.0, float *%tmp
15 store float* %tmp, float* addrspace(3)* %ptr
16 ret void
17}
18
19; Offset is applied
20; GCN-LABEL: {{^}}stored_fi_to_lds_2_small_objects:
21; GCN: s_load_dword [[LDSPTR:s[0-9]+]]
22; GCN: v_mov_b32_e32 [[ZERO0:v[0-9]+]], 0{{$}}
23; GCN: v_mov_b32_e32 [[ZERO1:v[0-9]+]], 0{{$}}
24; GCN: buffer_store_dword v{{[0-9]+}}, [[ZERO1]]
25
26; GCN: v_mov_b32_e32 [[FI1:v[0-9]+]], 4{{$}}
27; GCN: buffer_store_dword v{{[0-9]+}}, [[FI1]]
28
29
30; GCN-DAG: v_mov_b32_e32 [[VLDSPTR:v[0-9]+]], [[LDSPTR]]
31; GCN: ds_write_b32 [[VLDSPTR]], [[ZERO0]]
32
33; GCN-DAG: v_mov_b32_e32 [[FI1:v[0-9]+]], 4{{$}}
34; GCN: ds_write_b32 [[VLDSPTR]], [[FI1]]
35define void @stored_fi_to_lds_2_small_objects(float* addrspace(3)* %ptr) #0 {
36 %tmp0 = alloca float
37 %tmp1 = alloca float
38 store float 4.0, float *%tmp0
39 store float 4.0, float *%tmp1
40 store volatile float* %tmp0, float* addrspace(3)* %ptr
41 store volatile float* %tmp1, float* addrspace(3)* %ptr
42 ret void
43}
44
45; Same frame index is used multiple times in the store
46; GCN-LABEL: {{^}}stored_fi_to_self:
47define void @stored_fi_to_self() #0 {
48 %tmp = alloca i32*
49
50 ; Avoid optimizing everything out
51 store volatile i32* inttoptr (i32 1234 to i32*), i32** %tmp
52 %bitcast = bitcast i32** %tmp to i32*
53 store volatile i32* %bitcast, i32** %tmp
54 ret void
55}
56
57; GCN-LABEL: {{^}}stored_fi_to_fi:
58; GCN: buffer_store_dword
59; GCN: buffer_store_dword
60; GCN: buffer_store_dword
61
62; GCN-DAG: v_mov_b32_e32 [[FI1:v[0-9]+]], 4{{$}}
63; GCN-DAG: v_mov_b32_e32 [[FI2:v[0-9]+]], 8{{$}}
64; GCN: buffer_store_dword [[FI1]], [[FI2]]
65
66; GCN-DAG: v_mov_b32_e32 [[FI1:v[0-9]+]], 4{{$}}
67; GCN-DAG: v_mov_b32_e32 [[FI2:v[0-9]+]], 8{{$}}
68; GCN: buffer_store_dword [[FI2]], [[FI1]]
69define void @stored_fi_to_fi() #0 {
70 %tmp0 = alloca i32*
71 %tmp1 = alloca i32*
72 %tmp2 = alloca i32*
73 store volatile i32* inttoptr (i32 1234 to i32*), i32** %tmp0
74 store volatile i32* inttoptr (i32 5678 to i32*), i32** %tmp1
75 store volatile i32* inttoptr (i32 9999 to i32*), i32** %tmp2
76
77 %bitcast1 = bitcast i32** %tmp1 to i32*
78 %bitcast2 = bitcast i32** %tmp2 to i32* ; at offset 8
79
80 store volatile i32* %bitcast1, i32** %tmp2 ; store offset 4 at offset 8
81 store volatile i32* %bitcast2, i32** %tmp1 ; store offset 8 at offset 4
82 ret void
83}
84
85; GCN-LABEL: {{^}}stored_fi_to_global:
86; GCN: buffer_store_dword v{{[0-9]+}}, v{{[0-9]+}}, s{{\[[0-9]+:[0-9]+\]}}, s{{[0-9]+}} offen
87; GCN: v_mov_b32_e32 [[FI:v[0-9]+]], 0{{$}}
88; GCN: buffer_store_dword [[FI]]
89define void @stored_fi_to_global(float* addrspace(1)* %ptr) #0 {
90 %tmp = alloca float
91 store float 0.0, float *%tmp
92 store float* %tmp, float* addrspace(1)* %ptr
93 ret void
94}
95
96; Offset is applied
97; GCN-LABEL: {{^}}stored_fi_to_global_2_small_objects:
98; GCN: buffer_store_dword v{{[0-9]+}}, v{{[0-9]+}}, s{{\[[0-9]+:[0-9]+\]}}, s{{[0-9]+}} offen
99; GCN: buffer_store_dword v{{[0-9]+}}, v{{[0-9]+}}, s{{\[[0-9]+:[0-9]+\]}}, s{{[0-9]+}} offen
100; GCN: buffer_store_dword v{{[0-9]+}}, v{{[0-9]+}}, s{{\[[0-9]+:[0-9]+\]}}, s{{[0-9]+}} offen
101
102; GCN: v_mov_b32_e32 [[FI1:v[0-9]+]], 4{{$}}
103; GCN: buffer_store_dword [[FI1]], s{{\[[0-9]+:[0-9]+\]}}, 0{{$}}
104
105; GCN-DAG: v_mov_b32_e32 [[FI2:v[0-9]+]], 8{{$}}
106; GCN: buffer_store_dword [[FI2]], s{{\[[0-9]+:[0-9]+\]}}, 0{{$}}
107define void @stored_fi_to_global_2_small_objects(float* addrspace(1)* %ptr) #0 {
108 %tmp0 = alloca float
109 %tmp1 = alloca float
110 %tmp2 = alloca float
111 store volatile float 0.0, float *%tmp0
112 store volatile float 0.0, float *%tmp1
113 store volatile float 0.0, float *%tmp2
114 store volatile float* %tmp1, float* addrspace(1)* %ptr
115 store volatile float* %tmp2, float* addrspace(1)* %ptr
116 ret void
117}
118
119attributes #0 = { nounwind }