
It would be nice to factor out the common tails, e.g. by branching to
#14372: CMM contains a bunch of tail-merging opportunities -------------------------------------+------------------------------------- Reporter: heisenbug | Owner: (none) Type: feature request | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.2.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by heisenbug): Replying to [comment:2 nomeata]: the first tail already emitted.
Branches can be expensive, so this might not be a clear win. Have you
measured the effect? (You can do that without modifying GHC: Just get your hands on the assembly file, make the changes you want to see, and compare.) These will probably be short, known branches. Since more ''relevant'' code now can reside in the instruction cache, I expect less misses and no prediction failures.
The other idea, detecting blocks that are equal up-to a constant, sounds
fun. But again, the question is: Is it worth it? Well, it makes code straight-line and branchless. Eliminates jump-tables. Shrinks code size. Which one of these is a penalty? ;-) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/14372#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler