compilation of pattern-matching?

Jan-Willem Maessen jmaessen at
Wed Mar 25 16:35:51 EDT 2009

On Mar 25, 2009, at 5:18 AM, Simon Peyton-Jones wrote:

> Indeed GHC does not attempt to retain the order of alternatives,  
> although
> a) it might be possible to do so by paying more attention in  
> numerous places
> b) GHC may do so already, by accident, in certain cases
> ...
> * Which plan performs best is tremendously architecture dependent,  
> and may well vary a lot between different chips implementing the  
> same instruction set.  It's a losing battle to fix the strategy in  
> source code.
> * More promising might be to say "this is the hot branch".  That  
> information about frequency could in principle be used by the back  
> end to generate better code.  However, I am unsure how
>        a) to express this info in source code
>        b) retain it throughout optimisation

The usual compiler heuristic is "backward branches" or "loop edges",  
which I would re-interpret in Haskell as "contains a call (any call)  
to a function in the same SCC binding group".  But I expect for hot  
code the effect would indeed be small.

> Claus, if you think this thread is worth capturing, then do write a  
> Commentary page, and I'll check its veracity.
> Thanks
> Simon

More information about the Glasgow-haskell-users mailing list