
#9136: Constant folding in Core could be better --------------------------------------------+------------------------------ Reporter: simonpj | Owner: nomeata Type: bug | Status: patch Priority: normal | Milestone: Component: Compiler | Version: 7.8.2 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: Type of failure: Runtime performance bug | Unknown/Multiple Test Case: | Difficulty: Unknown Blocking: | Blocked By: | Related Tickets: --------------------------------------------+------------------------------ Comment (by simonpj): I had a look and the patch seemed broadly OK, through rather under- commented. Notably the parameters to the key function, whose name I now forget, and a user-readable version of the rewrite that each block of code performs. Care is needed to be sure that the rewrites really are semantics preserving, given that overflow may happen. It's probably ok because the types involved do wrap-around, but that very point needs a careful `Note` in the code. By all means extend it further, but please do document it well. One thing to bear in mind is that these rewrite rules are tried for every single expression `(op a b)`, where `op` is (say) `Int#` addition, and every single iteration of the simplifier. So it needs to fail fast if it ends up doing nothing. An alternative would be an entirely separate pass, which can then be as expensive as you like. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9136#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler