public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Guenther <rguenther@suse.de>
To: "Joseph S. Myers" <joseph@codesourcery.com>
Cc: Geert Bosch <bosch@adacore.com>,
		Diego Novillo <dnovillo@google.com>,
	gcc@gcc.gnu.org
Subject: Re: New no-undefined-overflow branch
Date: Fri, 06 Mar 2009 14:10:00 -0000	[thread overview]
Message-ID: <alpine.LNX.2.00.0903061458450.10965@zhemvz.fhfr.qr> (raw)
In-Reply-To: <Pine.LNX.4.64.0903061341520.24198@digraph.polyomino.org.uk>

On Fri, 6 Mar 2009, Joseph S. Myers wrote:

> On Fri, 6 Mar 2009, Richard Guenther wrote:
> 
> > There is of course the problem that we have to be careful not to
> > introduce new traps via folding, a problem that doesn't exist with
> > the no-overflow variants (I can simply drop to the wrapping variants).
> > With for example  (a -/v 10) +/v 10 would you want to preserve
> > the possibly trapping a -/v 10?  For (a -/v 10) +/v (b -/v 10) do
> > we want to be careful to not introduce extra traps when simplifying
> > to (a +/v b) -/v 20?
> 
> I think we should preserve the property of whether the code evaluated 
> between sequence points causes no traps, or at least one trap.  (But need 
> not preserve the difference between one trap and two, for example.  This 
> is the same as C99 Annex F requirements for floating-point exceptions: the 
> set of exceptions produced between calls to fenv.h functions checking or 
> modifying exception state needs to be preserved, but not the number (> 0) 
> of times each exception is produced.)

That sounds sensible.  Of course we don't know about sequence points
during folding (as that may get trees combined from several GIMPLE
statements).

> This probably means that most folding should not apply to trapping 
> variants.

Indeed.

> (In principle I believe folding should be done on GIMPLE rather than 
> folding functions being called from the front ends on trees.  If you do 
> always lower to explicit overflow checks and only run folding after that 
> lowering stage, the problem of changing whether a trap occurs does not 
> arise.  But with trapping variants in GIMPLE, the folding code would still 
> need to allow for them even with folding all happening on GIMPLE.)

Yes.

> > So while trapping variants can certainly be introduced it looks like
> > this task may be more difficult.  So lowering them early during
> > gimplification looks like a more reasonable plan IMHO.
> 
> If you lower to whatever forms of checks for overflow can be conveniently 
> expressed in GIMPLE then you have the interesting problem of 
> reconstituting trapping operations for those targets that have trapping 
> instructions or instructions setting overflow flags that can be checked 
> directly.  It's possible that you want to lower to explicit overflow 
> checks for targets without the operations, but to trapping operation codes 
> for targets with the operations.  (Which would suggest starting with 
> trapping variants, and then lowering to explicit checks part way through 
> the GIMPLE optimizations, only on targets without suitable instructions 
> for the relevant type precision and depending on -Os to determine whether 
> inline code or libgcc function calls might be better.)

Ok, I didn't think of generating optimal code for the overflow checks,
but it should be reasonably possible to if-convert the explicit
overflow checks back to builtins that can be specially expanded
(that would also help explicit overflow checks in source code).

So my opinion still holds that explicit overflow checks would be
prefered.

Richard.

  reply	other threads:[~2009-03-06 14:02 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-26 11:05 Richard Guenther
2009-02-26 11:28 ` Manuel López-Ibáñez
2009-02-26 12:02   ` Richard Guenther
2009-02-26 13:07 ` Joseph S. Myers
2009-02-26 13:22   ` Richard Guenther
2009-02-26 14:16 ` Dave Korn
2009-02-26 23:08 ` Zdenek Dvorak
2009-02-27 10:16   ` Richard Guenther
2009-02-27 12:07     ` Dave Korn
2009-02-27 13:17       ` Richard Guenther
2009-02-27 13:35         ` Dave Korn
2009-02-27 13:45           ` Richard Guenther
2009-02-27 18:07       ` Zdenek Dvorak
2009-02-27 17:58     ` Zdenek Dvorak
2009-02-27 18:17       ` Richard Guenther
2009-02-27 23:07 ` Diego Novillo
2009-02-28  0:04   ` Joseph S. Myers
2009-02-28 10:29     ` Richard Guenther
2009-03-05 17:24       ` Geert Bosch
2009-03-06 12:28         ` Richard Guenther
2009-03-06 13:54           ` Joseph S. Myers
2009-03-06 14:10             ` Richard Guenther [this message]
2009-03-06 14:29               ` Joseph S. Myers
2009-03-06 17:17                 ` Geert Bosch
2009-03-06 17:42                   ` Joseph S. Myers
2009-03-06 14:44           ` Paolo Bonzini
2009-03-06 15:10             ` Richard Guenther
2009-03-06 15:23               ` Paolo Bonzini
2009-03-06 15:39                 ` Paolo Bonzini
2009-03-06 16:19                 ` Richard Guenther
2009-03-06 17:23                   ` Joseph S. Myers
2009-03-06 18:54                 ` Richard Earnshaw
2009-03-06 19:53                   ` Ian Lance Taylor
2009-03-06 20:42                     ` Robert Dewar
     [not found]                 ` <1236364189.1654.2.camel@pc960.cambridge.arm.com>
2009-03-06 19:34                   ` Paolo Bonzini
2009-03-06 15:58               ` Ian Lance Taylor
2009-03-06 17:25             ` Joseph S. Myers
2009-03-06 17:52               ` Paolo Bonzini
2009-03-06 18:36                 ` Joseph S. Myers
2009-03-27 13:11             ` Eus
2009-03-27 18:07               ` Paolo Bonzini
2009-03-31  4:55                 ` Eus
2009-03-06 17:21           ` Geert Bosch
2009-03-06 17:38             ` Joseph S. Myers
2009-03-06 18:47               ` Paolo Bonzini
2009-03-07  3:00                 ` Joseph S. Myers
2009-03-06 22:46               ` Geert Bosch
2009-03-07  1:21                 ` Richard Guenther
2009-02-28 10:25   ` Richard Guenther
2009-02-27 19:58 Jay Foad
2009-02-27 22:41 ` Richard Guenther
2009-02-27 23:00 ` Ian Lance Taylor

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.LNX.2.00.0903061458450.10965@zhemvz.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=bosch@adacore.com \
    --cc=dnovillo@google.com \
    --cc=gcc@gcc.gnu.org \
    --cc=joseph@codesourcery.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).