public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Joseph Myers <joseph@codesourcery.com>
To: Tejas Joshi <tejasjoshi9673@gmail.com>
Cc: <gcc-patches@gcc.gnu.org>, Martin Jambor <mjambor@suse.cz>,
	<hubicka@ucw.cz>
Subject: Re: [PATCH] Builtin function roundeven folding implementation
Date: Fri, 09 Aug 2019 21:26:00 -0000	[thread overview]
Message-ID: <alpine.DEB.2.21.1908092021090.31221@digraph.polyomino.org.uk> (raw)
In-Reply-To: <CACMrGjCu54zN+Smc7+3JF8MBZV76HXwaP-vk1HFTQGhRc=Toww@mail.gmail.com>

On Fri, 28 Jun 2019, Tejas Joshi wrote:

> +    CASE_CFN_ROUNDEVEN:
> +    CASE_CFN_ROUNDEVEN_FN:
> +      if (!REAL_VALUE_ISNAN (*arg) || !flag_errno_math)

Checking flag_errno_math here does not make sense.  roundeven never sets 
errno (at least, TS 18661-1 makes it implementation-defined whether sNaN 
input counts as a domain error, but I'm not aware of implementations that 
make it a domain error and set errno, and typically GCC follows glibc in 
such cases in the absence of known implementations requiring a different 
approach).

The only case where you need to avoid folding is where the argument is a 
signaling NaN (it's fine to fold for quiet NaNs).  In that case, you need 
to avoid folding to avoid losing an exception (if the user cares about 
signaling NaNs, they probably care about exceptions) - so it still doesn't 
matter whether the library implementation also sets errno or not.

(Yes, this means the existing ceil / floor / round checks should be 
adjusted just to check for signaling NaN, though that's fairly cosmetic as 
calls to those functions with quiet NaN argument still get folded via 
match.pd.  trunc ought also check for signaling NaN rather than folding 
unconditionally, so all those functions should end up with the same 
conditions for folding.)

> @@ -898,6 +907,10 @@ fold_const_call_ss (wide_int *result, combined_fn fn,
>        return fold_const_conversion (result, real_round, arg,
>  				    precision, format);
>  
> +    CASE_CFN_ROUNDEVEN:
> +    CASE_CFN_ROUNDEVEN_FN:
> +      return fold_const_conversion (result, real_roundeven, arg, precision, format);
> +

This is the version of fold_const_call_ss for functions returning a result 
of integer type; roundeven returns an integer value in a floating-point 
type.  I don't think this code should be there, and I don't think this 
version of the function should be called at all for roundeven.

-- 
Joseph S. Myers
joseph@codesourcery.com

  parent reply	other threads:[~2019-08-09 20:45 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-28  3:40 Tejas Joshi
2019-07-29 16:49 ` Martin Jambor
2019-08-09 21:26 ` Joseph Myers [this message]
2019-08-14  7:24   ` Tejas Joshi
2019-08-21 11:52     ` Martin Jambor
2019-08-21 12:48       ` Joseph Myers
2019-08-21 19:10         ` Martin Jambor
2019-08-21 20:50           ` Joseph Myers
2019-08-22 14:40             ` Martin Jambor
2019-08-22 15:52               ` Joseph Myers
2019-08-22 21:39                 ` Tejas Joshi
2019-08-23 12:21                   ` Martin Jambor
2019-08-23 21:24                   ` Joseph Myers
2019-08-25 20:28                     ` Tejas Joshi
2020-02-12  6:20                     ` [PATCH] real: Fix roundeven on inf/nan [PR93663] Jakub Jelinek
2020-02-12 20:56                       ` Joseph Myers

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=alpine.DEB.2.21.1908092021090.31221@digraph.polyomino.org.uk \
    --to=joseph@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hubicka@ucw.cz \
    --cc=mjambor@suse.cz \
    --cc=tejasjoshi9673@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).