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 8F6CF395A04F for ; Wed, 16 Nov 2022 13:00:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8F6CF395A04F 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 _____8DxPdkB33Rjz9AHAA--.22697S3; Wed, 16 Nov 2022 21:00:50 +0800 (CST) Received: from [10.20.4.33] (unknown [10.20.4.33]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Bxj+AB33RjQ9wUAA--.54854S3; Wed, 16 Nov 2022 21:00:49 +0800 (CST) From: tangxiaolin 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> Message-ID: <040b20f8-c94c-859e-34c5-fe4e0eef4da5@loongson.cn> Date: Wed, 16 Nov 2022 21:00:49 +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:AQAAf8Bxj+AB33RjQ9wUAA--.54854S3 X-CM-SenderInfo: pwdqw5xldrzx3q6o00pqjv00gofq/ X-Coremail-Antispam: 1Uk129KBjvJXo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y3UUUUU== X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_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: I notice that use __builtin_lrint to expand __lrint to:          ftint.l.d       $fa0, $fa0          movfr2gr.d      $a0, $fa0          jirl            $zero, $ra, 0 Operations of 'ftint.l.d'  is convertToIntegerExactTiesToEven(x)/ convertToIntegerExactTowardZero(x)/ convertToIntegerExactTowardPositive(x)/convertToIntegerExactTowardNegative(x) according to FCSR RM(LoongArch Manual). However, the operation of function rint, lrint, llrint is roundToIntegralExact according to  ISO/IEC TS 18661-1: 2014 and The GNU C Library Reference Manual. It's a little bit difference between those two operations, but we still can pass all testcases so far. I'm a little worried about it.(As we know that operations of  'frint.{d,s}' is exactly roundToIntegralExact, however we discard it.) 在 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. >>>