[e-lang] Killing the MatchBindExpr
Kevin Reid
kpreid at attglobal.net
Wed May 3 12:20:12 EDT 2006
On May 3, 2006, at 2:31, Mark S. Miller wrote:
> Many languages (such as C and Java) have constant-time switch
> constructs (at least when the case values are dense). Currently, if
> the E programmer writes a simple switch which should be compiled to
> a constant time dispatch, this is first expanded to an 'else if'
> chain. Although Dan reports that gcc will actually optimize some
> 'else if' chains to constant time dispatches, that's a lot to ask
> of an optimizer. But if the switch is passed through directly to
> Kernel-E, then it should be easier for reasonable E implementations
> to recognize some of the simple cases they can turn into constant
> time dispatches.
Why would it be a lot to ask?
It is trivial (and only O(n) instead of O(1)) to pattern-match the
else-if chain rather than a single 'SwitchExpr', and the optimizer is
then able to recognize structures which are similar to a switch
expression but not specifically written that way.
There are cases where a high-level construct is easier to optimize
but I don't think this is one of them.
--
Kevin Reid <http://homepage.mac.com/kpreid/>
More information about the e-lang
mailing list