[m-rev.] for review: multi-cons-id switch arms for MLDS

Julien Fischer juliensf at csse.unimelb.edu.au
Wed Aug 26 12:03:47 AEST 2009


On Wed, 19 Aug 2009, Zoltan Somogyi wrote:

> Implement multi-arm switches for the MLDS backend. When possible, the code of a
> switch arm that has more than one cons_id is included in the output only once,
> though of course with a condition that causes it to be executed for any of its
> matching cons_ids. However, in the case of a tag switch in which a switch arm
> has cons_ids with different primary tags, at least one of which has a
> secondary tag that requires a switch on *it*, we duplicate the MLDS code of the
> switch arm (we generate one copy for each such primary tag).
>
> The diff yields a speedup of 0.4% on speedtest and a 0.5% reduction in code
> size, but the main reason for it is so that programmers don't have any
> incentive anymore to prefer an if-then-else chain to a switch for code
> that is logically a switch with a default case that applies to many cons_ids.

...

> Index: compiler/handle_options.m
> ===================================================================
> RCS file: /home/mercury/mercury1/repository/mercury/compiler/handle_options.m,v
> retrieving revision 1.337
> diff -u -b -r1.337 handle_options.m
> --- compiler/handle_options.m	10 Jul 2009 01:30:36 -0000	1.337
> +++ compiler/handle_options.m	17 Aug 2009 11:59:57 -0000

...

> @@ -1134,8 +1133,20 @@
>         option_implies(highlevel_code, mutable_always_boxed, bool(no),
>             !Globals),
>
> -        option_implies(highlevel_code, allow_multi_arm_switches, bool(no),
> -            !Globals),
> +        % Currently, multi-arm switches % have been tested only for the LLDS
> +        % backend (which always generates C) and for the MLDS backend when
> +        % it is generating C code.

The first line of that comment contains an extra "%".

The rest looks okay.  Please check that the compiler still bootchecks
in a number of the high-level C grades, e.g. hl.gc, not just hlc.gc
before committing.

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