From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 104822 invoked by alias); 2 Dec 2019 14:56:18 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 104814 invoked by uid 89); 2 Dec 2019 14:56:18 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.0 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.1 spammy=201912, pay X-HELO: mx0a-001b2d01.pphosted.com Subject: Re: [PATCH 01/17] S390: Use load-fp-integer instruction for nearbyint functions. To: libc-alpha@sourceware.org References: <1572881244-6781-1-git-send-email-stli@linux.ibm.com> From: Stefan Liebler Date: Mon, 02 Dec 2019 14:56:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit x-cbid: 19120214-0028-0000-0000-000003C3741F X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19120214-0029-0000-0000-000024868A0F Message-Id: <146c3464-3a70-e2b9-e50f-46d2a27e056f@linux.ibm.com> X-SW-Source: 2019-12/txt/msg00032.txt.bz2 On 11/4/19 7:22 PM, Adhemerval Zanella wrote: > > > On 04/11/2019 12:27, Stefan Liebler wrote: >> If compiled with z196 zarch support, the load-fp-integer instruction >> is used to implement nearbyint, nearbyintf, nearbyintl. >> Otherwise the common-code implementation is used. > >> + >> +double >> +__nearbyint (double x) >> +{ >> + double y; >> + /* The z196 zarch "load fp integer" (fidbra) instruction is rounding >> + x to the nearest integer according to current rounding mode (M3-field: 0) >> + where inexact exceptions are suppressed (M4-field: 4). */ >> + __asm__ ("fidbra %0,0,%1,4" : "=f" (y) : "f" (x)); >> + return y; >> +} >> +libm_alias_double (__nearbyint, nearbyint) > > At least with recent gcc __builtin_nearbyint generates the expected fidbra > instruction for -march=z196. I wonder if we could start to simplify some > math symbols implementation where new architectures/extensions provide > direct implementation by a direct mapping implemented by compiler builtins. > > I would expect to: > > 1. Move all sysdeps/ieee754/dbl-64/wordsize-64 to sysdeps/ieee754/dbl-64/ > since I hardly doubt these micro-optimizations really pay off with > recent architectures and compiler version. > > 2. Add internal macros __USE__BUILTIN and use as: > > * sysdeps/ieee754/dbl-64/s_nearbyint.c > > [...] > double > __nearbyint (double x) > { > #if __USE_NEARBYINT_BUILTIN > return __builtin_nearbyint (x); > #else > /* Use generic implementation. */ > #endif > } > > 3. Define the __USE__BUILTIN for each architecture. > > It would allow to simplify some architectures, aarch64 for instance. > This patch is superseded by the patch-series which is always using wordsize-64 version and allows to use the GCC builtins in common-code implementation: "[PATCH 00/13] Use GCC builtins for some math functions if desired." https://www.sourceware.org/ml/libc-alpha/2019-12/msg00029.html Bye, Stefan