From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x22f.google.com (mail-oi1-x22f.google.com [IPv6:2607:f8b0:4864:20::22f]) by sourceware.org (Postfix) with ESMTPS id B65CA3858C1F for ; Tue, 12 Sep 2023 13:27:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B65CA3858C1F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-3aa1254fb45so3782250b6e.2 for ; Tue, 12 Sep 2023 06:27:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694525275; x=1695130075; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=aUJz2gcEwQ63ffWXp1T6REDAyC9urMxnTUcGK5zMAyU=; b=W+YQWg3KoYsfqgMvTPfUOg0srW4nRt3jhO8Iu4JsoUpSQhtFQ0EgPtRspI8Ba8hvSf +VWaRpgckqLTS2I2Fg6s2/ZyHPD7w17mITG31YuVJCssOopCrTGnLeBuYp/Zeipvs16S m7vZZ4v2gx/xrpLjLZMBgR7wN90UeuL5YQUWmbOkxMzYnvKO+9U03oFq0Ch6vp+RJ245 ZNXDDbejfhoYPJLqW6TtouOh+KTlVqgvWgCsByMOZ7B574oXPVzU+HeFPg4Kr6lKL5Kt uS/x+Kasd3ivxUm/Fky/7LLW6zTaAkE6oIoOGnqlopLvyqfKWIy8CPwE5x8gnpUwad5/ zlYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694525275; x=1695130075; h=content-transfer-encoding:in-reply-to:organization:from:references :cc:to:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=aUJz2gcEwQ63ffWXp1T6REDAyC9urMxnTUcGK5zMAyU=; b=YQlk72Tmcwr0DT82zRar74uc+O3QUS729+7r1BTI5zlPu3NbzhMHqGsCpL2NuI30VF tUk7DfM6PfVUka3K/KhVKW1LnRArctf2/NQE9K/XLyGyiGLG6i2jpREpAVQ0STq5wEw5 p067q+ydZRZSuIucvjRu1nWuQM7OBUj+0Pk7Dc/lUifu2vwVlctDRfLdwNn18oAJx/NI TLqbdxI3eKwRjpLGurZMKQrS4wegtRjUIP3bOXB3IU/kVY3X+E7LePIvqJx8yx1cLqSn 9SCkIZxotKG8xIrqvKi1NmG4tIMk56eurnP6HjwchzJnURxK+/V65fwTNLEf43ST9zpW 15GA== X-Gm-Message-State: AOJu0YzO41rAHPEjRlm33h4XKKKcc3PIk4eSRnjnxe0YQGNwkwILGubz IEQQ+fryc8P0pCLblhuFUGxZheezf09/Zo5/qubMFg== X-Google-Smtp-Source: AGHT+IG1RoJLsVBchRWWu1xwBIAjnFX2oDjR6KTk0WDIMQMLvSGUhAYqPohT9Gcte0Ka0hnPUW8uFw== X-Received: by 2002:a05:6808:144c:b0:3a7:71bf:af58 with SMTP id x12-20020a056808144c00b003a771bfaf58mr15433157oiv.56.1694525274851; Tue, 12 Sep 2023 06:27:54 -0700 (PDT) Received: from ?IPV6:2804:1b3:a7c0:91cb:1977:7e4f:e638:7fad? ([2804:1b3:a7c0:91cb:1977:7e4f:e638:7fad]) by smtp.gmail.com with ESMTPSA id f5-20020a05680814c500b003a75593746asm4185312oiw.57.2023.09.12.06.27.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Sep 2023 06:27:54 -0700 (PDT) Message-ID: <526f2aac-a06c-d1cf-4c7b-1339846a1711@linaro.org> Date: Tue, 12 Sep 2023 10:27:51 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: [PATCH] [powerpc] fegetenv_and_set_rn now uses the builtins provided by GCC. Content-Language: en-US To: Manjunath Matti , libc-alpha@sourceware.org Cc: rajis@linux.ibm.com, Carl Love References: <20230912082730.3951006-1-mmatti@linux.ibm.com> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <20230912082730.3951006-1-mmatti@linux.ibm.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 12/09/23 05:27, Manjunath Matti wrote: > On powerpc, SET_RESTORE_ROUND uses inline assembly to optimize the > prologue get/save/set rounding mode operations for POWER9 and > later by using 'mffscrn' where possible, this was introduced by > commit f1c56cdff09f650ad721fae026eb6a3651631f3d. > > GCC version 14 onwards supports builtins as __builtin_set_fpscr_rn > which now returns the FPSCR fields in a double. This feature is > available on Power9 when the __SET_FPSCR_RN_RETURNS_FPSCR__ macro > is defined along with __builtin_set_fpscr_rn enabled. > GCC commit ef3bbc69d15707e4db6e2f198c621effb636cc26 adds > this feature. > > Changes are done to use __builtin_set_fpscr_rn instead of mffscrn > or mffscrni in __fe_mffscrn(rn). > > Suggested-by: Carl Love > --- > sysdeps/powerpc/fpu/fenv_libc.h | 23 ++++++++++++++++++++--- > 1 file changed, 20 insertions(+), 3 deletions(-) > > diff --git a/sysdeps/powerpc/fpu/fenv_libc.h b/sysdeps/powerpc/fpu/fenv_libc.h > index fa5e1c697e..55484eb229 100644 > --- a/sysdeps/powerpc/fpu/fenv_libc.h > +++ b/sysdeps/powerpc/fpu/fenv_libc.h > @@ -84,8 +84,15 @@ extern const fenv_t *__fe_mask_env (void) attribute_hidden; > __fr.fenv; \ > }) > > +/* GCC version 14 onwards supports builtins as __builtin_set_fpscr_rn and > + now returns the FPSCR fields in a double. This support is available > + on Power9 when the __SET_FPSCR_RN_RETURNS_FPSCR__ macro is defined. > + To retain backward compatibility with older GCC, we still retain the > + old inline assembly implementation. */ > +#if defined _ARCH_PWR9 && defined __SET_FPSCR_RN_RETURNS_FPSCR__ > +#define fegetenv_and_set_rn(rn) __builtin_set_fpscr_rn (rn) > +#elif defined _ARCH_PWR9 > /* Like fegetenv_control, but also sets the rounding mode. */ > -#ifdef _ARCH_PWR9 > #define fegetenv_and_set_rn(rn) __fe_mffscrn (rn) > #else > /* 'mffscrn' will decode to 'mffs' on ARCH < 3_00, which is still necessary I think the macro would be better defined as: #ifdef __SET_FPSCR_RN_RETURNS_FPSCR__ # define __fe_mffscrn(rn) __builtin_set_fpscr_rn (rn) #else # define __fe_mffscrn(rn) [...] #endif Then there is no need to redefine fegetenv_and_set_rn nor __fesetround_inline. > @@ -148,7 +155,12 @@ typedef union > static inline int > __fesetround_inline (int round) > { > -#ifdef _ARCH_PWR9 > +/* GCC version 14 onwards supports builtins as __builtin_set_fpscr_rn and > + now returns the FPSCR fields in a double. This support is available > + on Power9 when the __SET_FPSCR_RN_RETURNS_FPSCR__ macro is defined. */ > +#if defined _ARCH_PWR9 && defined __SET_FPSCR_RN_RETURNS_FPSCR__ > + __builtin_set_fpscr_rn (round); > +#elif defined _ARCH_PWR9 > __fe_mffscrn (round); > #else > if (__glibc_likely (GLRO(dl_hwcap2) & PPC_FEATURE2_ARCH_3_00)) > @@ -178,7 +190,12 @@ __fesetround_inline (int round) > static inline void > __fesetround_inline_nocheck (const int round) > { > -#ifdef _ARCH_PWR9 > +/* GCC version 14 onwards supports builtins as __builtin_set_fpscr_rn and > + now returns the FPSCR fields in a double. This support is available > + on Power9 when the __SET_FPSCR_RN_RETURNS_FPSCR__ macro is defined. */ > +#if defined _ARCH_PWR9 && defined __SET_FPSCR_RN_RETURNS_FPSCR__ > + __builtin_set_fpscr_rn (round); > +#elif defined _ARCH_PWR9 > __fe_mffscrn (round); > #else > if (__glibc_likely (GLRO(dl_hwcap2) & PPC_FEATURE2_ARCH_3_00))