From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x234.google.com (mail-oi1-x234.google.com [IPv6:2607:f8b0:4864:20::234]) by sourceware.org (Postfix) with ESMTPS id 591BE3858D32 for ; Mon, 16 Jan 2023 14:18:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 591BE3858D32 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-x234.google.com with SMTP id n8so23493565oih.0 for ; Mon, 16 Jan 2023 06:18:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; 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=QhXObj82nBcQEYJAA1ad2r04kCOEU7ksJDCUDcSKqfM=; b=tI6CSUZ00xKAcoJU6fK06ndrKdAPulBob6ZSlrajIa8BTR+1Xyp1sS0TlfpZX5E9qk +cs4oheyV7sr8YUpzCdBPB7RjpVDM4hgG//KZaMw7pNjxUAY1tVEm67vDtj3SdSDkiLg bG9l+QI9xL9XOFYCsjeDX5MIyJ4yoVrKPjgF1+zbbd/cHgDrMXf4AzOetHuSwRKPza8L 7uOFtIWgsvDxFkIA0gJdhO+gnsPpN9CbHZex3dQiloS5kqodQ5ctcxI6z+fbvFnLz7j1 phpz/yo7giantvh4XstzCMeJl0FUBbsnuPWn8bwppaQO3RVQHMgDMJMLdX5pxenWWO66 V09Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=QhXObj82nBcQEYJAA1ad2r04kCOEU7ksJDCUDcSKqfM=; b=3oxPKU9HAkmv3Zepm7xNFm2I/OA135YfMZ9Ks+FcoQBFW5BmE6JMys81+U6VFIeQDG yStg0Ox92SnQ4aIixjQ2aXYN7YXTvmO6331A/DfSWPhdhw9qN172nNXdv35czlaOQkjy uCoEyXVuoG3MYPEr5y3wygw2+EQIAyLuaj6Ck1ED9B76qrKu4nRXHsGps3A+Vh/3WJqQ dprmFdrPfD3SpJ3HcL0QaDNsVLMa41JVLqoCUn4jJ7iWLNgWIRmExa3D+7K3yzQI/BuD MzYKoaXhymmvhLUR+AtAqObD5Ev9QKy2qoilU3cRzgLHRnpl3tYXQyg8ne/FHFBIXhdM VuXA== X-Gm-Message-State: AFqh2kqHBeNI93nSmYw6/7h0s2GGvsAiyQLPy/X+vAsSaUbjFhYQuG/Q gNeTiWFjpvAqiqqHZYe9Sn7hrQ== X-Google-Smtp-Source: AMrXdXt5Y9rnGnK2jQgoDuMD7ftHG31yjnqkT68npF4s6OTj6xY9XkGWS94On/TyZDa1XCCQvXgE3w== X-Received: by 2002:a05:6808:120d:b0:364:9e70:2d77 with SMTP id a13-20020a056808120d00b003649e702d77mr8126360oil.20.1673878708565; Mon, 16 Jan 2023 06:18:28 -0800 (PST) Received: from ?IPV6:2804:1b3:a7c1:1652:49fa:2dd7:dbd:38f6? ([2804:1b3:a7c1:1652:49fa:2dd7:dbd:38f6]) by smtp.gmail.com with ESMTPSA id r42-20020a056808212a00b00364e8f85c08sm2368092oiw.21.2023.01.16.06.18.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 16 Jan 2023 06:18:27 -0800 (PST) Message-ID: <882721d2-adb1-1cbd-cd06-d7902dc9d2e7@linaro.org> Date: Mon, 16 Jan 2023 11:18:25 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH] ARC:fpu: add extra capability check before use of sqrt and fma builtins Content-Language: en-US To: Pavel.Kozlov@synopsys.com, libc-alpha@sourceware.org Cc: linux-snps-arc@lists.infradead.org References: <20221221162849.12301-1-kozlov@synopsys.com> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <20221221162849.12301-1-kozlov@synopsys.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.9 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 21/12/22 13:28, Pavel.Kozlov--- via Libc-alpha wrote: > From: Pavel Kozlov > > Add extra check for compiler definitions to ensure that compiler provides > sqrt and fma hw fpu instructions else use software implementation. > > As divide/sqrt and FMA hw support from CPU side is optional, > the compiler can be configured by options to generate hw FPU instructions, > but without use of FDDIV, FDSQRT, FSDIV, FSSQRT, FDMADD and FSMADD > instructions. In this case __builtin_sqrt and __builtin_sqrtf provided by > compiler can't be used inside the glibc code, as these builtins are used > in implementations of sqrt() and sqrtf() functions but at the same time > these builtins unfold to sqrt() and sqrtf(). So it is possible to receive > code like that: > > 0001c4b4 <__ieee754_sqrtf>: > 1c4b4: 0001 0000 b 0 ;1c4b4 <__ieee754_sqrtf> > > The same is also true for __builtin_fma and __builtin_fmaf. > --- > sysdeps/arc/fpu/math-use-builtins-fma.h | 14 ++++++++++++-- > sysdeps/arc/fpu/math-use-builtins-sqrt.h | 14 ++++++++++++-- > 2 files changed, 24 insertions(+), 4 deletions(-) > > diff --git a/sysdeps/arc/fpu/math-use-builtins-fma.h b/sysdeps/arc/fpu/math-use-builtins-fma.h > index eede75aa41be..082badf48201 100644 > --- a/sysdeps/arc/fpu/math-use-builtins-fma.h > +++ b/sysdeps/arc/fpu/math-use-builtins-fma.h > @@ -1,4 +1,14 @@ > -#define USE_FMA_BUILTIN 1 > -#define USE_FMAF_BUILTIN 1 > +#if defined __ARC_FPU_DP_DIV__ > +# define USE_SQRT_BUILTIN 1 > +#else > +# define USE_SQRT_BUILTIN 0 > +#endif > + > +#if defined __ARC_FPU_SP_DIV__ > +# define USE_SQRTF_BUILTIN 1 > +#else > +# define USE_SQRTF_BUILTIN 0 > +#endif > + > #define USE_FMAL_BUILTIN 0 > #define USE_FMAF128_BUILTIN 0 This is wrong, sqrt use macro do not belong for the fma switch file. > diff --git a/sysdeps/arc/fpu/math-use-builtins-sqrt.h b/sysdeps/arc/fpu/math-use-builtins-sqrt.h > index e94c915ba66a..a449bc609295 100644 > --- a/sysdeps/arc/fpu/math-use-builtins-sqrt.h > +++ b/sysdeps/arc/fpu/math-use-builtins-sqrt.h > @@ -1,4 +1,14 @@ > -#define USE_SQRT_BUILTIN 1 > -#define USE_SQRTF_BUILTIN 1 > +#if defined __ARC_FPU_DP_DIV__ > +# define USE_SQRT_BUILTIN 1 > +#else > +# define USE_SQRT_BUILTIN 0 > +#endif > + > +#if defined __ARC_FPU_SP_DIV__ > +# define USE_SQRTF_BUILTIN 1 > +#else > +# define USE_SQRTF_BUILTIN 0 > +#endif > + > #define USE_SQRTL_BUILTIN 0 > #define USE_SQRTF128_BUILTIN 0 This is ok.