[GHC] #14844: SpecConstr also non-recursive function
GHC
ghc-devs at haskell.org
Mon Mar 19 20:57:00 UTC 2018
#14844: SpecConstr also non-recursive function
-------------------------------------+-------------------------------------
Reporter: nomeata | Owner: (none)
Type: task | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.5
Resolution: | Keywords: SpecConstr
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 nomeata):
I distilled this example to show the effect
{{{
module T14844Example (bar1, bar2) where
large x = x
{-# NOINLINE large #-}
foo :: Int -> (a -> b -> Bool) -> (a,b) -> Bool
foo 0 _ _ = False
foo s f t = l s' t
where
l 0 t = False
l 1 t = case t of (x,y) -> f x y
l n (x,y) = l (n-1) (x,y)
s' = -- To prevent inlining
large $ large $ large $ large $ large $ large $ large $ large $
large $ large $ large $ large $ large $ large $ large $ large $
s
bar1 :: Int -> (a -> b -> Bool) -> a -> b -> Bool
bar1 s f x y = foo s f (x,y)
bar2 :: Int -> (a -> b -> Bool) -> a -> b -> Bool
bar2 s f x y = foo (s + 1) f (x,y)
}}}
This needs to rounds of !SpecConstr to specialize `foo` for the `(x,y)`
call pattern; in the first round, `l` is specialized, then the (then non-
recursive `l`) gets inlined into `foo`, then `foo` gets specialized.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14844#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list