1 ; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s
3 ; Test that materialization constants that are the bit reversed of
4 ; inline immediates are replaced with bfrev of the inline immediate to
7 ; GCN-LABEL: {{^}}materialize_0_i32:
8 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 0{{$}}
9 ; GCN: buffer_store_dword [[K]]
10 define amdgpu_kernel void @materialize_0_i32(i32 addrspace(1)* %out) {
11 store i32 0, i32 addrspace(1)* %out
15 ; GCN-LABEL: {{^}}materialize_0_i64:
16 ; GCN: v_mov_b32_e32 v[[LOK:[0-9]+]], 0{{$}}
17 ; GCN: v_mov_b32_e32 v[[HIK:[0-9]+]], v[[LOK]]{{$}}
18 ; GCN: buffer_store_dwordx2 v{{\[}}[[LOK]]:[[HIK]]{{\]}}
19 define amdgpu_kernel void @materialize_0_i64(i64 addrspace(1)* %out) {
20 store i64 0, i64 addrspace(1)* %out
24 ; GCN-LABEL: {{^}}materialize_neg1_i32:
25 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], -1{{$}}
26 ; GCN: buffer_store_dword [[K]]
27 define amdgpu_kernel void @materialize_neg1_i32(i32 addrspace(1)* %out) {
28 store i32 -1, i32 addrspace(1)* %out
32 ; GCN-LABEL: {{^}}materialize_neg1_i64:
33 ; GCN: v_mov_b32_e32 v[[LOK:[0-9]+]], -1{{$}}
34 ; GCN: v_mov_b32_e32 v[[HIK:[0-9]+]], v[[LOK]]{{$}}
35 ; GCN: buffer_store_dwordx2 v{{\[}}[[LOK]]:[[HIK]]{{\]}}
36 define amdgpu_kernel void @materialize_neg1_i64(i64 addrspace(1)* %out) {
37 store i64 -1, i64 addrspace(1)* %out
41 ; GCN-LABEL: {{^}}materialize_signbit_i32:
42 ; GCN: v_bfrev_b32_e32 [[K:v[0-9]+]], 1{{$}}
43 ; GCN: buffer_store_dword [[K]]
44 define amdgpu_kernel void @materialize_signbit_i32(i32 addrspace(1)* %out) {
45 store i32 -2147483648, i32 addrspace(1)* %out
49 ; GCN-LABEL: {{^}}materialize_signbit_i64:
50 ; GCN-DAG: v_mov_b32_e32 v[[LOK:[0-9]+]], 0{{$}}
51 ; GCN-DAG: v_bfrev_b32_e32 v[[HIK:[0-9]+]], 1{{$}}
52 ; GCN: buffer_store_dwordx2 v{{\[}}[[LOK]]:[[HIK]]{{\]}}
53 define amdgpu_kernel void @materialize_signbit_i64(i64 addrspace(1)* %out) {
54 store i64 -9223372036854775808, i64 addrspace(1)* %out
58 ; GCN-LABEL: {{^}}materialize_rev_neg16_i32:
59 ; GCN: v_bfrev_b32_e32 [[K:v[0-9]+]], -16{{$}}
60 ; GCN: buffer_store_dword [[K]]
61 define amdgpu_kernel void @materialize_rev_neg16_i32(i32 addrspace(1)* %out) {
62 store i32 268435455, i32 addrspace(1)* %out
66 ; GCN-LABEL: {{^}}materialize_rev_neg16_i64:
67 ; GCN-DAG: v_mov_b32_e32 v[[LOK:[0-9]+]], -1{{$}}
68 ; GCN-DAG: v_bfrev_b32_e32 v[[HIK:[0-9]+]], -16{{$}}
69 ; GCN: buffer_store_dwordx2 v{{\[}}[[LOK]]:[[HIK]]{{\]}}
70 define amdgpu_kernel void @materialize_rev_neg16_i64(i64 addrspace(1)* %out) {
71 store i64 1152921504606846975, i64 addrspace(1)* %out
75 ; GCN-LABEL: {{^}}materialize_rev_neg17_i32:
76 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 0xf7ffffff{{$}}
77 ; GCN: buffer_store_dword [[K]]
78 define amdgpu_kernel void @materialize_rev_neg17_i32(i32 addrspace(1)* %out) {
79 store i32 -134217729, i32 addrspace(1)* %out
83 ; GCN-LABEL: {{^}}materialize_rev_neg17_i64:
84 ; GCN-DAG: v_mov_b32_e32 v[[LOK:[0-9]+]], -1{{$}}
85 ; GCN-DAG: v_mov_b32_e32 v[[HIK:[0-9]+]], 0xf7ffffff{{$}}
86 ; GCN: buffer_store_dwordx2 v{{\[}}[[LOK]]:[[HIK]]{{\]}}
87 define amdgpu_kernel void @materialize_rev_neg17_i64(i64 addrspace(1)* %out) {
88 store i64 -576460752303423489, i64 addrspace(1)* %out
92 ; GCN-LABEL: {{^}}materialize_rev_64_i32:
93 ; GCN: v_bfrev_b32_e32 [[K:v[0-9]+]], 64{{$}}
94 ; GCN: buffer_store_dword [[K]]
95 define amdgpu_kernel void @materialize_rev_64_i32(i32 addrspace(1)* %out) {
96 store i32 33554432, i32 addrspace(1)* %out
100 ; GCN-LABEL: {{^}}materialize_rev_64_i64:
101 ; GCN-DAG: v_mov_b32_e32 v[[LOK:[0-9]+]], 0{{$}}
102 ; GCN-DAG: v_bfrev_b32_e32 v[[HIK:[0-9]+]], 64{{$}}
103 ; GCN: buffer_store_dwordx2 v{{\[}}[[LOK]]:[[HIK]]{{\]}}
104 define amdgpu_kernel void @materialize_rev_64_i64(i64 addrspace(1)* %out) {
105 store i64 144115188075855872, i64 addrspace(1)* %out
109 ; GCN-LABEL: {{^}}materialize_rev_65_i32:
110 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 0x82000000{{$}}
111 ; GCN: buffer_store_dword [[K]]
112 define amdgpu_kernel void @materialize_rev_65_i32(i32 addrspace(1)* %out) {
113 store i32 -2113929216, i32 addrspace(1)* %out
117 ; GCN-LABEL: {{^}}materialize_rev_65_i64:
118 ; GCN-DAG: v_mov_b32_e32 v[[LOK:[0-9]+]], 0{{$}}
119 ; GCN-DAG: v_mov_b32_e32 v[[HIK:[0-9]+]], 0x82000000{{$}}
120 ; GCN: buffer_store_dwordx2 v{{\[}}[[LOK]]:[[HIK]]{{\]}}
121 define amdgpu_kernel void @materialize_rev_65_i64(i64 addrspace(1)* %out) {
122 store i64 -9079256848778919936, i64 addrspace(1)* %out
126 ; GCN-LABEL: {{^}}materialize_rev_3_i32:
127 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], -2.0{{$}}
128 ; GCN: buffer_store_dword [[K]]
129 define amdgpu_kernel void @materialize_rev_3_i32(i32 addrspace(1)* %out) {
130 store i32 -1073741824, i32 addrspace(1)* %out
134 ; GCN-LABEL: {{^}}materialize_rev_3_i64:
135 ; GCN-DAG: v_mov_b32_e32 v[[LOK:[0-9]+]], 0{{$}}
136 ; GCN-DAG: v_mov_b32_e32 v[[HIK:[0-9]+]], -2.0{{$}}
137 ; GCN: buffer_store_dwordx2 v{{\[}}[[LOK]]:[[HIK]]{{\]}}
138 define amdgpu_kernel void @materialize_rev_3_i64(i64 addrspace(1)* %out) {
139 store i64 -4611686018427387904, i64 addrspace(1)* %out
143 ; GCN-LABEL: {{^}}materialize_rev_1.0_i32:
144 ; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 0x1fc{{$}}
145 ; GCN: buffer_store_dword [[K]]
146 define amdgpu_kernel void @materialize_rev_1.0_i32(i32 addrspace(1)* %out) {
147 store i32 508, i32 addrspace(1)* %out
151 ; GCN-LABEL: {{^}}materialize_rev_1.0_i64:
152 ; GCN-DAG: v_mov_b32_e32 v[[LOK:[0-9]+]], 0x1fc{{$}}
153 ; GCN-DAG: v_mov_b32_e32 v[[HIK:[0-9]+]], 0{{$}}
154 ; GCN: buffer_store_dwordx2 v{{\[}}[[LOK]]:[[HIK]]{{\]}}
155 define amdgpu_kernel void @materialize_rev_1.0_i64(i64 addrspace(1)* %out) {
156 store i64 508, i64 addrspace(1)* %out
160 ; GCN-LABEL: {{^}}s_materialize_0_i32:
161 ; GCN: s_mov_b32 s{{[0-9]+}}, 0{{$}}
162 define amdgpu_kernel void @s_materialize_0_i32() {
163 call void asm sideeffect "; use $0", "s"(i32 0)
167 ; GCN-LABEL: {{^}}s_materialize_1_i32:
168 ; GCN: s_mov_b32 s{{[0-9]+}}, 1{{$}}
169 define amdgpu_kernel void @s_materialize_1_i32() {
170 call void asm sideeffect "; use $0", "s"(i32 1)
174 ; GCN-LABEL: {{^}}s_materialize_neg1_i32:
175 ; GCN: s_mov_b32 s{{[0-9]+}}, -1{{$}}
176 define amdgpu_kernel void @s_materialize_neg1_i32() {
177 call void asm sideeffect "; use $0", "s"(i32 -1)
181 ; GCN-LABEL: {{^}}s_materialize_signbit_i32:
182 ; GCN: s_brev_b32 s{{[0-9]+}}, 1{{$}}
183 define amdgpu_kernel void @s_materialize_signbit_i32() {
184 call void asm sideeffect "; use $0", "s"(i32 -2147483648)
188 ; GCN-LABEL: {{^}}s_materialize_rev_64_i32:
189 ; GCN: s_brev_b32 s{{[0-9]+}}, 64{{$}}
190 define amdgpu_kernel void @s_materialize_rev_64_i32() {
191 call void asm sideeffect "; use $0", "s"(i32 33554432)
195 ; GCN-LABEL: {{^}}s_materialize_rev_65_i32:
196 ; GCN: s_mov_b32 s{{[0-9]+}}, 0x82000000{{$}}
197 define amdgpu_kernel void @s_materialize_rev_65_i32() {
198 call void asm sideeffect "; use $0", "s"(i32 -2113929216)
202 ; GCN-LABEL: {{^}}s_materialize_rev_neg16_i32:
203 ; GCN: s_brev_b32 s{{[0-9]+}}, -16{{$}}
204 define amdgpu_kernel void @s_materialize_rev_neg16_i32() {
205 call void asm sideeffect "; use $0", "s"(i32 268435455)
209 ; GCN-LABEL: {{^}}s_materialize_rev_neg17_i32:
210 ; GCN: s_mov_b32 s{{[0-9]+}}, 0xf7ffffff{{$}}
211 define amdgpu_kernel void @s_materialize_rev_neg17_i32() {
212 call void asm sideeffect "; use $0", "s"(i32 -134217729)
216 ; GCN-LABEL: {{^}}s_materialize_rev_1.0_i32:
217 ; GCN: s_movk_i32 s{{[0-9]+}}, 0x1fc{{$}}
218 define amdgpu_kernel void @s_materialize_rev_1.0_i32() {
219 call void asm sideeffect "; use $0", "s"(i32 508)