public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <richard.guenther@gmail.com>
To: Xi Ruoyao <xry111@xry111.site>
Cc: gcc-patches@gcc.gnu.org, chenglulu <chenglulu@loongson.cn>,
	i@xen0n.name,  xuchenghua@loongson.cn,
	Tamar Christina <Tamar.Christina@arm.com>,
	tschwinge@gcc.gnu.org,  Roger Sayle <roger@nextmovesoftware.com>
Subject: Re: [PATCH] Fix (fcopysign x, NEGATIVE_CONST) -> (fneg (fabs x)) simplification [PR112483]
Date: Mon, 13 Nov 2023 07:54:53 +0100	[thread overview]
Message-ID: <CAFiYyc0amUJ_Vwf=jOP1FEegku5AWyJHskVPo-v4LjkrUG75Aw@mail.gmail.com> (raw)
In-Reply-To: <20231112202603.228074-2-xry111@xry111.site>

On Sun, Nov 12, 2023 at 9:27 PM Xi Ruoyao <xry111@xry111.site> wrote:
>
> (fcopysign x, NEGATIVE_CONST) can be simplified to (fneg (fabs x)), but
> a logic error in the code caused it mistakenly simplified to (fneg x)
> instead.

OK.

> gcc/ChangeLog:
>
>         PR rtl-optimization/112483
>         * simplify-rtx.cc (simplify_binary_operation_1) <case COPYSIGN>:
>         Fix the simplification of (fcopysign x, NEGATIVE_CONST).
> ---
>
> Bootstrapped and regtested on loongarch64-linux-gnu and
> x86_64-linux-gnu.  Ok for trunk?
>
>  gcc/simplify-rtx.cc | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc
> index 69d87579d9c..2d2e5a3c1ca 100644
> --- a/gcc/simplify-rtx.cc
> +++ b/gcc/simplify-rtx.cc
> @@ -4392,7 +4392,7 @@ simplify_ashift:
>           real_convert (&f1, mode, CONST_DOUBLE_REAL_VALUE (trueop1));
>           rtx tmp = simplify_gen_unary (ABS, mode, op0, mode);
>           if (REAL_VALUE_NEGATIVE (f1))
> -           tmp = simplify_gen_unary (NEG, mode, op0, mode);
> +           tmp = simplify_gen_unary (NEG, mode, tmp, mode);
>           return tmp;
>         }
>        if (GET_CODE (op0) == NEG || GET_CODE (op0) == ABS)
> --
> 2.42.1
>

  reply	other threads:[~2023-11-13  6:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-12 20:25 Xi Ruoyao
2023-11-13  6:54 ` Richard Biener [this message]
2023-11-13  7:09   ` Tamar Christina
2023-11-13  7:38     ` Xi Ruoyao
2023-11-13  7:39     ` Andrew Pinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFiYyc0amUJ_Vwf=jOP1FEegku5AWyJHskVPo-v4LjkrUG75Aw@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=Tamar.Christina@arm.com \
    --cc=chenglulu@loongson.cn \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=i@xen0n.name \
    --cc=roger@nextmovesoftware.com \
    --cc=tschwinge@gcc.gnu.org \
    --cc=xry111@xry111.site \
    --cc=xuchenghua@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).