public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* New no-undefined-overflow branch
@ 2009-02-26 11:05 Richard Guenther
  2009-02-26 11:28 ` Manuel López-Ibáñez
                   ` (4 more replies)
  0 siblings, 5 replies; 52+ messages in thread
From: Richard Guenther @ 2009-02-26 11:05 UTC (permalink / raw)
  To: gcc


There have been numerous issues in the past with respect to the
undefinedness of signed overflow in our IL, with the non-semantics
of sizetype and friends and with the pessimization of using
unsigned arithmetic vs. signed arithmetic in loop optimizations.

The goal of the no-undefined-overflow branch is to address all
these problems by tackling the single worst problem, imposing

  There shall be no construct in the GIMPLE IL that invokes
  undefined behavior.

Thus, from now on integer overflow is defined and will wrap with
the usual twos-complement semantics.  Thus, for the middle-end
-fwrapv is always in effect.  This extends to pointer overflow.

To support languages that have undefined semantics on overflowing
operations the middle-end gets new unary and binary operators
that implicitly encode value-range information about their operands
noting that the operation does not overflow.  These does-not-overflow
operators transform the undefined behavior into a valid assumption
and thus make the GIMPLE IL fully defined.

Thus it is now up to the frontend(s) and value-range analysis to
figure out if operations overflow and accordingly change the IL
to retain optimizations that were possible before.

As a start there will be no-overflow variants of NEGATE_EXPR,
PLUS_EXPR, MINUS_EXPR, MULT_EXPR and POINTER_PLUS_EXPR.

The sizetypes will simply be operated on in no-overflow variants
by default (by size_binop and friends).

Naming suggestions welcome, at the moment I consider NEGATEV_EXPR
(thus appending V to the first part).

Richard.

^ permalink raw reply	[flat|nested] 52+ messages in thread
* Re: New no-undefined-overflow branch
@ 2009-02-27 19:58 Jay Foad
  2009-02-27 22:41 ` Richard Guenther
  2009-02-27 23:00 ` Ian Lance Taylor
  0 siblings, 2 replies; 52+ messages in thread
From: Jay Foad @ 2009-02-27 19:58 UTC (permalink / raw)
  To: rguenther; +Cc: gcc

> To support languages that have undefined semantics on overflowing
> operations the middle-end gets new unary and binary operators
> that implicitly encode value-range information about their operands
> noting that the operation does not overflow.  These does-not-overflow
> operators transform the undefined behavior into a valid assumption
> and thus make the GIMPLE IL fully defined.

From an optimisation pass's point of view, what's the difference between:

1. a PLUS expression that gives an undefined result on overflow, and
2. a PLUS expression with a guarantee that the result won't overflow.

I can't see how they will be handled any differently in practice.

Thanks,
Jay.

^ permalink raw reply	[flat|nested] 52+ messages in thread

end of thread, other threads:[~2009-03-31  3:05 UTC | newest]

Thread overview: 52+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-26 11:05 New no-undefined-overflow branch 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
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

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).