1 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=hawaii -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,SI %s
2 ; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=fiji -verify-machineinstrs < %s | FileCheck -enable-var-scope -check-prefixes=GCN,VI %s
4 declare i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
6 ; GCN-LABEL: {{^}}v_uint_to_fp_i64_to_f64
7 ; GCN: flat_load_dwordx2 v[[[LO:[0-9]+]]:[[HI:[0-9]+]]]
8 ; GCN-DAG: v_cvt_f64_u32_e32 [[HI_CONV:v\[[0-9]+:[0-9]+\]]], v[[HI]]
9 ; GCN-DAG: v_cvt_f64_u32_e32 [[LO_CONV:v\[[0-9]+:[0-9]+\]]], v[[LO]]
10 ; GCN-DAG: v_ldexp_f64 [[LDEXP:v\[[0-9]+:[0-9]+\]]], [[HI_CONV]], 32
11 ; GCN: v_add_f64 [[RESULT:v\[[0-9]+:[0-9]+\]]], [[LDEXP]], [[LO_CONV]]
12 ; GCN: flat_store_dwordx2 v{{\[[0-9]+:[0-9]+\]}}, [[RESULT]]
13 define amdgpu_kernel void @v_uint_to_fp_i64_to_f64(double addrspace(1)* %out, i64 addrspace(1)* %in) {
14 %tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
15 %gep = getelementptr i64, i64 addrspace(1)* %in, i32 %tid
16 %val = load i64, i64 addrspace(1)* %gep, align 8
17 %result = uitofp i64 %val to double
18 store double %result, double addrspace(1)* %out
22 ; GCN-LABEL: {{^}}s_uint_to_fp_i64_to_f64
23 define amdgpu_kernel void @s_uint_to_fp_i64_to_f64(double addrspace(1)* %out, i64 %in) {
24 %cast = uitofp i64 %in to double
25 store double %cast, double addrspace(1)* %out, align 8
29 ; GCN-LABEL: {{^}}s_uint_to_fp_v2i64_to_v2f64
30 define amdgpu_kernel void @s_uint_to_fp_v2i64_to_v2f64(<2 x double> addrspace(1)* %out, <2 x i64> %in) {
31 %cast = uitofp <2 x i64> %in to <2 x double>
32 store <2 x double> %cast, <2 x double> addrspace(1)* %out, align 16
36 ; GCN-LABEL: {{^}}s_uint_to_fp_v4i64_to_v4f64
37 define amdgpu_kernel void @s_uint_to_fp_v4i64_to_v4f64(<4 x double> addrspace(1)* %out, <4 x i64> %in) {
38 %cast = uitofp <4 x i64> %in to <4 x double>
39 store <4 x double> %cast, <4 x double> addrspace(1)* %out, align 16
43 ; GCN-LABEL: {{^}}s_uint_to_fp_i32_to_f64
44 ; GCN: v_cvt_f64_u32_e32
46 define amdgpu_kernel void @s_uint_to_fp_i32_to_f64(double addrspace(1)* %out, i32 %in) {
47 %cast = uitofp i32 %in to double
48 store double %cast, double addrspace(1)* %out, align 8
52 ; GCN-LABEL: {{^}}s_uint_to_fp_v2i32_to_v2f64
53 ; GCN: v_cvt_f64_u32_e32
54 ; GCN: v_cvt_f64_u32_e32
56 define amdgpu_kernel void @s_uint_to_fp_v2i32_to_v2f64(<2 x double> addrspace(1)* %out, <2 x i32> %in) {
57 %cast = uitofp <2 x i32> %in to <2 x double>
58 store <2 x double> %cast, <2 x double> addrspace(1)* %out, align 16
62 ; GCN-LABEL: {{^}}s_uint_to_fp_v4i32_to_v4f64
63 ; GCN: v_cvt_f64_u32_e32
64 ; GCN: v_cvt_f64_u32_e32
65 ; GCN: v_cvt_f64_u32_e32
66 ; GCN: v_cvt_f64_u32_e32
68 define amdgpu_kernel void @s_uint_to_fp_v4i32_to_v4f64(<4 x double> addrspace(1)* %out, <4 x i32> %in) {
69 %cast = uitofp <4 x i32> %in to <4 x double>
70 store <4 x double> %cast, <4 x double> addrspace(1)* %out, align 16
74 ; We can't fold the SGPRs into v_cndmask_b32_e32, because it already
75 ; uses an SGPR (implicit vcc).
77 ; GCN-LABEL: {{^}}uint_to_fp_i1_to_f64:
78 ; VI-DAG: s_cmp_eq_u32
79 ; VI-DAG: s_cselect_b32 s[[SSEL:[0-9]+]], 0x3ff00000, 0
80 ; VI-DAG: v_mov_b32_e32 v[[SEL:[0-9]+]], s[[SSEL]]
81 ; SI-DAG: s_cmp_eq_u32
82 ; SI-DAG: s_cselect_b64 vcc, -1, 0
83 ; SI-DAG: v_cndmask_b32_e32 v[[SEL:[0-9]+]], 0, {{v[0-9]+}}, vcc
84 ; GCN-DAG: v_mov_b32_e32 v[[ZERO:[0-9]+]], 0{{$}}
85 ; GCN: flat_store_dwordx2 v{{\[[0-9]+:[0-9]+\]}}, v[[[ZERO]]:[[SEL]]]
87 define amdgpu_kernel void @uint_to_fp_i1_to_f64(double addrspace(1)* %out, i32 %in) {
88 %cmp = icmp eq i32 %in, 0
89 %fp = uitofp i1 %cmp to double
90 store double %fp, double addrspace(1)* %out, align 4
94 ; GCN-LABEL: {{^}}uint_to_fp_i1_to_f64_load:
95 ; GCN: v_cndmask_b32_e64 [[IRESULT:v[0-9]]], 0, 1
96 ; GCN: v_cvt_f64_u32_e32 [[RESULT:v\[[0-9]+:[0-9]\]]], [[IRESULT]]
97 ; GCN: flat_store_dwordx2 v{{\[[0-9]+:[0-9]+\]}}, [[RESULT]]
99 define amdgpu_kernel void @uint_to_fp_i1_to_f64_load(double addrspace(1)* %out, i1 %in) {
100 %fp = uitofp i1 %in to double
101 store double %fp, double addrspace(1)* %out, align 8
105 ; GCN-LABEL: {{^}}s_uint_to_fp_i8_to_f64:
106 ; GCN: s_load_dword [[VAL:s[0-9]+]]
107 ; SI: s_and_b32 [[ZEXT:s[0-9]+]], [[VAL]], 0xff{{$}}
108 ; SI: v_cvt_f64_u32_e32 v{{\[[0-9]+:[0-9]+\]}}, [[ZEXT]]
110 ; VI: s_and_b32 [[ZEXT:s[0-9]+]], [[VAL]], 0xff{{$}}
111 ; VI: v_cvt_f64_u32_e32 v{{\[[0-9]+:[0-9]+\]}}, [[ZEXT]]
112 define amdgpu_kernel void @s_uint_to_fp_i8_to_f64(double addrspace(1)* %out, i8 %in) {
113 %fp = uitofp i8 %in to double
114 store double %fp, double addrspace(1)* %out
119 ; GCN-LABEL: {{^}}v_uint_to_fp_i8_to_f64:
120 ; SI: v_and_b32_e32 [[ZEXT:v[0-9]+]], 0xff, v0
121 ; SI: v_cvt_f64_u32_e32 v{{\[[0-9]+:[0-9]+\]}}, [[ZEXT]]
123 ; VI: v_mov_b32_e32 v{{[0-9]+}}
125 ; VI: v_cvt_f64_u32_e32 v{{\[[0-9]+:[0-9]+\]}},
126 define double @v_uint_to_fp_i8_to_f64(i8 %in) {
127 %fp = uitofp i8 %in to double