[GHC] #3198: inliner fails to kick in for Double (*)
GHC
trac at galois.com
Wed Apr 29 11:15:13 EDT 2009
#3198: inliner fails to kick in for Double (*)
---------------------------------+------------------------------------------
Reporter: JulesBean | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 6.11
Severity: normal | Resolution:
Keywords: | Difficulty: Unknown
Testcase: | Os: Unknown/Multiple
Architecture: Unknown/Multiple |
---------------------------------+------------------------------------------
Changes (by simonpj):
* difficulty: => Unknown
Comment:
Suppose you have
{{{
f :: Double -> Double -> Double
f x y = x * y
}}}
What is gained if we inline `(*)` here? Virtually nothing: simply a jump
from `f` to `*`. After all, `f` is just `(*)`, and we know nothing about
`x` or `y`. (It'd be quite differnet if it was `x*1`!.) Moreover, if we
don't inline `*` here, we'll replace `f` by `(*)` at every call site.
(Remember too that this is Haskell, so it `(*)` was inlined you'd get
{{{
f x y = case x of D# a -> case y of D# b -> D# (plusDouble# a b)
}}}
In general, if GHC sees a call `(foo x y)`, where
* nothing whatsoever is known about `x` or `y` (for example, they are
lambda-bound), ''and''
* there is nothing interesting about the context of the cal
then GHC does not inline `foo`, ''even if `foo` has an INLINE pragma''.
Why? Because it simply give code bloat with zero or small benefit.
This is an adjustable decision, but I'm not yet convinced it needs
adjusting.
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3198#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list