[m-rev.] for review: peephole optimization for the MLDS

Julien Fischer juliensf at csse.unimelb.edu.au
Fri Jul 29 14:56:15 AEST 2011


On Thu, 28 Jul 2011, Zoltan Somogyi wrote:

> compiler/ml_optimize.m:
> 	Add a peephole pass to the MLDS optimization suite.
>
> 	The one pattern we now optimize is code that has redundant tests:
>
> 	if (testcond) {
> 		...
> 	} else {
> 		...
> 	}
> 	if (testcond) {
> 		...
> 	} else {
> 		...
> 	}
>
> 	If neither the then-part nor the else-part of the first if-then-else
> 	updates any lval in testcond, then the second test is redundant, and
> 	the peephole pattern therefore optimizes it away.
>
> 	The pattern seems to occur mostly with semidet deconstructions.
> 	The semidet deconstruction tests whether the variable has the right
> 	functor, the then-part of that if-then-else picks up its argument
> 	values, there is no else part, and the next statement starts by testing
> 	whether the previous one succeeded, using the exact same condition
> 	as the semidet deconstruction.
>
> compiler/mercury_compile_mlds_back_end.m:
> 	Improve the format of a comment.
>
> compiler/options.m:
> doc/user_guide.text:
> 	Add another name, --mlds-peephole, for the existing peephole
> 	optimization flag, which until now was used only by the LLDS backend.
>

> Index: compiler/ml_optimize.m
> ===================================================================
> RCS file: /home/mercury/mercury1/repository/mercury/compiler/ml_optimize.m,v
> retrieving revision 1.71
> diff -u -b -r1.71 ml_optimize.m
> --- compiler/ml_optimize.m	23 May 2011 05:08:06 -0000	1.71
> +++ compiler/ml_optimize.m	28 Jul 2011 05:08:52 -0000

...

> +:- pred find_lval_component_lvals(mlds_lval::in,
> +    set(mlds_lval)::in, set(mlds_lval)::out) is det.
> +
> +find_lval_component_lvals(Lval, !Components) :-
> +    (
> +        Lval = ml_field(_, Rval, _, _, _),
> +        find_rval_component_lvals(Rval, !Components)
> +    ;
> +        Lval = ml_mem_ref(Rval, _),
> +        find_rval_component_lvals(Rval, !Components)
> +    ;
> +        Lval = ml_global_var_ref(_)     % XXX

What does the XXX here mean?

Looks fine otherwise.

Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list