#6122: INLINE pragma not obeyed
------------------------------+---------------------------------------------
Reporter: augustss | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler
Version: 7.4.1 | Keywords:
Os: Unknown/Multiple | Architecture: Unknown/Multiple
Failure: None/Unknown | Testcase:
Blockedby: | Blocking:
Related: |
------------------------------+---------------------------------------------
GHC seems to decide that it knows better than I when I put INLINE on a
recursive function. Take the following example
{{{
digits10 :: Int
digits10 = count 0 (floatRadix x ^ floatDigits x)
where {-# INLINE count #-}
count n v = if v < 10 then n else count (n+1) (v `quot` 10)
x = 1 :: Double
}}}
This should evaluate to 15 at compile time, but instead it will perform
the computation at runtime. I put INLINE of the count function because I
know what I'm doing, but I guess GHC doesn't trust me.
Postponing this calculation to runtime means that other constant folding
involving digits10 will not happen.
It can sometimes be very important to compute certain things at compile
time rather than runtime, and perhaps an even better way to ensure this
would be to have a pragma that specifies that a computation is supposed to
be done at compile time.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/6122>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs