[GHC] #15445: SPECIALIZE one of two identical functions does not fire well
GHC
ghc-devs at haskell.org
Mon Jul 30 11:31:39 UTC 2018
#15445: SPECIALIZE one of two identical functions does not fire well
---------------------------------+--------------------------------------
Reporter: nobrakal | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone: 8.6.1
Component: Compiler | Version: 8.4.3
Resolution: | Keywords:
Operating System: Linux | Architecture: x86_64 (amd64)
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
---------------------------------+--------------------------------------
Comment (by simonpj):
Aha. The problem is that we get
{{{
RULES: "SPEC plusTwoRec" forall ($dNum :: Num Int).
plusTwoRec @ Int $dNum = plusTwoRec_$splusTwoRec
}}}
but, as you say, Common Subexpression Elimination has decided to replace
`plusTwoRec`'s RHS with just `plusTwoRec'`. This is basically a good
thing to do (saves code duplication), but if `plusTwoRec` is inlined
before the rule has a chance to fire, we'll miss the specialisation.
I thought of disabling CSE for functions with RULES; but that seems wrong.
Generally, we add a NOINLINE pragma to a function with RULES to ensure
that the function does not inline before the rule has a chance to fire. I
think we should do the same thing with these auto-generated RULES from
specialisations.
Patch coming.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/15445#comment:2>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list