[GHC] #3831: SpecConstr should exploit cases where there is exactly one call pattern
GHC
ghc-devs at haskell.org
Thu Feb 22 13:11:46 UTC 2018
#3831: SpecConstr should exploit cases where there is exactly one call pattern
-------------------------------------+-------------------------------------
Reporter: igloo | Owner: simonpj
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.13
Resolution: | Keywords: SpecConstr
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: Compile-time | Test Case:
performance bug | simplCore/should_compile/T3831
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by sgraf):
I'm trying to reproduce what the missed opportunity was here. I ran T3831
and realized that the test is ineffective for detecting a regression of
this ticket: The compiler invocation misses a `-O2`.
Re: missed tantalising opportunity: I think you are referring to
`setAttributes`, specifically to this nesting of join points:
{{{
join {
$j1
$j1 x1 m1
= case m1 of {
Nothing -> (# x1, Nothing #);
Just x1 -> case ... x1 of {
(# y1, n1 #) ->
join {
$j2
$j2 x2 m2
= ... -- many more
join {
$j12 x12 m12
= case m12
of {
Nothing ->
(# x12, Nothing #);
Just f ->
(# x12, Just (\a -> ...) #)
} } in
...
case m2
of {
Nothing -> jump $j12 x2 Nothing;
Just f -> case ... x2 of {
(# x12', m12' #) ->
case m12'
of {
Nothing -> jump $j12 x12' (Just (x6 lvl7));
Just _ -> jump $j12 x12' (Just ...)
}
}
} } in
case n1
of {
Nothing -> jump $j2 y1 Nothing;
Just _ -> jump $j2 y1 (Just ...)
} } in
}}}
I probably have made some errors while simplifying, but the idea is that
these join points aren't specialised at all.
1. These are all non-recursive. I was under the impression that we have
the inliner for non-recursive bindings to decide if inlining is
worthwhile.
2. I don't see how there's only one call-pattern for each join point.
There are 3: one Nothing, two Justs. Specialising (branching factor 2) or
even inlining (3) these would mean exponential blow-up in code size.
So either I'm referring to the wrong fragment of the code (I found no
other join points, let alone recursive ones) or things have changed since
then.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/3831#comment:17>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list