* [PATCH] Do not allow "x + 0.0" to "x" optimization with -fsignaling-nans
@ 2023-06-19 10:32 Toru Kisuki
2023-06-19 11:41 ` Richard Biener
0 siblings, 1 reply; 4+ messages in thread
From: Toru Kisuki @ 2023-06-19 10:32 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 1063 bytes --]
Hi,
With -O3 -fsignaling-nans -fno-signed-zeros, compiler should not simplify 'x + 0.0' to 'x'.
GCC Bugzilla : Bug 110305
gcc/ChangeLog:
2023-06-19 Toru Kisuki <tkisuki@tachyum.com>
* simplify-rtx.cc (simplify_context::simplify_binary_operation_1):
---
gcc/simplify-rtx.cc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc
index e152918b0f1..cc96b36ad4e 100644
--- a/gcc/simplify-rtx.cc
+++ b/gcc/simplify-rtx.cc
@@ -2698,7 +2698,8 @@ simplify_context::simplify_binary_operation_1 (rtx_code code,
when x is NaN, infinite, or finite and nonzero. They aren't
when x is -0 and the rounding mode is not towards -infinity,
since (-0) + 0 is then 0. */
- if (!HONOR_SIGNED_ZEROS (mode) && trueop1 == CONST0_RTX (mode))
+ if (!HONOR_SIGNED_ZEROS (mode) && !HONOR_SNANS (mode)
+ && trueop1 == CONST0_RTX (mode))
return op0;
/* ((-a) + b) -> (b - a) and similarly for (a + (-b)). These
--
2.38.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Do not allow "x + 0.0" to "x" optimization with -fsignaling-nans
2023-06-19 10:32 [PATCH] Do not allow "x + 0.0" to "x" optimization with -fsignaling-nans Toru Kisuki
@ 2023-06-19 11:41 ` Richard Biener
2023-06-19 17:55 ` Jeff Law
0 siblings, 1 reply; 4+ messages in thread
From: Richard Biener @ 2023-06-19 11:41 UTC (permalink / raw)
To: Toru Kisuki; +Cc: gcc-patches
On Mon, Jun 19, 2023 at 12:33 PM Toru Kisuki via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Hi,
>
>
> With -O3 -fsignaling-nans -fno-signed-zeros, compiler should not simplify 'x + 0.0' to 'x'.
>
OK if you bootstrapped / tested this change.
Thanks,
Richard.
> GCC Bugzilla : Bug 110305
>
>
> gcc/ChangeLog:
>
> 2023-06-19 Toru Kisuki <tkisuki@tachyum.com>
>
> * simplify-rtx.cc (simplify_context::simplify_binary_operation_1):
>
> ---
> gcc/simplify-rtx.cc | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc
> index e152918b0f1..cc96b36ad4e 100644
> --- a/gcc/simplify-rtx.cc
> +++ b/gcc/simplify-rtx.cc
> @@ -2698,7 +2698,8 @@ simplify_context::simplify_binary_operation_1 (rtx_code code,
> when x is NaN, infinite, or finite and nonzero. They aren't
> when x is -0 and the rounding mode is not towards -infinity,
> since (-0) + 0 is then 0. */
> - if (!HONOR_SIGNED_ZEROS (mode) && trueop1 == CONST0_RTX (mode))
> + if (!HONOR_SIGNED_ZEROS (mode) && !HONOR_SNANS (mode)
> + && trueop1 == CONST0_RTX (mode))
> return op0;
>
> /* ((-a) + b) -> (b - a) and similarly for (a + (-b)). These
> --
> 2.38.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Do not allow "x + 0.0" to "x" optimization with -fsignaling-nans
2023-06-19 11:41 ` Richard Biener
@ 2023-06-19 17:55 ` Jeff Law
2023-06-20 5:18 ` Toru Kisuki
0 siblings, 1 reply; 4+ messages in thread
From: Jeff Law @ 2023-06-19 17:55 UTC (permalink / raw)
To: Richard Biener, Toru Kisuki; +Cc: gcc-patches
On 6/19/23 05:41, Richard Biener via Gcc-patches wrote:
> On Mon, Jun 19, 2023 at 12:33 PM Toru Kisuki via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
>>
>> Hi,
>>
>>
>> With -O3 -fsignaling-nans -fno-signed-zeros, compiler should not simplify 'x + 0.0' to 'x'.
>>
>
> OK if you bootstrapped / tested this change.
I'm suspect Toru doesn't have write access. So I went ahead and did and
x86 bootstrap & regression test which passed. The ChangeLog entry
needed fleshing out a bit and fixed a minor whitespace problem in the
patch itself.
Pushed to the trunk.
jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Do not allow "x + 0.0" to "x" optimization with -fsignaling-nans
2023-06-19 17:55 ` Jeff Law
@ 2023-06-20 5:18 ` Toru Kisuki
0 siblings, 0 replies; 4+ messages in thread
From: Toru Kisuki @ 2023-06-20 5:18 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 999 bytes --]
Hi Jeff,
Thank you for taking care of it.
Toru
________________________________
From: Jeff Law <jeffreyalaw@gmail.com>
Sent: Monday, June 19, 2023 7:55 PM
To: Richard Biener; Toru Kisuki
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Do not allow "x + 0.0" to "x" optimization with -fsignaling-nans
[EXTERNAL] Caution: This email originated from outside of the organization.
On 6/19/23 05:41, Richard Biener via Gcc-patches wrote:
> On Mon, Jun 19, 2023 at 12:33 PM Toru Kisuki via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
>>
>> Hi,
>>
>>
>> With -O3 -fsignaling-nans -fno-signed-zeros, compiler should not simplify 'x + 0.0' to 'x'.
>>
>
> OK if you bootstrapped / tested this change.
I'm suspect Toru doesn't have write access. So I went ahead and did and
x86 bootstrap & regression test which passed. The ChangeLog entry
needed fleshing out a bit and fixed a minor whitespace problem in the
patch itself.
Pushed to the trunk.
jeff
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-06-20 5:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-19 10:32 [PATCH] Do not allow "x + 0.0" to "x" optimization with -fsignaling-nans Toru Kisuki
2023-06-19 11:41 ` Richard Biener
2023-06-19 17:55 ` Jeff Law
2023-06-20 5:18 ` Toru Kisuki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).