Stefan O'Rear wrote:
 | On Mon, Jun 11, 2007 at 09:43:17AM +1000, Thomas Conway wrote:
 :
 | > codeLen 127 = 0
 | > codeLen 128 = 1
 | > ...
 | > codeLen 255 = 8
 | >
 | > Now, compiling with ghc 6.6.1 and -O3, I see that it generates a long
 | > chain of conditional branches.
 :

That's deeply tied in with Num being a subclass of Eq, isn't it? Pattern matching for /non-numeric/ data constructors should be more direct, at any optimisation level, thanks to the taglessness of the STG machine.

 | I'd suggest learning how to hack on GHC, I get a chain of branches even
 | at the maximum optimization setting.  Hackers are always appreciated!

Such a GHC hack may have to be limited to some known, standard numeric types. User-defined numeric types may not provide anything that you can use to look up a jump table.

How would an array go, as a user-level optimisation?

Regards,
Tom


_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to