From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 2BD673955C88 for ; Wed, 16 Nov 2022 09:17:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2BD673955C88 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn Received: from loongson.cn (unknown [10.20.4.33]) by gateway (Coremail) with SMTP id _____8CxjdqwqnRjNLoHAA--.22290S3; Wed, 16 Nov 2022 17:17:36 +0800 (CST) Received: from [10.20.4.33] (unknown [10.20.4.33]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Dxd1etqnRjhbQUAA--.36824S3; Wed, 16 Nov 2022 17:17:35 +0800 (CST) Subject: Re: [PATCH v2 0/4] LoongArch: Add some floating-point operations To: Xi Ruoyao , libc-alpha@sourceware.org Cc: Lulu Cheng , Wang Xuerui , Chenghua Xu , caiyinyu@loongson.cn References: <20221109135329.952128-1-xry111@xry111.site> <1a465d2a0bea2a47aadaa727c0689ac48d5982c5.camel@xry111.site> <235d9f8e-040c-2917-8444-654b33aa124e@loongson.cn> <3520c6e178315f94e38ce334e66432e4b0ccab2a.camel@xry111.site> From: tangxiaolin Message-ID: Date: Wed, 16 Nov 2022 17:17:33 +0800 User-Agent: Mozilla/5.0 (X11; Linux loongarch64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <3520c6e178315f94e38ce334e66432e4b0ccab2a.camel@xry111.site> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-CM-TRANSID:AQAAf8Dxd1etqnRjhbQUAA--.36824S3 X-CM-SenderInfo: pwdqw5xldrzx3q6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBjvJXoWxuF4DXFWxXw1kZF4kXFykGrg_yoW5Kr4Dpa 9r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YES_00,BODY_8BITS,KAM_DMARC_STATUS,KAM_SHORT,NICE_REPLY_A,SPF_HELO_PASS,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: Thanks a lot. These patches look very good,  honestly I have nothing to add. For lrint and llrint, If you ask my suggestion, I would say adding  USE_LRINTL_BUILTIN and USE_LRINTF128_BUILTIN (with zero value) is better for consistency with other functions like ceil. I did an experiment, 'scalbn' is indeed not easy to deal with, and I don't have a better idea so far.I tend to add inline assembler for this function instead of builtin if you don't have a better idea. What do you think? 在 2022/11/14 下午4:05, Xi Ruoyao 写道: > On Mon, 2022-11-14 at 10:41 +0800, tangxiaolin wrote: >> How about I do this work on Glibc? > [Moving the discussion to libc-alpha.] > > Go for it. I'm attaching my draft patches and you can use them as a > starting point. > > rint change is trivial. for lrint and llrint I'm not sure if we should > add USE_LRINTL_BUILTIN and USE_LRINTF128_BUILTIN (with zero value) as > well. Likewise for logb. > > scalbn is a little complicated: I'd prefer to expand M_SCALBN to > __builtin_scalbn directly instead of calling __scalbn (to avoid the > overhead calling a function with only two instructions) but it seems not > easy: some files calling M_SCALBN are compiled with -fmath-errno, with > which the compiler will refuse to expand __builtin_scalbn. > >> 在 2022/11/12 下午3:08, Xi Ruoyao 写道: >>> On Wed, 2022-11-09 at 21:53 +0800, Xi Ruoyao wrote: >>>> These patches allow to expand the following builtins to floating >>>> point >>>> instructions for LoongArch: >>>> >>>> - __builtin_rint{,f} >>>> - __builtin_{l,ll}rint{,f} >>>> - __builtin_{l,ll}floor{,f} >>>> - __builtin_{l,ll}ceil{,f} >>>> - __builtin_scalb{n,ln}{,f} >>>> - __builtin_logb{,f} >>>> >>>> Bootstrapped and regtested on loongarch64-linux-gnu.  And a >>>> modified >>>> Glibc using the builtins for rint{,f}, {l,ll}rint{,f}, and >>>> logb{,f} >>>> also survived Glibc test suite. >>>> >>>> Please review ASAP because GCC 13 stage 1 will end on Nov. 13th. >>>> >>>> v1 -> v2: Only use ftint{rm,rp} instructions if floor and ceil are >>>> allowed to raise inexact exception. >>>> >>>> Xi Ruoyao (4): >>>>    LoongArch: Rename frint_ to rint2 >>>>    LoongArch: Add ftint{,rm,rp}.{w,l}.{s,d} instructions >>>>    LoongArch: Add fscaleb.{s,d} instructions as ldexp{sf,df}3 >>>>    LoongArch: Add flogb.{s,d} instructions and expand logb{sf,df}2 >>>> >>>>   gcc/config/loongarch/loongarch.md             | 95 >>>> ++++++++++++++++++- >>>>   gcc/testsuite/gcc.target/loongarch/flogb.c    | 18 ++++ >>>>   gcc/testsuite/gcc.target/loongarch/frint.c    | 16 ++++ >>>>   gcc/testsuite/gcc.target/loongarch/fscaleb.c  | 48 ++++++++++ >>>>   .../gcc.target/loongarch/ftint-no-inexact.c   | 44 +++++++++ >>>>   gcc/testsuite/gcc.target/loongarch/ftint.c    | 44 +++++++++ >>>>   6 files changed, 261 insertions(+), 4 deletions(-) >>>>   create mode 100644 gcc/testsuite/gcc.target/loongarch/flogb.c >>>>   create mode 100644 gcc/testsuite/gcc.target/loongarch/frint.c >>>>   create mode 100644 gcc/testsuite/gcc.target/loongarch/fscaleb.c >>>>   create mode 100644 gcc/testsuite/gcc.target/loongarch/ftint-no- >>>> inexact.c >>>>   create mode 100644 gcc/testsuite/gcc.target/loongarch/ftint.c >>>> >>> Pushed r13-3922. >>> >>> I'll be busy in the following week.  Will do the work on Glibc side >>> after Nov. 20. >>>