[m-rev.] for post-commit review: fix mantis bug 480 (mostly)

Zoltan Somogyi zoltan.somogyi at runbox.com
Tue Aug 6 16:46:57 AEST 2019



On Tue, 6 Aug 2019 11:29:19 +1000, Peter Wang <novalazy at gmail.com> wrote:
> That looks okay, thanks.

I followed both your suggestions.

> Out of interest, am I right that since there is no obligation for a
> hypothetical Mercury compiler to perform CSE before switch detection,
> this disjunction is not necessarily a switch according to the definition
> in the reference manual:
> 
>     (
> 	Struct = struct(Foo1, _Bar),
> 	Foo1 = yes(_),
> 	...
>     ;
> 	Struct = struct(Foo2, _Bar),
> 	Foo2 = no,
> 	...
>     )

The language lawyer was Fergus, not me. Given that there is only one
Mercury implementation, I don't see much point in expending effort
in drawing an imaginary line in the sand between "what the language requires"
and what the compiler does. Even if a second Mercury implementation
*does* arise, *they* will decide what subset of Mercury they implement,
not us :-)

BTW, the cse pass is done *after* the switch detection pass. Its just that
if cse ever does change the code of a procedure, it repeats switch detection
on that procedure, then invokes itself again, until it gets to a fixpoint.
This is because changes by cse can find new opportunities for switch
detection, and vice versa. So cse is always sandwiched between
two invocations of switch detection.

Zoltan.


More information about the reviews mailing list