[m-dev.] Tuples and pairs

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Dec 21 19:24:30 AEDT 2001

On 21-Dec-2001, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> On 21-Dec-2001, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> > Result: not so good.  Switch detection does not work on code like the
> > following:
> > 
> > f([]) = ...
> > f([cons1 - X | _]) = ...
> > f([cons2 - X | _]) = ...
> > f([cons3 - X | _]) = ...
> > 
> > The problem arises because switch detection only looks as far as the
> > first call in each disjunct, rather than the first semidet goal.
> > 
> > This is fixable, but non-trivial and hence will have to wait until after
> > Xmas.
> This is not the first time that non-intuitive nature of the compiler's current
> behavior has come up. There is a good case to be made that switch detection
> should search each disjunct until the first *predicate* call, and that it
> should not stop at *function* calls.
> That modification isn't too hard; you just need to add a bit of code to
> find_bind_var in switch_detection.m to step past function calls and
> generic_calls. I'll put it on my plate for next week.

Actually Ralph's summary was incomplete.  Ralph, Simon and I discussed
this and came to exactly the same conclusion as you.  I was about to go
and implement it, when I realized that this in itself is not sufficient.
To get switch detection in cases like this one, not only does switch
detection need to look past function calls, but in addition cse_detection
needs to detect and eliminate common function calls in the same way that
it currently does for common deconstruction unifications.

That is the bit which I decided, after a brief glance at the code,
was non-trivial and definitely too difficult to do before Christmas ;-)

I'm also less sure about what other ramifications there might be from
making cse_detection hoist out common function calls.

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-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