GVN may be expensive, but for a release build, execution time is more important than build time for releases. This fact is noted in my proposal: the ProposePass function can decide if it will allow a further GVN or not. ProposePass can decide to run every other pass before running into a new GVN. ProposePass can ensure, that GVN is not called twice in a -O2 or -O1 build.<br>
In my profilings, I noted that llc needs about 45% of the total compilation time while opt needs 33%. In the testcase i worked with, I was able to shrink the code size to 30% (to, not by!). This means less data passed to the code generator and btw a faster compiler, too when compiled with clang.<br>
<br><div class="gmail_quote">2011/12/2 Eli Friedman <span dir="ltr"><<a href="mailto:eli.friedman@gmail.com">eli.friedman@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5">On Fri, Dec 2, 2011 at 11:56 AM, Carl-Philip Hänsch<br>
<<a href="mailto:cphaensch@googlemail.com">cphaensch@googlemail.com</a>> wrote:<br>
> While trying to find a solution for this bug<br>
> <a href="http://llvm.org/bugs/show_bug.cgi?id=11235" target="_blank">http://llvm.org/bugs/show_bug.cgi?id=11235</a> ,<br>
> I came to the conclusion that the following things can happen while<br>
> optimizing:<br>
>  - after gvn, I get new constants which are inserted into br and<br>
> add/sum/..., so there should be at least one more jump-threading and/or<br>
> instsimplify<br>
>  - after instsimplify, I get new constants which are inserted into br, so<br>
> there should be one more jump-threading pass<br>
>  - after jump-threading, new bigger blocks occur with redundant loads which<br>
> need an other gvn pass<br>
><br>
> At least for -O3 we will need those optimizations.<br>
> Is there a kind of "I need at least one more $XYZ pass" call that can be<br>
> invoked from a Pass?<br>
><br>
> So my suggestion to implement in LLVM is:<br>
>  - Detect where exactly constants are inserted<br>
>  - Detect which pass is responsible to continue folding it<br>
>  - Insert that pass if allowed and if it is not in the queue by a<br>
> ProposePass function<br>
><br>
> ProposePass should decide wether it's worth to further constant fold the<br>
> block by running the proposed pass. Once accepted, the pass should be<br>
> inserted into the pass queue at a position where it is most effective.<br>
><br>
> What do you think about that idea? How much would be the effort of<br>
> implementing it? Does it fit the layering design?<br>
<br>
</div></div>One thing that this proposal doesn't really address is that running<br>
GVN is expensive; on common testcases, it takes much more time to run<br>
than any other pass.  We really don't want to be inserting extra runs<br>
of GVN into the pass pipeline.<br>
<font color="#888888"><br>
-Eli<br>
</font></blockquote></div><br>