[r6rs-discuss] [OT] Should compilers preserve termination?

From: Thomas Lord <lord>
Date: Thu Mar 1 14:44:10 2007

Joe Marshall wrote:
> On 2/28/07, Paul Schlie <schlie_at_comcast.net> wrote:
>>
>> Thereby although creating a logical loop testing for a termination
>> condition
>> prior to returning a value and thereby enabling control flow to
>> proceed, may
>> not be the best way to temporally synchronize program execution to
>> external
>> events, it's seemingly valid; and thereby seemingly only valid to
>> optimize
>> away evaluation if it can be proven to terminate exclusively based on
>> synthetic state values within the context of the logical program, and
>> not
>> values imported from the outside world through I/O ports or other
>> similar
>> means for example.
>
> This seems weird. If I were to write a loop that just ran for timing
> purposes,
> I'd be insane to run it through an optimizing compiler.

Joe, I think he is saying that all low-level port-events should be
defined to be well-ordered points on a hypothetical world-line of
a single program run and that the semantics of the order-of-execution
partially determine that ordering. Because low-level port events are
externally
observable, they can't be optimized away and, in the view he's expressing,
have to occur in one of the expected orders.

I tried for a while to argue against that but came to the conclusion that
Paul is right. Even an optimizing compiler should be sensitive to
the observable side effects implied by the semantics.

But I don't disagree that the whole topic is "weird", at least
to the extent that that is roughly synonymous with "interesting"
or "fascinating".

You could still build an optimizing compiler that didn't honor
this restriction and it could still be very useful -- but it should,
in this view, come with a warning that it may not compile some
portable programs faithfully.

-t



>
> As it stands, collatz conjecture hasn't been proven, but no divergent
> value has
> ever been discovered. Would it be ok to optimize out the code
> for the cases for which it is known to converge? Suppose a
> termination proof were
> found, would it be ok to optimize out the call in that case? Would it
> be ok even
> if someone wrote timing code that depended on such a proof not being
> found?
>
Received on Thu Mar 01 2007 - 14:52:28 UTC

This archive was generated by hypermail 2.3.0 : Wed Oct 23 2024 - 09:15:01 UTC