[GHC] #9279: Optimisation bug
GHC
ghc-devs at haskell.org
Mon Jul 7 11:40:06 UTC 2014
#9279: Optimisation bug
------------------------------+--------------------------------------------
Reporter: simonmar | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 7.8.2
Keywords: | Operating System: Unknown/Multiple
Architecture: | Type of failure: Runtime performance bug
Unknown/Multiple | Test Case:
Difficulty: Unknown | Blocking:
Blocked By: |
Related Tickets: |
------------------------------+--------------------------------------------
I have a strange problem with a local function binding that is not being
inlined. I've attached the repro code, build it like this:
{{{
$ ghc -O2 Haxl/Core/Monad.hs
}}}
There are several modules, but the one with the problem is
`Haxl/Core/Monad.hs`. In particular
`Haxl.Core.Monad.$fApplicativeGenHaxl2`, which contains this fragment:
{{{
let {
$wa4_s6YQ
$wa4_s6YQ =
\ w_s6YF _ ww1_s6YM _ _ w1_s6YI ->
case GHC.Prim.readMutVar# ipv7_X5Ne w1_s6YI
of _ { (# ipv10_X5QO, ipv11_X5QQ #) ->
case ipv11_X5QQ of _ {
Haxl.Core.Monad.IVarFull a2_a3kK -> case lvl6_r7qi of
wild3_00 { };
Haxl.Core.Monad.IVarEmpty dt2_d4Vs ->
case GHC.Prim.writeMutVar#
ipv7_X5Ne (Haxl.Core.Monad.IVarFull w_s6YF)
ipv10_X5QO
of s2#_a5OR { __DEFAULT ->
case GHC.Prim.readMutVar# dt2_d4Vs s2#_a5OR
of _ { (# ipv12_X5R0, ipv13_X5R2 #) ->
case GHC.Prim.readMutVar# ww1_s6YM ipv12_X5R0
of _ { (# ipv14_X5SS, ipv15_X5SU #) ->
letrec {
go_a5ti
go_a5ti =
\ ds10_a5tj ->
case ds10_a5tj of _ {
[] -> ipv15_X5SU;
: y_a5to ys_a5tp -> GHC.Types.: (y_a5to
w_s6YF) (go_a5ti ys_a5tp)
}; } in
case go_a5ti ipv13_X5R2 of x'_a5P6 { __DEFAULT ->
case GHC.Prim.writeMutVar# ww1_s6YM x'_a5P6
ipv14_X5SS
of s2#1_a5P7 { __DEFAULT ->
(# s2#1_a5P7, Haxl.Core.Monad.cacheRequest6 #)
}
}
}
}
}
}
} } in
let {
a2_s6lH
a2_s6lH =
\ w_s6YF _ w2_s6YH w3_s6YI ->
case w2_s6YH
of _
{ Haxl.Core.Monad.SchedState ww1_s6YL ww2_s6YM ww3_s6YN
ww4_s6YO ->
$wa4_s6YQ w_s6YF ww1_s6YL ww2_s6YM ww3_s6YN ww4_s6YO
w3_s6YI
} } in
}}}
I want `$wa4` to be inlined at its single occurrence in `a2`. I believe
the reason it is not being inlined is that `a2` is a wrapper, but the
situation seems silly because the wrapper isn't going away either, so we
have a redundant closure being built (this is in my inner loop).
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/9279>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list