1; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s 2 3; Test that materialization constants that are the bit reversed of 4; inline immediates are replaced with bfrev of the inline immediate to 5; save code size. 6 7; GCN-LABEL: {{^}}materialize_0_i32: 8; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 0{{$}} 9; GCN: buffer_store_dword [[K]] 10define amdgpu_kernel void @materialize_0_i32(i32 addrspace(1)* %out) { 11 store i32 0, i32 addrspace(1)* %out 12 ret void 13} 14 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]]{{\]}} 19define amdgpu_kernel void @materialize_0_i64(i64 addrspace(1)* %out) { 20 store i64 0, i64 addrspace(1)* %out 21 ret void 22} 23 24; GCN-LABEL: {{^}}materialize_neg1_i32: 25; GCN: v_mov_b32_e32 [[K:v[0-9]+]], -1{{$}} 26; GCN: buffer_store_dword [[K]] 27define amdgpu_kernel void @materialize_neg1_i32(i32 addrspace(1)* %out) { 28 store i32 -1, i32 addrspace(1)* %out 29 ret void 30} 31 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]]{{\]}} 36define amdgpu_kernel void @materialize_neg1_i64(i64 addrspace(1)* %out) { 37 store i64 -1, i64 addrspace(1)* %out 38 ret void 39} 40 41; GCN-LABEL: {{^}}materialize_signbit_i32: 42; GCN: v_bfrev_b32_e32 [[K:v[0-9]+]], 1{{$}} 43; GCN: buffer_store_dword [[K]] 44define amdgpu_kernel void @materialize_signbit_i32(i32 addrspace(1)* %out) { 45 store i32 -2147483648, i32 addrspace(1)* %out 46 ret void 47} 48 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]]{{\]}} 53define amdgpu_kernel void @materialize_signbit_i64(i64 addrspace(1)* %out) { 54 store i64 -9223372036854775808, i64 addrspace(1)* %out 55 ret void 56} 57 58; GCN-LABEL: {{^}}materialize_rev_neg16_i32: 59; GCN: v_bfrev_b32_e32 [[K:v[0-9]+]], -16{{$}} 60; GCN: buffer_store_dword [[K]] 61define amdgpu_kernel void @materialize_rev_neg16_i32(i32 addrspace(1)* %out) { 62 store i32 268435455, i32 addrspace(1)* %out 63 ret void 64} 65 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]]{{\]}} 70define amdgpu_kernel void @materialize_rev_neg16_i64(i64 addrspace(1)* %out) { 71 store i64 1152921504606846975, i64 addrspace(1)* %out 72 ret void 73} 74 75; GCN-LABEL: {{^}}materialize_rev_neg17_i32: 76; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 0xf7ffffff{{$}} 77; GCN: buffer_store_dword [[K]] 78define amdgpu_kernel void @materialize_rev_neg17_i32(i32 addrspace(1)* %out) { 79 store i32 -134217729, i32 addrspace(1)* %out 80 ret void 81} 82 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]]{{\]}} 87define amdgpu_kernel void @materialize_rev_neg17_i64(i64 addrspace(1)* %out) { 88 store i64 -576460752303423489, i64 addrspace(1)* %out 89 ret void 90} 91 92; GCN-LABEL: {{^}}materialize_rev_64_i32: 93; GCN: v_bfrev_b32_e32 [[K:v[0-9]+]], 64{{$}} 94; GCN: buffer_store_dword [[K]] 95define amdgpu_kernel void @materialize_rev_64_i32(i32 addrspace(1)* %out) { 96 store i32 33554432, i32 addrspace(1)* %out 97 ret void 98} 99 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]]{{\]}} 104define amdgpu_kernel void @materialize_rev_64_i64(i64 addrspace(1)* %out) { 105 store i64 144115188075855872, i64 addrspace(1)* %out 106 ret void 107} 108 109; GCN-LABEL: {{^}}materialize_rev_65_i32: 110; GCN: v_mov_b32_e32 [[K:v[0-9]+]], 0x82000000{{$}} 111; GCN: buffer_store_dword [[K]] 112define amdgpu_kernel void @materialize_rev_65_i32(i32 addrspace(1)* %out) { 113 store i32 -2113929216, i32 addrspace(1)* %out 114 ret void 115} 116 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]]{{\]}} 121define amdgpu_kernel void @materialize_rev_65_i64(i64 addrspace(1)* %out) { 122 store i64 -9079256848778919936, i64 addrspace(1)* %out 123 ret void 124} 125 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]] 129define amdgpu_kernel void @materialize_rev_3_i32(i32 addrspace(1)* %out) { 130 store i32 -1073741824, i32 addrspace(1)* %out 131 ret void 132} 133 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]]{{\]}} 138define amdgpu_kernel void @materialize_rev_3_i64(i64 addrspace(1)* %out) { 139 store i64 -4611686018427387904, i64 addrspace(1)* %out 140 ret void 141} 142 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]] 146define amdgpu_kernel void @materialize_rev_1.0_i32(i32 addrspace(1)* %out) { 147 store i32 508, i32 addrspace(1)* %out 148 ret void 149} 150 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]]{{\]}} 155define amdgpu_kernel void @materialize_rev_1.0_i64(i64 addrspace(1)* %out) { 156 store i64 508, i64 addrspace(1)* %out 157 ret void 158} 159 160; GCN-LABEL: {{^}}s_materialize_0_i32: 161; GCN: s_mov_b32 s{{[0-9]+}}, 0{{$}} 162define amdgpu_kernel void @s_materialize_0_i32() { 163 call void asm sideeffect "; use $0", "s"(i32 0) 164 ret void 165} 166 167; GCN-LABEL: {{^}}s_materialize_1_i32: 168; GCN: s_mov_b32 s{{[0-9]+}}, 1{{$}} 169define amdgpu_kernel void @s_materialize_1_i32() { 170 call void asm sideeffect "; use $0", "s"(i32 1) 171 ret void 172} 173 174; GCN-LABEL: {{^}}s_materialize_neg1_i32: 175; GCN: s_mov_b32 s{{[0-9]+}}, -1{{$}} 176define amdgpu_kernel void @s_materialize_neg1_i32() { 177 call void asm sideeffect "; use $0", "s"(i32 -1) 178 ret void 179} 180 181; GCN-LABEL: {{^}}s_materialize_signbit_i32: 182; GCN: s_brev_b32 s{{[0-9]+}}, 1{{$}} 183define amdgpu_kernel void @s_materialize_signbit_i32() { 184 call void asm sideeffect "; use $0", "s"(i32 -2147483648) 185 ret void 186} 187 188; GCN-LABEL: {{^}}s_materialize_rev_64_i32: 189; GCN: s_brev_b32 s{{[0-9]+}}, 64{{$}} 190define amdgpu_kernel void @s_materialize_rev_64_i32() { 191 call void asm sideeffect "; use $0", "s"(i32 33554432) 192 ret void 193} 194 195; GCN-LABEL: {{^}}s_materialize_rev_65_i32: 196; GCN: s_mov_b32 s{{[0-9]+}}, 0x82000000{{$}} 197define amdgpu_kernel void @s_materialize_rev_65_i32() { 198 call void asm sideeffect "; use $0", "s"(i32 -2113929216) 199 ret void 200} 201 202; GCN-LABEL: {{^}}s_materialize_rev_neg16_i32: 203; GCN: s_brev_b32 s{{[0-9]+}}, -16{{$}} 204define amdgpu_kernel void @s_materialize_rev_neg16_i32() { 205 call void asm sideeffect "; use $0", "s"(i32 268435455) 206 ret void 207} 208 209; GCN-LABEL: {{^}}s_materialize_rev_neg17_i32: 210; GCN: s_mov_b32 s{{[0-9]+}}, 0xf7ffffff{{$}} 211define amdgpu_kernel void @s_materialize_rev_neg17_i32() { 212 call void asm sideeffect "; use $0", "s"(i32 -134217729) 213 ret void 214} 215 216; GCN-LABEL: {{^}}s_materialize_rev_1.0_i32: 217; GCN: s_movk_i32 s{{[0-9]+}}, 0x1fc{{$}} 218define amdgpu_kernel void @s_materialize_rev_1.0_i32() { 219 call void asm sideeffect "; use $0", "s"(i32 508) 220 ret void 221} 222