[GHC] #14068: Loopification using join points
GHC
ghc-devs at haskell.org
Thu Feb 22 16:25:17 UTC 2018
#14068: Loopification using join points
-------------------------------------+-------------------------------------
Reporter: nomeata | Owner: nomeata
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
Resolution: | Keywords: JoinPoints
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: #13966 #14067 | Differential Rev(s): Phab:D3811
#14827 |
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by nomeata):
> > Without loopification we get a specialization for drop, with
loopification we do not.
>
> I wonder why. Are you happy to pursue, or would you like help?
It seems rather clear to me *why*: We get this code for `drop`, which does
not satisfy the conditions for !SpecConstr; in particular, `drop` is not
recursive (!SpecConstr only creates specializations for recursive
functions):
{{{
drop n xs =
case xs of
[] -> []
(y:ys) -> case n of
I# n# -> case n# of
0# -> []
_ ->
joinrec j xs n# = case xs of
[] -> []
(y:ys) -> case n# of
0# -> []
_ -> call j ys (n# -# 1#)
in j ys (n# -# 1#)
}}}
But I think I need your guidance as to what we should do about it!
Should we simply enable !SpecConstr even for all non-recursive functions?
(My gut feeling is that this will blow up code size and compilation times
too much.)
Maybe we need to float the `joinrec … in …` out out of `drop`, so that the
remaining code in `drop` (which does the case analysis on `n`) is small
enough to be always inlined?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14068#comment:33>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list