Date: Mon, 1 Mar 2021 12:56:02 GMT From: Alex Richardson <arichardson@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 524b018d2004 - main - riscv: Add a soft-float implementation of fabs() Message-ID: <202103011256.121Cu24D047064@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by arichardson: URL: https://cgit.FreeBSD.org/src/commit/?id=524b018d200408bed5eb0d2b892db5b9fb46808b commit 524b018d200408bed5eb0d2b892db5b9fb46808b Author: Alex Richardson <arichardson@FreeBSD.org> AuthorDate: 2021-03-01 12:46:30 +0000 Commit: Alex Richardson <arichardson@FreeBSD.org> CommitDate: 2021-03-01 12:53:46 +0000 riscv: Add a soft-float implementation of fabs() We could just use a C implementation using __builtin_fabs(), but using this assembly version guarantees that there is no additional prolog/epilog code. Additionally, clang generates worse code for masking off the top bit than GCC: https://bugs.llvm.org/show_bug.cgi?id=49377. This fixes the RISCV64 softfloat world build after cf97d2a1dab8. That commit added -fno-builtin to the msun tests which resulted in the first references to fabs (previously the compiler inlined all calls). Reviewed By: dim Reported by: mjg Differential Revision: https://reviews.freebsd.org/D28994 --- lib/libc/riscv/gen/fabs.S | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/libc/riscv/gen/fabs.S b/lib/libc/riscv/gen/fabs.S index 44249252e9c1..09042af3b4c0 100644 --- a/lib/libc/riscv/gen/fabs.S +++ b/lib/libc/riscv/gen/fabs.S @@ -1,5 +1,6 @@ /*- * Copyright (c) 2015-2017 Ruslan Bukin <br@bsdpad.com> + * Copyright (c) 2021 Alex Richardson <arichardson@FreeBSD.org> * All rights reserved. * * Portions of this software were developed by SRI International and the @@ -10,6 +11,9 @@ * Computer Laboratory as part of the CTSRD Project, with support from the * UK Higher Education Innovation Fund (HEIF). * + * This work was supported by Innovate UK project 105694, "Digital Security + * by Design (DSbD) Technology Platform Prototype". + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -35,9 +39,12 @@ #include <machine/asm.h> __FBSDID("$FreeBSD$"); -#ifdef __riscv_float_abi_double ENTRY(fabs) +#ifdef __riscv_float_abi_double fabs.d fa0, fa0 +#else + slli a0,a0,1 + srli a0,a0,1 +#endif ret END(fabs) -#endif
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202103011256.121Cu24D047064>