public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alexandre Oliva <aoliva@redhat.com>
To: "Dave Korn" <dave.korn@artimi.com>
Cc: "'Robert Dewar'" <dewar@adacore.com>,
	<Theodore.Papadopoulo@sophia.inria.fr>,
	"'Michael Veksler'" <VEKSLER@il.ibm.com>, <gcc@gcc.gnu.org>
Subject: Re: The utility of standard's semantics for overflow
Date: Fri, 01 Jul 2005 18:30:00 -0000	[thread overview]
Message-ID: <orhdfecrc2.fsf@livre.redhat.lsd.ic.unicamp.br> (raw)
In-Reply-To: <SERRANOBWFXbEJSGdvy0000029b@SERRANO.CAM.ARTIMI.COM>

On Jun 29, 2005, "Dave Korn" <dave.korn@artimi.com> wrote:

>   In fact, doesn't this suggest that in _most_ circumstances, *saturation*
> would be the best behaviour?

If that's for user-introduced overflows, it could be useful in some
cases, but I wouldn't go as far as `most'.

For compiler-introduced overflows (e.g., re-association), wrap
semantics enable some optimizations that you just couldn't perform
otherwise.  Consider the already-mentioned example:

  (a + b) + c

if you re-group this as:

  a + (b + c)

and `b + c' overflows, and then the addition with a underflows, that's
not a problem, since modulo semantics will give you the correct
result.

Turning:

  a * b + a * c

into

  a * (b + c)

might be a problem should b + c overflow, but if you use modulo
semantics, you'll always get the correct result for cases in which
none of the original operations overflowed.


What you must be careful to avoid, however, is deriving further
assumptions from `(b + c) does not overflow'.  Since it's a
compiler-introduced operation in both cases, that's only valid if you
can assume modulo semantics, assuming it doesn't overflow will lead
you to wrong conclusions.

-- 
Alexandre Oliva         http://www.lsd.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}

      parent reply	other threads:[~2005-07-01 18:30 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-29  8:33 Michael Veksler
2005-06-29  8:42 ` Robert Dewar
2005-06-29  9:04   ` Michael Veksler
2005-06-29  9:18     ` Robert Dewar
2005-06-29  8:48 ` Eric Botcazou
2005-06-29 11:16   ` Michael Veksler
2005-06-29 16:19     ` Eric Botcazou
2005-06-29  9:47 ` Theodore Papadopoulo
2005-06-29 12:14   ` Robert Dewar
2005-06-29 13:12     ` Dave Korn
2005-06-29 13:35       ` Robert Dewar
2005-06-29 18:37       ` Olivier Galibert
2005-07-01 18:22         ` Alexandre Oliva
2005-07-01 18:30       ` Alexandre Oliva [this message]

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=orhdfecrc2.fsf@livre.redhat.lsd.ic.unicamp.br \
    --to=aoliva@redhat.com \
    --cc=Theodore.Papadopoulo@sophia.inria.fr \
    --cc=VEKSLER@il.ibm.com \
    --cc=dave.korn@artimi.com \
    --cc=dewar@adacore.com \
    --cc=gcc@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).