From patchwork Wed Aug 2 15:37:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H.J. Lu" X-Patchwork-Id: 796670 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-82608-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="Zb/A8nq1"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xMy4N4zXsz9sRm for ; Thu, 3 Aug 2017 01:37:40 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :mime-version:content-type; q=dns; s=default; b=nXuZgJjG4VcfLcBm NVaLZ7o3NSlPpEFIhBGOfhRQKiBWXsv/3aJRuHhTs6izf85OU3G+/tJf395cB8DZ sEVyeETrIg/UDwzOcyNGy9xXkjzlM/HwEcH98kYLHO2mQ7+Gloz914nzrtNXSDd1 lZ6mhKJB2tlWLLawPKjc3BWpxOE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :mime-version:content-type; s=default; bh=uYV8pZf4/UAWHrUpAU+SWD Hl3DY=; b=Zb/A8nq12+VXoWwjRSJNU/Js1l30Dg1rSuTaCSlOvo4at1MYEuNHTf w8EXhEkPX42y3gNUjXgkydEKOvJdipjIosXJicS6zo7BMyG87RuQJDwnHKzXuHki 2PWn7MVm/wO3BkxIyRkxWxOPFP4ucJ+DvdNDPfWWHdfHmpvDobvP0= Received: (qmail 5239 invoked by alias); 2 Aug 2017 15:37:31 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 5213 invoked by uid 89); 2 Aug 2017 15:37:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.2 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KAM_STOCKGEN, NO_DNS_FOR_FROM, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mga05.intel.com X-ExtLoop1: 1 Date: Wed, 2 Aug 2017 08:37:24 -0700 From: "H.J. Lu" To: GNU C Library Subject: [PATCH 1/4] x86-64: Implement libm IFUNC selectors in C Message-ID: <20170802153724.GA21898@gmail.com> Reply-To: "H.J. Lu" MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.8.3 (2017-05-23) Any comments or objections? H.J. --- * sysdeps/x86_64/fpu/multiarch/Makefile (libm-sysdep_routines): Add s_ceil-sse4_1, s_ceilf-sse4_1, s_floor-sse4_1, s_floorf-sse4_1, s_nearbyint-sse4_1, s_nearbyintf-sse4_1, s_rint-sse4_1 and s_rintf-sse4_1. * sysdeps/x86_64/fpu/multiarch/ifunc-sse4_1.h: New file. * sysdeps/x86_64/fpu/multiarch/s_ceil.c: Likewise. * sysdeps/x86_64/fpu/multiarch/s_ceilf.c: Likewise. * sysdeps/x86_64/fpu/multiarch/s_floor.c: Likewise. * sysdeps/x86_64/fpu/multiarch/s_floorf.c: Likewise. * sysdeps/x86_64/fpu/multiarch/s_nearbyint.c: Likewise. * sysdeps/x86_64/fpu/multiarch/s_nearbyintf.c: Likewise. * sysdeps/x86_64/fpu/multiarch/s_rint.c: Likewise. * sysdeps/x86_64/fpu/multiarch/s_rintf.c: Likewise. * sysdeps/x86_64/fpu/multiarch/s_ceil.S: Renamed to ... * sysdeps/x86_64/fpu/multiarch/s_ceil-sse4_1.S: This. Don't include nor . Include . (__ceil): Removed. * sysdeps/x86_64/fpu/multiarch/s_ceilf.S: Renamed to ... * sysdeps/x86_64/fpu/multiarch/s_ceilf-sse4_1.S: This. Don't include nor . Include . (__ceilf): Removed. * sysdeps/x86_64/fpu/multiarch/s_floor.S: Renamed to ... * sysdeps/x86_64/fpu/multiarch/s_floor-sse4_1.S: This. Don't include nor . Include . (__floor): Removed. * sysdeps/x86_64/fpu/multiarch/s_floorf.S: Renamed to ... * sysdeps/x86_64/fpu/multiarch/s_floorf-sse4_1.S: This. Don't include nor . Include . (__floorf): Removed. * sysdeps/x86_64/fpu/multiarch/s_nearbyint.S: Renamed to ... * sysdeps/x86_64/fpu/multiarch/s_nearbyint-sse4_1.S: This. Don't include nor . Include . (__nearbyint): Removed. * sysdeps/x86_64/fpu/multiarch/s_nearbyintf.S: Renamed to ... * sysdeps/x86_64/fpu/multiarch/s_nearbyintf-sse4_1.S: This. Don't include nor . Include . (__nearbyintf): Removed. * sysdeps/x86_64/fpu/multiarch/s_rint.S: Renamed to ... * sysdeps/x86_64/fpu/multiarch/s_rint-sse4_1.S: This. Don't include nor . Include . (__rint): Removed. * sysdeps/x86_64/fpu/multiarch/s_rintf.S: Renamed to ... * sysdeps/x86_64/fpu/multiarch/s_rintf-sse4_1.S: This. Don't include nor . Include . (__rintf): Removed. --- sysdeps/x86_64/fpu/multiarch/Makefile | 4 +++ sysdeps/x86_64/fpu/multiarch/ifunc-sse4_1.h | 33 ++++++++++++++++++++++ .../fpu/multiarch/{s_ceil.S => s_ceil-sse4_1.S} | 17 ++--------- sysdeps/x86_64/fpu/multiarch/s_ceil.c | 29 +++++++++++++++++++ .../fpu/multiarch/{s_ceilf.S => s_ceilf-sse4_1.S} | 17 ++--------- sysdeps/x86_64/fpu/multiarch/s_ceilf.c | 29 +++++++++++++++++++ .../fpu/multiarch/{s_floor.S => s_floor-sse4_1.S} | 17 ++--------- sysdeps/x86_64/fpu/multiarch/s_floor.c | 29 +++++++++++++++++++ .../multiarch/{s_floorf.S => s_floorf-sse4_1.S} | 17 ++--------- sysdeps/x86_64/fpu/multiarch/s_floorf.c | 29 +++++++++++++++++++ .../{s_nearbyint.S => s_nearbyint-sse4_1.S} | 17 ++--------- sysdeps/x86_64/fpu/multiarch/s_nearbyint.c | 30 ++++++++++++++++++++ .../{s_nearbyintf.S => s_nearbyintf-sse4_1.S} | 17 ++--------- sysdeps/x86_64/fpu/multiarch/s_nearbyintf.c | 30 ++++++++++++++++++++ .../fpu/multiarch/{s_rint.S => s_rint-sse4_1.S} | 17 ++--------- sysdeps/x86_64/fpu/multiarch/s_rint.c | 29 +++++++++++++++++++ .../fpu/multiarch/{s_rintf.S => s_rintf-sse4_1.S} | 17 ++--------- sysdeps/x86_64/fpu/multiarch/s_rintf.c | 29 +++++++++++++++++++ 18 files changed, 287 insertions(+), 120 deletions(-) create mode 100644 sysdeps/x86_64/fpu/multiarch/ifunc-sse4_1.h rename sysdeps/x86_64/fpu/multiarch/{s_ceil.S => s_ceil-sse4_1.S} (77%) create mode 100644 sysdeps/x86_64/fpu/multiarch/s_ceil.c rename sysdeps/x86_64/fpu/multiarch/{s_ceilf.S => s_ceilf-sse4_1.S} (77%) create mode 100644 sysdeps/x86_64/fpu/multiarch/s_ceilf.c rename sysdeps/x86_64/fpu/multiarch/{s_floor.S => s_floor-sse4_1.S} (77%) create mode 100644 sysdeps/x86_64/fpu/multiarch/s_floor.c rename sysdeps/x86_64/fpu/multiarch/{s_floorf.S => s_floorf-sse4_1.S} (76%) create mode 100644 sysdeps/x86_64/fpu/multiarch/s_floorf.c rename sysdeps/x86_64/fpu/multiarch/{s_nearbyint.S => s_nearbyint-sse4_1.S} (75%) create mode 100644 sysdeps/x86_64/fpu/multiarch/s_nearbyint.c rename sysdeps/x86_64/fpu/multiarch/{s_nearbyintf.S => s_nearbyintf-sse4_1.S} (75%) create mode 100644 sysdeps/x86_64/fpu/multiarch/s_nearbyintf.c rename sysdeps/x86_64/fpu/multiarch/{s_rint.S => s_rint-sse4_1.S} (77%) create mode 100644 sysdeps/x86_64/fpu/multiarch/s_rint.c rename sysdeps/x86_64/fpu/multiarch/{s_rintf.S => s_rintf-sse4_1.S} (77%) create mode 100644 sysdeps/x86_64/fpu/multiarch/s_rintf.c diff --git a/sysdeps/x86_64/fpu/multiarch/Makefile b/sysdeps/x86_64/fpu/multiarch/Makefile index 34542155aa..86ddde358b 100644 --- a/sysdeps/x86_64/fpu/multiarch/Makefile +++ b/sysdeps/x86_64/fpu/multiarch/Makefile @@ -2,6 +2,10 @@ ifeq ($(subdir),math) libm-sysdep_routines += s_floor-c s_ceil-c s_floorf-c s_ceilf-c \ s_rint-c s_rintf-c s_nearbyint-c s_nearbyintf-c +libm-sysdep_routines += s_ceil-sse4_1 s_ceilf-sse4_1 s_floor-sse4_1 \ + s_floorf-sse4_1 s_nearbyint-sse4_1 \ + s_nearbyintf-sse4_1 s_rint-sse4_1 s_rintf-sse4_1 + libm-sysdep_routines += e_exp-fma4 e_log-fma4 e_pow-fma4 s_atan-fma4 \ e_asin-fma4 e_atan2-fma4 s_sin-fma4 s_tan-fma4 \ mplog-fma4 mpa-fma4 slowexp-fma4 slowpow-fma4 \ diff --git a/sysdeps/x86_64/fpu/multiarch/ifunc-sse4_1.h b/sysdeps/x86_64/fpu/multiarch/ifunc-sse4_1.h new file mode 100644 index 0000000000..ad8d878a2d --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/ifunc-sse4_1.h @@ -0,0 +1,33 @@ +/* Common definition for ifunc selections optimized with SSE4.1. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +extern __typeof (REDIRECT_NAME) OPTIMIZE (c) attribute_hidden; +extern __typeof (REDIRECT_NAME) OPTIMIZE (sse41) attribute_hidden; + +static inline void * +IFUNC_SELECTOR (void) +{ + const struct cpu_features* cpu_features = __get_cpu_features (); + + if (CPU_FEATURES_CPU_P (cpu_features, SSE4_1)) + return OPTIMIZE (sse41); + + return OPTIMIZE (c); +} diff --git a/sysdeps/x86_64/fpu/multiarch/s_ceil.S b/sysdeps/x86_64/fpu/multiarch/s_ceil-sse4_1.S similarity index 77% rename from sysdeps/x86_64/fpu/multiarch/s_ceil.S rename to sysdeps/x86_64/fpu/multiarch/s_ceil-sse4_1.S index f8eef43eff..6d6be97432 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_ceil.S +++ b/sysdeps/x86_64/fpu/multiarch/s_ceil-sse4_1.S @@ -16,22 +16,9 @@ License along with the GNU C Library; if not, see . */ -#include -#include - - -ENTRY(__ceil) - .type __ceil, @gnu_indirect_function - LOAD_RTLD_GLOBAL_RO_RDX - leaq __ceil_sse41(%rip), %rax - HAS_CPU_FEATURE (SSE4_1) - jnz 2f - leaq __ceil_c(%rip), %rax -2: ret -END(__ceil) -weak_alias (__ceil, ceil) - +#include + .section .text.sse4.1,"ax",@progbits ENTRY(__ceil_sse41) roundsd $10, %xmm0, %xmm0 ret diff --git a/sysdeps/x86_64/fpu/multiarch/s_ceil.c b/sysdeps/x86_64/fpu/multiarch/s_ceil.c new file mode 100644 index 0000000000..2c01957963 --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_ceil.c @@ -0,0 +1,29 @@ +/* Multiple versions of __ceil. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define ceil __redirect_ceil +#define __ceil __redirect___ceil +#include +#undef ceil +#undef __ceil + +#define SYMBOL_NAME ceil +#include "ifunc-sse4_1.h" + +libc_ifunc_redirected (__redirect_ceil, __ceil, IFUNC_SELECTOR ()); +weak_alias (__ceil, ceil) diff --git a/sysdeps/x86_64/fpu/multiarch/s_ceilf.S b/sysdeps/x86_64/fpu/multiarch/s_ceilf-sse4_1.S similarity index 77% rename from sysdeps/x86_64/fpu/multiarch/s_ceilf.S rename to sysdeps/x86_64/fpu/multiarch/s_ceilf-sse4_1.S index 076f10f0f0..9081ce6eb4 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_ceilf.S +++ b/sysdeps/x86_64/fpu/multiarch/s_ceilf-sse4_1.S @@ -16,22 +16,9 @@ License along with the GNU C Library; if not, see . */ -#include -#include - - -ENTRY(__ceilf) - .type __ceilf, @gnu_indirect_function - LOAD_RTLD_GLOBAL_RO_RDX - leaq __ceilf_sse41(%rip), %rax - HAS_CPU_FEATURE (SSE4_1) - jnz 2f - leaq __ceilf_c(%rip), %rax -2: ret -END(__ceilf) -weak_alias (__ceilf, ceilf) - +#include + .section .text.sse4.1,"ax",@progbits ENTRY(__ceilf_sse41) roundss $10, %xmm0, %xmm0 ret diff --git a/sysdeps/x86_64/fpu/multiarch/s_ceilf.c b/sysdeps/x86_64/fpu/multiarch/s_ceilf.c new file mode 100644 index 0000000000..090de048b3 --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_ceilf.c @@ -0,0 +1,29 @@ +/* Multiple versions of __ceilf. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define ceilf __redirect_ceilf +#define __ceilf __redirect___ceilf +#include +#undef ceilf +#undef __ceilf + +#define SYMBOL_NAME ceilf +#include "ifunc-sse4_1.h" + +libc_ifunc_redirected (__redirect_ceilf, __ceilf, IFUNC_SELECTOR ()); +weak_alias (__ceilf, ceilf) diff --git a/sysdeps/x86_64/fpu/multiarch/s_floor.S b/sysdeps/x86_64/fpu/multiarch/s_floor-sse4_1.S similarity index 77% rename from sysdeps/x86_64/fpu/multiarch/s_floor.S rename to sysdeps/x86_64/fpu/multiarch/s_floor-sse4_1.S index f519ab24f4..022a4ac160 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_floor.S +++ b/sysdeps/x86_64/fpu/multiarch/s_floor-sse4_1.S @@ -16,22 +16,9 @@ License along with the GNU C Library; if not, see . */ -#include -#include - - -ENTRY(__floor) - .type __floor, @gnu_indirect_function - LOAD_RTLD_GLOBAL_RO_RDX - leaq __floor_sse41(%rip), %rax - HAS_CPU_FEATURE (SSE4_1) - jnz 2f - leaq __floor_c(%rip), %rax -2: ret -END(__floor) -weak_alias (__floor, floor) - +#include + .section .text.sse4.1,"ax",@progbits ENTRY(__floor_sse41) roundsd $9, %xmm0, %xmm0 ret diff --git a/sysdeps/x86_64/fpu/multiarch/s_floor.c b/sysdeps/x86_64/fpu/multiarch/s_floor.c new file mode 100644 index 0000000000..3dd0f81da5 --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_floor.c @@ -0,0 +1,29 @@ +/* Multiple versions of __floor. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define floor __redirect_floor +#define __floor __redirect___floor +#include +#undef floor +#undef __floor + +#define SYMBOL_NAME floor +#include "ifunc-sse4_1.h" + +libc_ifunc_redirected (__redirect_floor, __floor, IFUNC_SELECTOR ()); +weak_alias (__floor, floor) diff --git a/sysdeps/x86_64/fpu/multiarch/s_floorf.S b/sysdeps/x86_64/fpu/multiarch/s_floorf-sse4_1.S similarity index 76% rename from sysdeps/x86_64/fpu/multiarch/s_floorf.S rename to sysdeps/x86_64/fpu/multiarch/s_floorf-sse4_1.S index 8613f73acc..ea631441e7 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_floorf.S +++ b/sysdeps/x86_64/fpu/multiarch/s_floorf-sse4_1.S @@ -16,22 +16,9 @@ License along with the GNU C Library; if not, see . */ -#include -#include - - -ENTRY(__floorf) - .type __floorf, @gnu_indirect_function - LOAD_RTLD_GLOBAL_RO_RDX - leaq __floorf_sse41(%rip), %rax - HAS_CPU_FEATURE (SSE4_1) - jnz 2f - leaq __floorf_c(%rip), %rax -2: ret -END(__floorf) -weak_alias (__floorf, floorf) - +#include + .section .text.sse4.1,"ax",@progbits ENTRY(__floorf_sse41) roundss $9, %xmm0, %xmm0 ret diff --git a/sysdeps/x86_64/fpu/multiarch/s_floorf.c b/sysdeps/x86_64/fpu/multiarch/s_floorf.c new file mode 100644 index 0000000000..d6cf14da6e --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_floorf.c @@ -0,0 +1,29 @@ +/* Multiple versions of __floorf. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define floorf __redirect_floorf +#define __floorf __redirect___floorf +#include +#undef floorf +#undef __floorf + +#define SYMBOL_NAME floorf +#include "ifunc-sse4_1.h" + +libc_ifunc_redirected (__redirect_floorf, __floorf, IFUNC_SELECTOR ()); +weak_alias (__floorf, floorf) diff --git a/sysdeps/x86_64/fpu/multiarch/s_nearbyint.S b/sysdeps/x86_64/fpu/multiarch/s_nearbyint-sse4_1.S similarity index 75% rename from sysdeps/x86_64/fpu/multiarch/s_nearbyint.S rename to sysdeps/x86_64/fpu/multiarch/s_nearbyint-sse4_1.S index 5a734f6027..68934aac73 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_nearbyint.S +++ b/sysdeps/x86_64/fpu/multiarch/s_nearbyint-sse4_1.S @@ -16,22 +16,9 @@ License along with the GNU C Library; if not, see . */ -#include -#include - - -ENTRY(__nearbyint) - .type __nearbyint, @gnu_indirect_function - LOAD_RTLD_GLOBAL_RO_RDX - leaq __nearbyint_sse41(%rip), %rax - HAS_CPU_FEATURE (SSE4_1) - jnz 2f - leaq __nearbyint_c(%rip), %rax -2: ret -END(__nearbyint) -weak_alias (__nearbyint, nearbyint) - +#include + .section .text.sse4.1,"ax",@progbits ENTRY(__nearbyint_sse41) roundsd $0xc, %xmm0, %xmm0 ret diff --git a/sysdeps/x86_64/fpu/multiarch/s_nearbyint.c b/sysdeps/x86_64/fpu/multiarch/s_nearbyint.c new file mode 100644 index 0000000000..05579c66ea --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_nearbyint.c @@ -0,0 +1,30 @@ +/* Multiple versions of __nearbyint. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define nearbyint __redirect_nearbyint +#define __nearbyint __redirect___nearbyint +#include +#undef nearbyint +#undef __nearbyint + +#define SYMBOL_NAME nearbyint +#include "ifunc-sse4_1.h" + +libc_ifunc_redirected (__redirect_nearbyint, __nearbyint, + IFUNC_SELECTOR ()); +weak_alias (__nearbyint, nearbyint) diff --git a/sysdeps/x86_64/fpu/multiarch/s_nearbyintf.S b/sysdeps/x86_64/fpu/multiarch/s_nearbyintf-sse4_1.S similarity index 75% rename from sysdeps/x86_64/fpu/multiarch/s_nearbyintf.S rename to sysdeps/x86_64/fpu/multiarch/s_nearbyintf-sse4_1.S index ad79fd6021..16bd905655 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_nearbyintf.S +++ b/sysdeps/x86_64/fpu/multiarch/s_nearbyintf-sse4_1.S @@ -16,22 +16,9 @@ License along with the GNU C Library; if not, see . */ -#include -#include - - -ENTRY(__nearbyintf) - .type __nearbyintf, @gnu_indirect_function - LOAD_RTLD_GLOBAL_RO_RDX - leaq __nearbyintf_sse41(%rip), %rax - HAS_CPU_FEATURE (SSE4_1) - jnz 2f - leaq __nearbyintf_c(%rip), %rax -2: ret -END(__nearbyintf) -weak_alias (__nearbyintf, nearbyintf) - +#include + .section .text.sse4.1,"ax",@progbits ENTRY(__nearbyintf_sse41) roundss $0xc, %xmm0, %xmm0 ret diff --git a/sysdeps/x86_64/fpu/multiarch/s_nearbyintf.c b/sysdeps/x86_64/fpu/multiarch/s_nearbyintf.c new file mode 100644 index 0000000000..e716c94037 --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_nearbyintf.c @@ -0,0 +1,30 @@ +/* Multiple versions of __nearbyintf. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define nearbyintf __redirect_nearbyintf +#define __nearbyintf __redirect___nearbyintf +#include +#undef nearbyintf +#undef __nearbyintf + +#define SYMBOL_NAME nearbyintf +#include "ifunc-sse4_1.h" + +libc_ifunc_redirected (__redirect_nearbyintf, __nearbyintf, + IFUNC_SELECTOR ()); +weak_alias (__nearbyintf, nearbyintf) diff --git a/sysdeps/x86_64/fpu/multiarch/s_rint.S b/sysdeps/x86_64/fpu/multiarch/s_rint-sse4_1.S similarity index 77% rename from sysdeps/x86_64/fpu/multiarch/s_rint.S rename to sysdeps/x86_64/fpu/multiarch/s_rint-sse4_1.S index 4f628a93a4..9224aa92b2 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_rint.S +++ b/sysdeps/x86_64/fpu/multiarch/s_rint-sse4_1.S @@ -16,22 +16,9 @@ License along with the GNU C Library; if not, see . */ -#include -#include - - -ENTRY(__rint) - .type __rint, @gnu_indirect_function - LOAD_RTLD_GLOBAL_RO_RDX - leaq __rint_sse41(%rip), %rax - HAS_CPU_FEATURE (SSE4_1) - jnz 2f - leaq __rint_c(%rip), %rax -2: ret -END(__rint) -weak_alias (__rint, rint) - +#include + .section .text.sse4.1,"ax",@progbits ENTRY(__rint_sse41) roundsd $4, %xmm0, %xmm0 ret diff --git a/sysdeps/x86_64/fpu/multiarch/s_rint.c b/sysdeps/x86_64/fpu/multiarch/s_rint.c new file mode 100644 index 0000000000..ad44e7cf8c --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_rint.c @@ -0,0 +1,29 @@ +/* Multiple versions of __rint. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define rint __redirect_rint +#define __rint __redirect___rint +#include +#undef rint +#undef __rint + +#define SYMBOL_NAME rint +#include "ifunc-sse4_1.h" + +libc_ifunc_redirected (__redirect_rint, __rint, IFUNC_SELECTOR ()); +weak_alias (__rint, rint) diff --git a/sysdeps/x86_64/fpu/multiarch/s_rintf.S b/sysdeps/x86_64/fpu/multiarch/s_rintf-sse4_1.S similarity index 77% rename from sysdeps/x86_64/fpu/multiarch/s_rintf.S rename to sysdeps/x86_64/fpu/multiarch/s_rintf-sse4_1.S index dee4ad794c..7f47592d8c 100644 --- a/sysdeps/x86_64/fpu/multiarch/s_rintf.S +++ b/sysdeps/x86_64/fpu/multiarch/s_rintf-sse4_1.S @@ -16,22 +16,9 @@ License along with the GNU C Library; if not, see . */ -#include -#include - - -ENTRY(__rintf) - .type __rintf, @gnu_indirect_function - LOAD_RTLD_GLOBAL_RO_RDX - leaq __rintf_sse41(%rip), %rax - HAS_CPU_FEATURE (SSE4_1) - jnz 2f - leaq __rintf_c(%rip), %rax -2: ret -END(__rintf) -weak_alias (__rintf, rintf) - +#include + .section .text.sse4.1,"ax",@progbits ENTRY(__rintf_sse41) roundss $4, %xmm0, %xmm0 ret diff --git a/sysdeps/x86_64/fpu/multiarch/s_rintf.c b/sysdeps/x86_64/fpu/multiarch/s_rintf.c new file mode 100644 index 0000000000..88f3052f33 --- /dev/null +++ b/sysdeps/x86_64/fpu/multiarch/s_rintf.c @@ -0,0 +1,29 @@ +/* Multiple versions of __rintf. + Copyright (C) 2017 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#define rintf __redirect_rintf +#define __rintf __redirect___rintf +#include +#undef rintf +#undef __rintf + +#define SYMBOL_NAME rintf +#include "ifunc-sse4_1.h" + +libc_ifunc_redirected (__redirect_rintf, __rintf, IFUNC_SELECTOR ()); +weak_alias (__rintf, rintf)