From cd3cc47033a619833f67e84ff0ec9adfbd8cab3f Mon Sep 17 00:00:00 2001 From: David Schultz Date: Sat, 15 Jan 2005 03:32:28 +0000 Subject: [PATCH] amd64 assembly versions of sqrt(), lrint(), and llrint() using SSE2. --- lib/msun/Makefile | 2 ++ lib/msun/amd64/e_sqrt.S | 33 +++++++++++++++++++++++++++++++++ lib/msun/amd64/s_llrint.S | 6 ++++++ lib/msun/amd64/s_lrint.S | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 77 insertions(+) create mode 100644 lib/msun/amd64/e_sqrt.S create mode 100644 lib/msun/amd64/s_llrint.S create mode 100644 lib/msun/amd64/s_lrint.S diff --git a/lib/msun/Makefile b/lib/msun/Makefile index d7d3e52abe4e..eec0f8a1d13b 100644 --- a/lib/msun/Makefile +++ b/lib/msun/Makefile @@ -48,6 +48,8 @@ ARCH_SRCS = s_copysign.S s_copysignf.S # handling is broken (doesn't exist!) on the Alpha port. # Stock gcc 2.7.2.1 doesn't understand these options. #CFLAGS += -mtrap-precision=i -mfp-trap-mode=su +.elif ${MACHINE_ARCH} == "amd64" +ARCH_SRCS = e_sqrt.S s_lrint.S s_llrint.S .elif ${MACHINE_ARCH} == "i386" ARCH_SUBDIR= i387 ARCH_SRCS = e_acos.S e_asin.S e_atan2.S e_exp.S e_fmod.S e_log.S e_log10.S \ diff --git a/lib/msun/amd64/e_sqrt.S b/lib/msun/amd64/e_sqrt.S new file mode 100644 index 000000000000..500c677fa3c0 --- /dev/null +++ b/lib/msun/amd64/e_sqrt.S @@ -0,0 +1,33 @@ +/*- + * Copyright (c) 2005 David Schultz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$") + +ENTRY(__ieee754_sqrt) + sqrtsd %xmm0, %xmm0 + ret + diff --git a/lib/msun/amd64/s_llrint.S b/lib/msun/amd64/s_llrint.S new file mode 100644 index 000000000000..ab098465cd57 --- /dev/null +++ b/lib/msun/amd64/s_llrint.S @@ -0,0 +1,6 @@ +#include +__FBSDID("$FreeBSD$") + +/* sizeof(long) == sizeof(long long) */ +#define fn llrint +#include "s_lrint.S" diff --git a/lib/msun/amd64/s_lrint.S b/lib/msun/amd64/s_lrint.S new file mode 100644 index 000000000000..9059a38f84de --- /dev/null +++ b/lib/msun/amd64/s_lrint.S @@ -0,0 +1,36 @@ +/*- + * Copyright (c) 2005 David Schultz + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include + +#ifndef fn +__FBSDID("$FreeBSD$") +#define fn lrint +#endif + +ENTRY(fn) + cvtsd2si %xmm0, %rax + ret