1 ; RUN: llc -march=amdgcn -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI %s
3 declare i32 @llvm.r600.read.tidig.x() nounwind readnone
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
13 ; SI-LABEL: {{^}}sint_to_fp_i1_f64:
14 ; SI: v_cmp_eq_i32_e64 [[CMP:s\[[0-9]+:[0-9]\]]],
15 ; We can't fold the SGPRs into v_cndmask_b32_e64, because it already
16 ; uses an SGPR for [[CMP]]
17 ; SI: v_cndmask_b32_e64 v{{[0-9]+}}, 0, v{{[0-9]+}}, [[CMP]]
18 ; SI: v_cndmask_b32_e64 v{{[0-9]+}}, 0, v{{[0-9]+}}, [[CMP]]
19 ; SI: buffer_store_dwordx2
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
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]]
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
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
46 ; SI-LABEL: @v_sint_to_fp_i64_to_f64
47 ; SI: buffer_load_dwordx2 v{{\[}}[[LO:[0-9]+]]:[[HI:[0-9]+]]{{\]}}
48 ; SI: v_cvt_f64_i32_e32 [[HI_CONV:v\[[0-9]+:[0-9]+\]]], v[[HI]]
49 ; SI: v_ldexp_f64 [[LDEXP:v\[[0-9]+:[0-9]+\]]], [[HI_CONV]], 32
50 ; SI: v_cvt_f64_u32_e32 [[LO_CONV:v\[[0-9]+:[0-9]+\]]], v[[LO]]
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