------- Additional Comments From kazu at cs dot umass dot edu 2005-01-22 18:34
-------
This is what I get at the end of tree-ssa optimizations.
foo (flag)
{
int D.1318;
_Bool D.1317;
<bb 0>:
D.1317_2 = *flag_1;
if (D.1317_2 != 0) goto <L0>; else goto <L1>;
<L0>:;
bar ();
<L1>:;
D.1317_4 = *flag_1;
if (D.1317_4 != 0) goto <L2>; else goto <L3>;
<L2>:;
bar () [tail call];
<L3>:;
return;
}
Note that the load immediately after <L1>:; is partially redundant.
I remember Daniel Berlin saying that if PRE is extended to handle
partially redundant load, we can remove the load on one path
to <L1> like so:
<L0>:;
bar ();
D.1317_5 = *flag_1;
D.1317_4 = PHI <D.1317_2(...), D.1317_5(...)>
<L1>:;
if (D.1317_4 != 0) goto <L2>; else goto <L3>;
At this point, DOM can thread one of the incoming edges to <L1>.
One problem is that PRE will probably be still disabled under -Os
when it is extended to handle partially redundant loads even though
PRE would improve this particular case.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19516