[m-dev.] for review: MLDS switch optimization
Fergus Henderson
fjh at cs.mu.OZ.AU
Mon Nov 13 17:17:55 AEDT 2000
On 13-Nov-2000, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> On 13-Nov-2000, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> > switch (x) {
> > case LONGMIN ... -1:
> > foo();
> > break;
> > case 0:
> > bar();
> > break;
> > case 1 ... LONGMAX:
> > baz();
> > break;
> > }
>
> This can be handled by putting an upper limit on the number of elements in a
> range that are handled by fallthrough. If the limit is exceeded, you can fall
> back on a chain of if-then-elses. I don't think there are any performance
> critical cases where this would yield a significant slowdown.
It certainly could be handled in that way.
But I'm not sure that mlds_to_il.m is the right place to put that check.
In cases where the target doesn't really support case ranges, I think
it would be better for the MLDS code generator to not emit them
and to instead emit MLDS if-then-elses, rather than having the
MLDS code generator emit match_range constructs that the target
doesn't support and having the MLDS->target phase emulate them.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list