From db373e4c57159ac82df4b07b596dd29c4cfe9d86 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Wed, 24 Mar 2021 18:56:34 -0300 Subject: Remove architecture specific sched_cpucount optimizations And replace the generic algorithm with the Brian Kernighan's one. GCC optimize it with popcnt if the architecture supports, so there is no need to add the extra POPCNT define to enable it. This is really a micro-optimization that only adds complexity: recent ABIs already support it (x86-64-v2 or power64le) and it simplifies the code for internal usage, since i686 does not allow an internal iFUNC call. Checked on x86_64-linux-gnu, aarch64-linux-gnu, and powerpc64le-linux-gnu. --- sysdeps/i386/i686/multiarch/sched_cpucount.c | 1 - sysdeps/ia64/sched_cpucount.c | 20 ---------------- sysdeps/powerpc/sched_cpucount.c | 22 ----------------- sysdeps/x86_64/multiarch/sched_cpucount.c | 36 ---------------------------- sysdeps/x86_64/sched_cpucount.c | 25 ------------------- 5 files changed, 104 deletions(-) delete mode 100644 sysdeps/i386/i686/multiarch/sched_cpucount.c delete mode 100644 sysdeps/ia64/sched_cpucount.c delete mode 100644 sysdeps/powerpc/sched_cpucount.c delete mode 100644 sysdeps/x86_64/multiarch/sched_cpucount.c delete mode 100644 sysdeps/x86_64/sched_cpucount.c (limited to 'sysdeps') diff --git a/sysdeps/i386/i686/multiarch/sched_cpucount.c b/sysdeps/i386/i686/multiarch/sched_cpucount.c deleted file mode 100644 index 7db31b02f8..0000000000 --- a/sysdeps/i386/i686/multiarch/sched_cpucount.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/ia64/sched_cpucount.c b/sysdeps/ia64/sched_cpucount.c deleted file mode 100644 index 8440864b02..0000000000 --- a/sysdeps/ia64/sched_cpucount.c +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright (C) 2007-2021 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 POPCNT(l) __builtin_popcountl (l) - -#include diff --git a/sysdeps/powerpc/sched_cpucount.c b/sysdeps/powerpc/sched_cpucount.c deleted file mode 100644 index 8f00e3dbc8..0000000000 --- a/sysdeps/powerpc/sched_cpucount.c +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright (C) 2007-2021 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 - . */ - -#ifdef _ARCH_PWR5 -# define POPCNT(l) __builtin_popcountl (l) -#endif - -#include diff --git a/sysdeps/x86_64/multiarch/sched_cpucount.c b/sysdeps/x86_64/multiarch/sched_cpucount.c deleted file mode 100644 index 5180a11434..0000000000 --- a/sysdeps/x86_64/multiarch/sched_cpucount.c +++ /dev/null @@ -1,36 +0,0 @@ -/* Count bits in CPU set. x86-64 multi-arch version. - This file is part of the GNU C Library. - Copyright (C) 2008-2021 Free Software Foundation, Inc. - Contributed by Ulrich Drepper . - - 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 -#include "init-arch.h" - -#define __sched_cpucount static generic_cpucount -#include -#undef __sched_cpucount - -#define POPCNT(l) \ - ({ __cpu_mask r; \ - asm ("popcnt %1, %0" : "=r" (r) : "0" (l));\ - r; }) -#define __sched_cpucount static popcount_cpucount -#include -#undef __sched_cpucount - -libc_ifunc (__sched_cpucount, - CPU_FEATURE_USABLE (POPCNT) ? popcount_cpucount : generic_cpucount); diff --git a/sysdeps/x86_64/sched_cpucount.c b/sysdeps/x86_64/sched_cpucount.c deleted file mode 100644 index 5a27336d6d..0000000000 --- a/sysdeps/x86_64/sched_cpucount.c +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright (C) 2007-2021 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 - . */ - -#ifdef __amdfam10 -# define POPCNT(l) \ - ({ __cpu_mask r; \ - asm ("popcntq %1, %0" : "=r" (r) : "0" (l)); \ - r; }) -#endif - -#include -- cgit 1.4.1