[m-rev.] For review by Fergus: Loop Invariant Hoisting

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Oct 30 23:17:50 AEDT 2002


On 30-Oct-2002, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> Fergus Henderson, Wednesday, 16 October 2002:
> > On 16-Oct-2002, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> > > I've just done a bootcheck on an updated tree and all is well.
> > 
> > I presume you bootchecked with the optimization enabled?
> > (E.g. -O4 or greater?)
> 
> Bootchecked in -O2 to -O6 in both asm_fast.gc and hlc.gc, each with
> --no-loop-invariants and --loop-invariants.
> 
> > Also, what effect does this have on performance?  (E.g. for the compiler
> > itself, or the benchmarks in the `bench' directory).  We don't want to
> > enable the optimization by default if it ends up making performance worse.
> > It would be a good idea to run some benchmarks to double-check that the
> > intended optimization really does improve things.
> 
> In asm_fast.gc:
> mercury_compile.01 average of 12 with ignore=1     52.88
> mercury_compile.02 average of 12 with ignore=1     52.31
> mercury_compile.03 average of 12 with ignore=1     51.40
> mercury_compile.04 average of 12 with ignore=1     51.96
> mercury_compile.05 average of 12 with ignore=1     50.72
> mercury_compile.06 average of 12 with ignore=1     50.62
> mercury_compile.07 average of 12 with ignore=1     50.37
> mercury_compile.08 average of 12 with ignore=1     50.55
> mercury_compile.09 average of 12 with ignore=1     56.99
> mercury_compile.10 average of 12 with ignore=1     57.46

So for asm_fast.gc, it looks like a slight loss, except at -O2 and -O4.

> In hlc.gc:
> mercury_compile.11 average of 12 with ignore=1     50.39
> mercury_compile.12 average of 12 with ignore=1     50.44
> mercury_compile.13 average of 12 with ignore=1     52.62
> mercury_compile.14 average of 12 with ignore=1     50.80
> mercury_compile.15 average of 12 with ignore=1     50.38
> mercury_compile.16 average of 12 with ignore=1     50.36
> mercury_compile.17 average of 12 with ignore=1     51.91
> mercury_compile.18 average of 12 with ignore=1     50.67
> mercury_compile.19 average of 12 with ignore=1     51.61
> mercury_compile.20 average of 12 with ignore=1     50.45

For hlc.gc, it looks like a slight win, except at -O2.

Probably the increase in code size is more costly (in terms of cache
performance) for asm_fast.gc, which already has a high code size.

What's the uncertainty/variance in these numbers?

Did you run the benchmarks at the same time that the nightly tests
were running?

> > How much space cost does it have?
> > Should it be disabled if --optimize-space is specified?
> 
> The space cost is reasonably small (with/without optimization):

About 1%.

I think it should be disabled if --optimize-space is specified.

> --- doc/user_guide.texi	22 Oct 2002 04:36:03 -0000	1.332
> +++ doc/user_guide.texi	25 Oct 2002 07:22:05 -0000
> @@ -5603,6 +5603,12 @@
>  containing large numbers of variables can cause
>  slow compilation.
>  
> + at item --loop-invariants
> + at findex --loop-invariants
> +Optimize loop invariants by moving computations within a loop that are
> +the same on every iteration to the outside so they are only calculated
> +once.  (This is a separate optimization to @samp{--optimize-rl-invariants}.)

I suggest s/to the outside/to outside the loop/

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list