public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: liuhongt <hongtao.liu@intel.com>
To: gcc-patches@gcc.gnu.org
Cc: joseph@codesourcery.com, richard.guenther@gmail.com
Subject: [PATCH] Add !flag_signaling_nans to simplifcation: (trunc)copysign((extend)a, (extend)b) to copysign (a, b).
Date: Fri,  5 Nov 2021 10:20:24 +0800	[thread overview]
Message-ID: <20211105022024.27921-1-hongtao.liu@intel.com> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2111041828480.2137366@digraph.polyomino.org.uk>

> Note that this is not safe with -fsignaling-nans, so needs to be disabled
> for that option (if there isn't already logic somewhere with that effect),
> because the extend will convert a signaling NaN to quiet (raising
> "invalid"), but copysign won't, so this transformation could result in a
> signaling NaN being wrongly returned when the original code would never
> have returned a signaling NaN.
>
> --
> Joseph S. Myers
> joseph@codesourcery.com

Bootstrapped and regtested on x86_64-linux-gnu{-m32,}.
Ok for trunk?

gcc/ChangeLog

	* match.pd
	(Simplifcation (trunc)copysign((extend)a, (extend)b) to
	.COPYSIGN (a, b)): Add !flag_signaling_nans.
---
 gcc/match.pd | 1 +
 1 file changed, 1 insertion(+)

diff --git a/gcc/match.pd b/gcc/match.pd
index fb1065dc0e6..d6a8dd0dd20 100644
--- a/gcc/match.pd
+++ b/gcc/match.pd
@@ -6176,6 +6176,7 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT)
  (simplify
   (convert (copysigns (convert@2 @0) (convert @1)))
    (if (optimize
+       && !flag_signaling_nans
        && types_match (type, TREE_TYPE (@0))
        && types_match (type, TREE_TYPE (@1))
        && TYPE_PRECISION (type) < TYPE_PRECISION (TREE_TYPE (@2))
-- 
2.18.1


  reply	other threads:[~2021-11-05  2:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-04  6:45 [PATCH 1/2] [Middle-end] Simplify (trunc)copysign((extend)a, (extend)b) to .COPYSIGN " liuhongt
2021-11-04  6:45 ` [PATCH 2/2] [i386] Extend vternlog define_insn_and_split to memory_operand to enable more optimziation liuhongt
2021-11-04  7:47 ` [PATCH 1/2] [Middle-end] Simplify (trunc)copysign((extend)a, (extend)b) to .COPYSIGN (a,b) Richard Biener
2021-11-04 18:32 ` [PATCH 1/2] [Middle-end] Simplify (trunc)copysign((extend)a, (extend)b) to .COPYSIGN (a, b) Joseph Myers
2021-11-05  2:20   ` liuhongt [this message]
2021-11-05  9:48     ` [PATCH] Add !flag_signaling_nans to simplifcation: (trunc)copysign((extend)a, (extend)b) to copysign " Richard Biener

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=20211105022024.27921-1-hongtao.liu@intel.com \
    --to=hongtao.liu@intel.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=joseph@codesourcery.com \
    --cc=richard.guenther@gmail.com \
    /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).