[Bug middle-end/38204] PRE for post dominating expressions
davidxl at gcc dot gnu dot org
gcc-bugzilla@gcc.gnu.org
Sat Nov 22 00:36:00 GMT 2008
------- Comment #3 from davidxl at gcc dot gnu dot org 2008-11-22 00:35 -------
(In reply to comment #2)
> (In reply to comment #0)
> > For this function:
> > int test (int a, int b, int c, int g)
> > {
> > int d, e;
> > if (a)
> > d = b * c;
> > else
> > d = b - c;
> > e = b * c + g;
> > return d + e;
> > }
> >
> > the multiply expression is moved to both branches of the "if", it would be
> > better to move it before the "if". Intel's compiler does that.
> >
>
> Moving it before the if is a code size optimization that also happens to extend
> the lifetime of the multiply.
> So "better" is a relative term.
>
As a side note:
PRE is made aware of the impact of code size bloat and is -Os friendly. for
instance, if multiple insertions are needed, the PRE won't happen with -Os.
if (..)
expr
else if (..)
...
else if (..)
...
else
...
expr
While this is good, if hoisting opportunities exposed by PRE is materialized,
this PRE should still be allowed under -Os.
(-Os in gcc is not well tuned -- many optimizations are simply turned off in
fear of code bloat without analysis -- the end result is often lost
opportunities for code clean up --> end up with a slower and BIGGer binary).
The hoisting increase tmp life time slightly, but it also adds more scheduling
freedom as a good effect.
David
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=38204
More information about the Gcc-bugs
mailing list