1 ; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
3 declare i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
5 declare double @fabs(double) readnone
6 declare double @llvm.fabs.f64(double) readnone
7 declare <2 x double> @llvm.fabs.v2f64(<2 x double>) readnone
8 declare <4 x double> @llvm.fabs.v4f64(<4 x double>) readnone
10 ; FUNC-LABEL: {{^}}v_fabs_f64:
13 define amdgpu_kernel void @v_fabs_f64(ptr addrspace(1) %out, ptr addrspace(1) %in) {
14 %tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
15 %tidext = sext i32 %tid to i64
16 %gep = getelementptr double, ptr addrspace(1) %in, i64 %tidext
17 %val = load double, ptr addrspace(1) %gep, align 8
18 %fabs = call double @llvm.fabs.f64(double %val)
19 store double %fabs, ptr addrspace(1) %out
23 ; FUNC-LABEL: {{^}}fabs_f64:
26 define amdgpu_kernel void @fabs_f64(ptr addrspace(1) %out, double %in) {
27 %fabs = call double @llvm.fabs.f64(double %in)
28 store double %fabs, ptr addrspace(1) %out
32 ; FUNC-LABEL: {{^}}fabs_v2f64:
36 define amdgpu_kernel void @fabs_v2f64(ptr addrspace(1) %out, <2 x double> %in) {
37 %fabs = call <2 x double> @llvm.fabs.v2f64(<2 x double> %in)
38 store <2 x double> %fabs, ptr addrspace(1) %out
42 ; FUNC-LABEL: {{^}}fabs_v4f64:
48 define amdgpu_kernel void @fabs_v4f64(ptr addrspace(1) %out, <4 x double> %in) {
49 %fabs = call <4 x double> @llvm.fabs.v4f64(<4 x double> %in)
50 store <4 x double> %fabs, ptr addrspace(1) %out
54 ; SI-LABEL: {{^}}fabs_fold_f64:
55 ; SI: s_load_dwordx2 [[ABS_VALUE:s\[[0-9]+:[0-9]+\]]], {{s\[[0-9]+:[0-9]+\]}}, 0x13
57 ; SI: v_mul_f64 {{v\[[0-9]+:[0-9]+\]}}, |[[ABS_VALUE]]|, {{v\[[0-9]+:[0-9]+\]}}
59 define amdgpu_kernel void @fabs_fold_f64(ptr addrspace(1) %out, [8 x i32], double %in0, [8 x i32], double %in1) {
60 %fabs = call double @llvm.fabs.f64(double %in0)
61 %fmul = fmul double %fabs, %in1
62 store double %fmul, ptr addrspace(1) %out
66 ; SI-LABEL: {{^}}fabs_fn_fold_f64:
67 ; SI: s_load_dwordx2 [[ABS_VALUE:s\[[0-9]+:[0-9]+\]]], {{s\[[0-9]+:[0-9]+\]}}, 0x13
69 ; SI: v_mul_f64 {{v\[[0-9]+:[0-9]+\]}}, |[[ABS_VALUE]]|, {{v\[[0-9]+:[0-9]+\]}}
71 define amdgpu_kernel void @fabs_fn_fold_f64(ptr addrspace(1) %out, [8 x i32], double %in0, [8 x i32], double %in1) {
72 %fabs = call double @fabs(double %in0)
73 %fmul = fmul double %fabs, %in1
74 store double %fmul, ptr addrspace(1) %out
78 ; FUNC-LABEL: {{^}}fabs_free_f64:
81 define amdgpu_kernel void @fabs_free_f64(ptr addrspace(1) %out, i64 %in) {
82 %bc= bitcast i64 %in to double
83 %fabs = call double @llvm.fabs.f64(double %bc)
84 store double %fabs, ptr addrspace(1) %out
88 ; FUNC-LABEL: {{^}}fabs_fn_free_f64:
91 define amdgpu_kernel void @fabs_fn_free_f64(ptr addrspace(1) %out, i64 %in) {
92 %bc= bitcast i64 %in to double
93 %fabs = call double @fabs(double %bc)
94 store double %fabs, ptr addrspace(1) %out