fix typos; NFC
[oota-llvm.git] / test / CodeGen / R600 / trunc.ll
1 ; RUN: llc -march=amdgcn -mcpu=SI -verify-machineinstrs< %s | FileCheck -check-prefix=SI %s
2 ; RUN: llc -march=r600 -mcpu=cypress < %s | FileCheck -check-prefix=EG %s
3
4 define void @trunc_i64_to_i32_store(i32 addrspace(1)* %out, i64 %in) {
5 ; SI-LABEL: {{^}}trunc_i64_to_i32_store:
6 ; SI: s_load_dword [[SLOAD:s[0-9]+]], s[0:1], 0xb
7 ; SI: v_mov_b32_e32 [[VLOAD:v[0-9]+]], [[SLOAD]]
8 ; SI: buffer_store_dword [[VLOAD]]
9
10 ; EG-LABEL: {{^}}trunc_i64_to_i32_store:
11 ; EG: MEM_RAT_CACHELESS STORE_RAW T0.X, T1.X, 1
12 ; EG: LSHR
13 ; EG-NEXT: 2(
14
15   %result = trunc i64 %in to i32 store i32 %result, i32 addrspace(1)* %out, align 4
16   ret void
17 }
18
19 ; SI-LABEL: {{^}}trunc_load_shl_i64:
20 ; SI-DAG: s_load_dwordx2
21 ; SI-DAG: s_load_dword [[SREG:s[0-9]+]],
22 ; SI: s_lshl_b32 [[SHL:s[0-9]+]], [[SREG]], 2
23 ; SI: v_mov_b32_e32 [[VSHL:v[0-9]+]], [[SHL]]
24 ; SI: buffer_store_dword [[VSHL]],
25 define void @trunc_load_shl_i64(i32 addrspace(1)* %out, i64 %a) {
26   %b = shl i64 %a, 2
27   %result = trunc i64 %b to i32
28   store i32 %result, i32 addrspace(1)* %out, align 4
29   ret void
30 }
31
32 ; SI-LABEL: {{^}}trunc_shl_i64:
33 ; SI: s_load_dwordx2 s{{\[}}[[LO_SREG:[0-9]+]]:{{[0-9]+\]}}, s{{\[[0-9]+:[0-9]+\]}}, 0xd
34 ; SI: s_lshl_b64 s{{\[}}[[LO_SHL:[0-9]+]]:{{[0-9]+\]}}, s{{\[}}[[LO_SREG]]:{{[0-9]+\]}}, 2
35 ; SI: s_add_u32 s[[LO_SREG2:[0-9]+]], s[[LO_SHL]],
36 ; SI: s_addc_u32
37 ; SI: v_mov_b32_e32 v[[LO_VREG:[0-9]+]], s[[LO_SREG2]]
38 ; SI: buffer_store_dword v[[LO_VREG]],
39 define void @trunc_shl_i64(i64 addrspace(1)* %out2, i32 addrspace(1)* %out, i64 %a) {
40   %aa = add i64 %a, 234 ; Prevent shrinking store.
41   %b = shl i64 %aa, 2
42   %result = trunc i64 %b to i32
43   store i32 %result, i32 addrspace(1)* %out, align 4
44   store i64 %b, i64 addrspace(1)* %out2, align 8 ; Prevent reducing ops to 32-bits
45   ret void
46 }
47
48 ; SI-LABEL: {{^}}trunc_i32_to_i1:
49 ; SI: v_and_b32_e32 v{{[0-9]+}}, 1, v{{[0-9]+}}
50 ; SI: v_cmp_eq_i32
51 define void @trunc_i32_to_i1(i32 addrspace(1)* %out, i32 addrspace(1)* %ptr) {
52   %a = load i32 addrspace(1)* %ptr, align 4
53   %trunc = trunc i32 %a to i1
54   %result = select i1 %trunc, i32 1, i32 0
55   store i32 %result, i32 addrspace(1)* %out, align 4
56   ret void
57 }
58
59 ; SI-LABEL: {{^}}sgpr_trunc_i32_to_i1:
60 ; SI: v_and_b32_e64 v{{[0-9]+}}, 1, s{{[0-9]+}}
61 ; SI: v_cmp_eq_i32
62 define void @sgpr_trunc_i32_to_i1(i32 addrspace(1)* %out, i32 %a) {
63   %trunc = trunc i32 %a to i1
64   %result = select i1 %trunc, i32 1, i32 0
65   store i32 %result, i32 addrspace(1)* %out, align 4
66   ret void
67 }