4d866eb86fdaefc1ac1d73a5f645fe5f3f03a4b2
[oota-llvm.git] / test / CodeGen / R600 / sint_to_fp.f64.ll
1 ; RUN: llc -march=amdgcn -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI %s
2
3 declare i32 @llvm.r600.read.tidig.x() nounwind readnone
4
5 ; SI-LABEL: {{^}}sint_to_fp_i32_to_f64
6 ; SI: v_cvt_f64_i32_e32
7 define void @sint_to_fp_i32_to_f64(double addrspace(1)* %out, i32 %in) {
8   %result = sitofp i32 %in to double
9   store double %result, double addrspace(1)* %out
10   ret void
11 }
12
13 ; SI-LABEL: {{^}}sint_to_fp_i1_f64:
14 ; SI: v_cmp_eq_i32_e64 [[CMP:s\[[0-9]+:[0-9]\]]],
15 ; FIXME: We should the VGPR sources for V_CNDMASK are copied from SGPRs,
16 ; we should be able to fold the SGPRs into the V_CNDMASK instructions.
17 ; SI: v_cndmask_b32_e64 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}, [[CMP]]
18 ; SI: v_cndmask_b32_e64 v{{[0-9]+}}, v{{[0-9]+}}, v{{[0-9]+}}, [[CMP]]
19 ; SI: buffer_store_dwordx2
20 ; SI: s_endpgm
21 define void @sint_to_fp_i1_f64(double addrspace(1)* %out, i32 %in) {
22   %cmp = icmp eq i32 %in, 0
23   %fp = sitofp i1 %cmp to double
24   store double %fp, double addrspace(1)* %out, align 4
25   ret void
26 }
27
28 ; SI-LABEL: {{^}}sint_to_fp_i1_f64_load:
29 ; SI: v_cndmask_b32_e64 [[IRESULT:v[0-9]]], 0, -1
30 ; SI-NEXT: v_cvt_f64_i32_e32 [[RESULT:v\[[0-9]+:[0-9]\]]], [[IRESULT]]
31 ; SI: buffer_store_dwordx2 [[RESULT]]
32 ; SI: s_endpgm
33 define void @sint_to_fp_i1_f64_load(double addrspace(1)* %out, i1 %in) {
34   %fp = sitofp i1 %in to double
35   store double %fp, double addrspace(1)* %out, align 8
36   ret void
37 }
38
39 ; SI-LABEL: @s_sint_to_fp_i64_to_f64
40 define void @s_sint_to_fp_i64_to_f64(double addrspace(1)* %out, i64 %in) {
41   %result = sitofp i64 %in to double
42   store double %result, double addrspace(1)* %out
43   ret void
44 }
45
46 ; SI-LABEL: @v_sint_to_fp_i64_to_f64
47 ; SI: buffer_load_dwordx2 v{{\[}}[[LO:[0-9]+]]:[[HI:[0-9]+]]{{\]}}
48 ; SI-DAG: v_cvt_f64_u32_e32 [[LO_CONV:v\[[0-9]+:[0-9]+\]]], v[[LO]]
49 ; SI-DAG: v_cvt_f64_i32_e32 [[HI_CONV:v\[[0-9]+:[0-9]+\]]], v[[HI]]
50 ; SI: v_ldexp_f64 [[LDEXP:v\[[0-9]+:[0-9]+\]]], [[HI_CONV]], 32
51 ; SI: v_add_f64 [[RESULT:v\[[0-9]+:[0-9]+\]]], [[LDEXP]], [[LO_CONV]]
52 ; SI: buffer_store_dwordx2 [[RESULT]]
53 define void @v_sint_to_fp_i64_to_f64(double addrspace(1)* %out, i64 addrspace(1)* %in) {
54   %tid = call i32 @llvm.r600.read.tidig.x() nounwind readnone
55   %gep = getelementptr i64 addrspace(1)* %in, i32 %tid
56   %val = load i64 addrspace(1)* %gep, align 8
57   %result = sitofp i64 %val to double
58   store double %result, double addrspace(1)* %out
59   ret void
60 }