From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from xry111.site (xry111.site [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id 6D8293858031 for ; Fri, 11 Nov 2022 05:30:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6D8293858031 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=xry111.site Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=xry111.site DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xry111.site; s=default; t=1668144605; bh=4KUlgClJeuDwG8J/ndih5459dHKMCa5QtL/THDcDQbU=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=EIFQi6zEbrMTm88US0zfm24u0/KByYDNcIn0C7QdSOwO3CoNav04TBaFhezsOO5jk KqBkIM32EqqcuUDU6wTMyGiTfCg6xbQ7UrLMx5UKLlDxQ86IgxFDR7fbAOe7dt57cO O82rtQaoULqQxYuEp8i1i3LQb6KMDsTmT5aE3aBI= Received: from [IPv6:240e:358:1199:8c00:dc73:854d:832e:2] (unknown [IPv6:240e:358:1199:8c00:dc73:854d:832e:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 3077366982; Fri, 11 Nov 2022 00:30:01 -0500 (EST) Message-ID: <627e6b6c214322c9d227778f002a931a13f33eeb.camel@xry111.site> Subject: Re: [PATCH v2 2/4] LoongArch: Add ftint{,rm,rp}.{w,l}.{s,d} instructions From: Xi Ruoyao To: Lulu Cheng , Joseph Myers Cc: gcc-patches@gcc.gnu.org, Wang Xuerui , Chenghua Xu , Xiaolin Tang Date: Fri, 11 Nov 2022 13:29:55 +0800 In-Reply-To: References: <20221109135329.952128-1-xry111@xry111.site> <20221109135329.952128-3-xry111@xry111.site> <5c9131fe-4bcb-1713-6716-a3e9930d8580@loongson.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.0 MIME-Version: 1.0 X-Spam-Status: No, score=1.2 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FROM_SUSPICIOUS_NTLD,LIKELY_SPAM_FROM,PDS_OTHER_BAD_TLD,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Lulu: So I think the code is correct: + ( + || flag_fp_int_builtin_inexact + || !flag_trapping_math)" is 1 for lrint, 0 for lceil and lfloor. As N3054 says: The lrint and llrint functions provide floating-to-integer conversion as= prescribed by IEC 60559. They round according to the current rounding direction. If the rounded v= alue is outside the range of the return type, the numeric result is unspecified and the "invalid" flo= ating-point exception is raised. When they raise no other floating-point exception and the result differs= from the argument, they raise the "inexact" floating-point exception. =20 If flag_fp_int_builtin_inexact is set, we allow lceil and lfloor to raise "inexact". If flag_trapping_math is not set (it's set by default and can only be unset explicitly with -fno-trapping-math: it's not even implied by - ffast-math), we don't care about whether exceptions are raised or not. So lceil and lfloor can be used if -ffp-int-builtin-inexact, or -fno- trapping-math. On Fri, 2022-11-11 at 00:07 +0000, Joseph Myers wrote: > On Thu, 10 Nov 2022, Xi Ruoyao via Gcc-patches wrote: >=20 > > Joseph: can you confirm that -ftrapping-math allows floor and ceil to > > raise inexact exception?=C2=A0 The man page currently says: > >=20 > > The default is -ffp-int-builtin-inexact, allowing the exception to be > > raised, unless C2X or a later C standard is selected.=C2=A0 This option= does=C2=A0 > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ^^^^^^^^^^^ > > nothing unless -ftrapping-math is in effect. > >=20 > > To me it's not very clear that "this option" stands for -fno-fp-int- > > builtin-inexact or -ffp-int-builtin-inexact. >=20 > The -ftrapping-math option (which is on by default) means that we care > about whether operations raise exceptions: they should raise exceptions i= f=20 > and only if the relevant standard permit them to do so. >=20 > The combination of -ftrapping-math with -fno-fp-int-builtin-inexact means= =20 > the listed built-in functions must not raise "inexact". >=20 > If -fno-trapping-math is used, then we don't care about whether exception= s=20 > are raised or not (for any floating-point operations, not just those=20 > functions).=C2=A0 So given -fno-trapping-math, there is no difference bet= ween=20 > -fno-fp-int-builtin-inexact and -ffp-int-builtin-inexact. >=20 > If -ffp-int-builtin-inexact (default before C2X), we don't care about=20 > whether those functions raise "inexact" (but still care about other=20 > exceptions and exceptions for other operations, unless=20 > -fno-trapping-math). --=20 Xi Ruoyao School of Aerospace Science and Technology, Xidian University