public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Nathan Sidwell <nathan@codesourcery.com>
To: Fergus Henderson <fjh@cs.mu.OZ.AU>
Cc: Roger Sayle <roger@www.eyesopen.com>,
	Richard Kenner <kenner@vlsi1.ultra.nyu.edu>,
	gcc-patches@gcc.gnu.org, gcc@gcc.gnu.org
Subject: Re: [PATCH] Document arithmetic overflow semantics
Date: Fri, 14 Feb 2003 00:11:00 -0000	[thread overview]
Message-ID: <3E4C24F6.4050009@codesourcery.com> (raw)
In-Reply-To: <20030213182746.GA15624@ceres.cs.mu.oz.au>

Fergus Henderson wrote:

> Optimizers are only paralyzed by such semantics (undefined behaviour on
> overflow) if it occurs in their *target* language, and can't be avoided.
> If it occurs in their *source* language, then it is a boon for the optimizer.
> 
> Of course, many optimizations are done as tree->tree or RTL->RTL passes;
> In that case, the target is the same as the source, and so such semantics
> can both help (in some cases) and hinder (in others), if the
thank you, I finally understand what this discussion is all about.

> One way to get the best of both words is to provide bits on each
> operation specifying the behaviour on overflow.  The optimizer
> can then convert operations with undefined behaviour into
> operations with defined behavior if this helps it optimize.
> 
> Let me give an example.
> Suppose we denote the three variants of "+" as follows:
> 
> 	+undef		undefined behaviour on overflow
> 	+wrap		wraps on overflow
> 	+trap		traps on overflow
This makes sense. I think you need
	op this_never_overflows
	op dont_care
	op modulo
	op trap
	op saturate (maybe).

optimizers are thus free to convert the first two into the final three. They
are also know that input values must be bounded such that the first one never
overflows.

> This is why I think it would be much better to specify the overflow behaviour
> by using flag bits on the operations, rather than on the types.
FWIW, I concur.

nathan
-- 
Nathan Sidwell    ::   http://www.codesourcery.com   ::     CodeSourcery LLC
          The voices in my head said this was stupid too
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org


  parent reply	other threads:[~2003-02-13 23:06 UTC|newest]

Thread overview: 102+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-13 13:24 Richard Kenner
2003-02-13 14:44 ` Roger Sayle
2003-02-13 18:39   ` Fergus Henderson
2003-02-13 19:05     ` Joe Buck
2003-02-14 13:52       ` Richard Earnshaw
2003-02-13 22:37     ` Richard Henderson
2003-02-13 22:54       ` Roger Sayle
2003-02-13 22:56       ` David Carlton
2003-02-14  0:11     ` Nathan Sidwell [this message]
2003-02-14  7:20       ` Fergus Henderson
2003-02-14 13:58         ` Geert Bosch
2003-02-14 18:59           ` Joseph S. Myers
2003-02-14 19:37         ` Joseph S. Myers
2003-02-13 16:04 ` Joe Buck
2003-02-13 16:22   ` Richard Earnshaw
2003-02-13 21:47 ` Florian Weimer
2003-02-13 14:57 Richard Kenner
2003-02-13 14:58 ` Gabriel Dos Reis
2003-02-13 15:26 ` Roger Sayle
2003-02-13 16:42   ` Joseph S. Myers
2003-02-13 17:58   ` Richard Henderson
2003-02-13 18:16     ` Roger Sayle
2003-02-13 19:46   ` Erik Trulsson
2003-02-13 15:23 Richard Kenner
2003-02-13 15:33 Richard Kenner
2003-02-13 15:36 ` Gabriel Dos Reis
2003-02-13 15:45 ` Roger Sayle
2003-02-13 15:35 Richard Kenner
2003-02-13 15:57 ` Roger Sayle
2003-02-13 15:45 Richard Kenner
2003-02-13 15:52 Richard Kenner
2003-02-13 16:03 ` Roger Sayle
2003-02-13 15:58 Richard Kenner
2003-02-13 16:10 ` Roger Sayle
2003-02-13 17:05   ` Joseph S. Myers
2003-02-13 18:05   ` Richard Henderson
2003-02-13 18:15     ` Richard Earnshaw
2003-02-13 19:03       ` Richard Henderson
2003-02-13 18:25     ` Roger Sayle
2003-02-13 18:44       ` Andrew Haley
2003-02-13 19:06       ` Richard Henderson
2003-02-13 16:09 Richard Kenner
2003-02-13 16:09 Richard Kenner
2003-02-13 17:49 ` Joe Buck
2003-02-13 16:21 Richard Kenner
2003-02-13 17:59 ` Roger Sayle
2003-02-13 17:54 Richard Kenner
2003-02-13 18:21 Robert Dewar
2003-02-13 22:04 ` Florian Weimer
2003-02-13 23:03   ` Joseph S. Myers
2003-02-15 20:52     ` Mark Hahn
2003-02-15 21:15       ` Neil Booth
2003-02-13 18:29 Richard Kenner
2003-02-13 18:56 ` Roger Sayle
2003-02-13 19:07   ` Joe Buck
2003-02-13 18:29 Richard Kenner
2003-02-13 18:33 Richard Kenner
2003-02-13 18:50 Robert Dewar
2003-02-13 18:53 Robert Dewar
2003-02-13 18:54 Robert Dewar
2003-02-13 18:58 Robert Dewar
2003-02-13 19:04 ` Andrew Haley
2003-02-13 20:55 ` Neil Booth
2003-02-13 21:10   ` Gabriel Dos Reis
2003-02-14  4:45     ` Phil Edwards
2003-02-14  8:46     ` Diego Novillo
2003-02-13 19:03 Richard Kenner
2003-02-13 19:08 Robert Dewar
2003-02-13 19:23 ` Fergus Henderson
2003-02-13 19:32 ` Andrew Haley
2003-02-13 19:10 Robert Dewar
2003-02-14  8:00 ` Fergus Henderson
2003-02-14  8:44   ` Fergus Henderson
2003-02-14 17:29     ` Michael S. Zick
2003-02-13 19:19 Robert Dewar
2003-02-13 19:56 ` Fergus Henderson
2003-02-13 19:22 Robert Dewar
2003-02-13 19:47 ` Joe Buck
2003-02-13 19:31 Robert Dewar
2003-02-13 19:42 Robert Dewar
2003-02-13 19:59 Robert Dewar
2003-02-13 20:14 Robert Dewar
2003-02-13 20:35 Robert Dewar
2003-02-13 20:41 Robert Dewar
2003-02-13 21:01 Chris Lattner
2003-02-14  8:17 ` Marcel Cox
2003-02-14 18:23   ` Joe Buck
2003-02-14 18:51     ` Nathan Sidwell
2003-02-13 21:14 Robert Dewar
2003-02-14  4:48 Robert Dewar
2003-02-14  5:57 Robert Dewar
2003-02-14  6:43 ` Chris Lattner
2003-02-14 18:14 ` Joe Buck
2003-02-14 14:14 Richard Kenner
2003-02-14 14:24 Robert Dewar
2003-02-16  5:52 ` Segher Boessenkool
2003-02-14 14:58 Richard Kenner
2003-02-14 15:26 Robert Dewar
2003-02-16 16:17 Robert Dewar
2003-02-18  6:41 ` Segher Boessenkool
2003-02-18  6:49   ` Fergus Henderson
2003-02-18 18:13   ` Joe Buck

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=3E4C24F6.4050009@codesourcery.com \
    --to=nathan@codesourcery.com \
    --cc=fjh@cs.mu.OZ.AU \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=gcc@gcc.gnu.org \
    --cc=kenner@vlsi1.ultra.nyu.edu \
    --cc=roger@www.eyesopen.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).