From patchwork Wed Sep 19 21:42:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 29478 Received: (qmail 24054 invoked by alias); 19 Sep 2018 21:42:11 -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 24044 invoked by uid 89); 19 Sep 2018 21:42:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=availability, extremely, invert X-HELO: relay1.mentorg.com Date: Wed, 19 Sep 2018 21:42:02 +0000 From: Joseph Myers To: Florian Weimer CC: Subject: Re: Update list of i686-class processors in sysdeps/x86/cpu-features.h In-Reply-To: <878t3xw8wb.fsf@oldenburg.str.redhat.com> Message-ID: References: <87r2hquhcj.fsf@mid.deneb.enyo.de> <878t3xw8wb.fsf@oldenburg.str.redhat.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 On Wed, 19 Sep 2018, Florian Weimer wrote: > > We have a general principle that it's best for compile-time selection of > > subarchitecture variants of functions to be based on how the compiler > > behaves rather than configuring for a variant host triplet or using > > --with-cpu. We could e.g. select SSE functions by default based on > > __SSE2__ (even if we don't do so at present). But testing whether the > > compiler produces a CMOV instruction for particular code seems more > > fragile than testing #if conditions for processors without CMOV. > > I agree about CMOV because it is extremely unlikely that we will see > another useful x86 CPU that doesn't have CMOV. So how about this patch that makes sysdeps/x86/cpu-features.h use short lists of processors without certain features instead of long lists of those with them? Invert sense of list of i686-class processors in sysdeps/x86/cpu-features.h. I noticed that sysdeps/x86/cpu-features.h had conditionals on whether to define HAS_CPUID, HAS_I586 and HAS_I686 with a long list of preprocessor macros for i686-and-later processors which however was out of date. This patch avoids the problem of the list getting out of date by instead having conditionals on all the (few, old) pre-i686 processors for which GCC has preprocessor macros, rather than the (many, expanding list) i686-and-later processors. It seems HAS_I586 and HAS_I686 are unused so the only effect of these macros being missing is that 32-bit glibc built for one of these processors would end up doing runtime detection of CPUID availability. i386 builds are prevented by a configure test so there is no need to allow for them here. __geode__ (no long nops?) and __k6__ (no CMOV, at least according to GCC) are conservatively handled as i586, not i686, here (as noted above, this is a theoretical distinction at present in that only HAS_CPUID appears to be used). Tested for x86. 2018-09-19 Joseph Myers * sysdeps/x86/cpu-features.h [__geode__ || __k6__]: Handle like [__i586__ || __pentium__]. [__i486__]: Handle explicitly. (HAS_CPUID): Define to 1 if above macros are undefined. (HAS_I586): Likewise. (HAS_I686): Likewise. diff --git a/sysdeps/x86/cpu-features.h b/sysdeps/x86/cpu-features.h index d342664c64..fb22d7b9d6 100644 --- a/sysdeps/x86/cpu-features.h +++ b/sysdeps/x86/cpu-features.h @@ -257,30 +257,19 @@ extern const struct cpu_features *__get_cpu_features (void) #ifdef __x86_64__ # define HAS_CPUID 1 -#elif defined __i586__ || defined __pentium__ +#elif (defined __i586__ || defined __pentium__ \ + || defined __geode__ || defined __k6__) # define HAS_CPUID 1 # define HAS_I586 1 # define HAS_I686 HAS_ARCH_FEATURE (I686) -#elif (defined __i686__ || defined __pentiumpro__ \ - || defined __pentium4__ || defined __nocona__ \ - || defined __atom__ || defined __core2__ \ - || defined __corei7__ || defined __corei7_avx__ \ - || defined __core_avx2__ || defined __nehalem__ \ - || defined __sandybridge__ || defined __haswell__ \ - || defined __knl__ || defined __bonnell__ \ - || defined __silvermont__ \ - || defined __k6__ || defined __k8__ \ - || defined __athlon__ || defined __amdfam10__ \ - || defined __bdver1__ || defined __bdver2__ \ - || defined __bdver3__ || defined __bdver4__ \ - || defined __btver1__ || defined __btver2__) -# define HAS_CPUID 1 -# define HAS_I586 1 -# define HAS_I686 1 -#else +#elif defined __i486__ # define HAS_CPUID 0 # define HAS_I586 HAS_ARCH_FEATURE (I586) # define HAS_I686 HAS_ARCH_FEATURE (I686) +#else +# define HAS_CPUID 1 +# define HAS_I586 1 +# define HAS_I686 1 #endif #endif /* cpu_features_h */