
#12877: Constant propagation with basic unboxed arithmetic instructions -------------------------------------+------------------------------------- Reporter: hsyl20 | Owner: Type: feature | Status: new request | Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: None/Unknown Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- I have a program that generates the following core: {{{#!hs main = case t of t0 0## -> ... DEFAULT -> case t0 -# 1## of t1 0## -> ... DEFAUT -> case t1 -# 1## of t2 0## -> ... DEFAULT -> case t2 -# 1## of _ 0## -> ... DEFAULT -> ... }}} I think it would be possible to implement constant propagation to get: {{{#!hs main = case t of _ 0## -> ... 1## -> ... 2## -> ... 3## -> ... DEFAULT -> ... }}} If I'm not mistaken, to do that we could replace occurences of: {{{#!hs case t -# k# of _ n0# -> ... n1# -> ... ... DEFAULT -> f }}} with: {{{#!hs case t of _ (n0#+k#) -> ... -- (ni#+k#) statically computed (n1#+k#) -> ... ... DEFAULT -> f }}} Any guidance on how to implement that would be appreciated. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12877 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler