This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -fwrapv enables some optimizations
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Bruno Haible <bruno at clisp dot org>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 20 Dec 2006 15:50:23 +0000 (UTC)
- Subject: Re: -fwrapv enables some optimizations
- References: <200612201538.30226.bruno@clisp.org>
On Wed, 20 Dec 2006, Bruno Haible wrote:
> But the other way around? Without -fwrapv the compiler can assume more
> about the program being compiled (namely that signed integer overflows
> don't occur), and therefore has more freedom for optimizations. All
> optimizations that are possible with -fwrapv should also be performed
> without -fwrapv. Anything else is a missed optimization.
Indeed. Fixing this may require it to be possible to mark individual
operations with their overflow semantics (which will also be needed for
LTO to handling inlining between translation units compiled with different
options). The problem is that some optimizations involve transforming an
"overflow undefined" operation into an "overflow wraps" one, which is a
valid transformation, but can't be represented in trees at present - but
when the transformation is also valid for the initial operation being an
"overflow wraps" one, the optimization can be done if -fwrapv.
When individual operations can be so marked, the optimizations in question
can then be done if the original operation is either "overflow undefined"
or "overflow wraps".
--
Joseph S. Myers
joseph@codesourcery.com