public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Aldy Hernandez <aldyh@redhat.com>
Cc: gcc-patches@gcc.gnu.org, Andrew MacLeod <amacleod@redhat.com>
Subject: Re: [PATCH] range-op-float: frange_arithmetic tweaks for MODE_COMPOSITE_P
Date: Wed, 7 Dec 2022 16:31:13 +0100	[thread overview]
Message-ID: <Y5Cxwcowiy7Wkmes@tucnak> (raw)
In-Reply-To: <851fe74e-e4da-7151-247d-41da27628b4e@redhat.com>

On Wed, Dec 07, 2022 at 04:21:09PM +0100, Aldy Hernandez wrote:
> On 12/7/22 13:10, Jakub Jelinek wrote:
> > +	      switch (code)
> > +		{
> > +		case PLUS_EXPR:
> > +		case MINUS_EXPR:
> > +		  // ibm-ldouble-format documents 1ulp for + and -.
> > +		  frange_nextafter (DFmode, tmp, inf);
> > +		  break;
> > +		case MULT_EXPR:
> > +		  // ibm-ldouble-format documents 2ulps for *.
> > +		  frange_nextafter (DFmode, tmp, inf);
> > +		  frange_nextafter (DFmode, tmp, inf);
> > +		  break;
> > +		case RDIV_EXPR:
> > +		  // ibm-ldouble-format documents 3ulps for /.
> > +		  frange_nextafter (DFmode, tmp, inf);
> > +		  frange_nextafter (DFmode, tmp, inf);
> > +		  frange_nextafter (DFmode, tmp, inf);
> > +		  break;
> > +		default:
> > +		  if (!inexact)
> > +		    return;
> > +		  break;
> 
> It looks like this chunk...
> 
> 
> > +	switch (code)
> > +	  {
> > +	  case PLUS_EXPR:
> > +	  case MINUS_EXPR:
> > +	    // ibm-ldouble-format documents 1ulp for + and -.
> > +	    frange_nextafter (mode, result, inf);
> > +	    break;
> > +	  case MULT_EXPR:
> > +	    // ibm-ldouble-format documents 2ulps for *.
> > +	    frange_nextafter (mode, result, inf);
> > +	    frange_nextafter (mode, result, inf);
> > +	    break;
> > +	  case RDIV_EXPR:
> > +	    // ibm-ldouble-format documents 3ulps for /.
> > +	    frange_nextafter (mode, result, inf);
> > +	    frange_nextafter (mode, result, inf);
> > +	    frange_nextafter (mode, result, inf);
> > +	    break;
> > +	  default:
> > +	    break;
> > +	  }
> 
> ...is the same as this chunk.  Plus, all this mode composite stuff is

It is not the same, there is the DFmode, tmp vs. mode, result difference.
But sure, we could either add an inline function which for
(code, mode, result, inf) set of options (or (code, DFmode, tmp, inf))
do those 0, 1, 2, 3 frange_nextafter calls (and return bool if it did any
- there is also the if (!inexact) return; case), or as you suggest
perhaps change frange_nextafter to handle MODE_COMPOSITE_P differently
and do there
  if (mode_composite && (real_isdenormal (&result, mode) || real_iszero (&result)))
    {
      // IBM extended denormals only have DFmode precision.
      REAL_VALUE_TYPE tmp;
      real_convert (&tmp, DFmode, &result);
      frange_nextafter (DFmode, tmp, inf);
      real_convert (&result, mode, &tmp);
    }
  else
    frange_nextafter (mode, result, inf);
Though, that somewhat changes behavior, it will convert to DFmode and back
for every nextafter rather than just once (just slower compile time),
but also right now we start from value rather than result.

So, perhaps a combination of that, change frange_nextafter to do the above
and change frange_arithmetic for the initial inexact rounding only to
do it by hand using range_nextafter and starting from value.

Anyway, this patch is far less important than the previous one...

	Jakub


  reply	other threads:[~2022-12-07 15:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07 12:10 Jakub Jelinek
2022-12-07 15:21 ` Aldy Hernandez
2022-12-07 15:31   ` Jakub Jelinek [this message]
2022-12-07 15:38     ` Aldy Hernandez
2022-12-07 16:05       ` [PATCH] range-op-float, v2: " Jakub Jelinek
2022-12-07 17:41         ` Aldy Hernandez

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=Y5Cxwcowiy7Wkmes@tucnak \
    --to=jakub@redhat.com \
    --cc=aldyh@redhat.com \
    --cc=amacleod@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /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).