
Whenever I try to inline a lot of nested function calls, GHC decides to specialise one of the functions and the specialised function is no longer inlined. I hoped to get the function inlined anyway by specialising it manually. Say, I want to inline genericFunc {-# INLINE genericFunc #-} genericFunc :: RealFrac a => a -> Int but GHC inserts a call to genericFunc1 specialised to a=Double where I apply genericFunc to a Double argument. Now I define {-# INLINE doubleFunc #-} doubleFunc :: Double -> Int doubleFunc = genericFunc However, in the Core output 'doubleFunc' does not get the __inline_me tag and thus will not be inlined, too. :-(

As luck would have it, I'm working on INLINE pragmas for Roman right at this moment. Could you spare a moment to give me a concrete test case, to make sure I hit your case too? If you can give me a program that doesn't optimise as you expect, I'm much more likely to get it right. Thanks Simon | -----Original Message----- | From: haskell-cafe-bounces@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Henning | Thielemann | Sent: 29 April 2008 11:02 | To: Haskell Cafe | Subject: [Haskell-cafe] force inlining in GHC | | | Whenever I try to inline a lot of nested function calls, GHC decides to | specialise one of the functions and the specialised function is no longer | inlined. I hoped to get the function inlined anyway by specialising it | manually. Say, I want to inline genericFunc | | {-# INLINE genericFunc #-} | genericFunc :: RealFrac a => a -> Int | | but GHC inserts a call to genericFunc1 specialised to a=Double where I | apply genericFunc to a Double argument. | | Now I define | | {-# INLINE doubleFunc #-} | doubleFunc :: Double -> Int | doubleFunc = genericFunc | | However, in the Core output 'doubleFunc' does not get the __inline_me tag | and thus will not be inlined, too. :-( | _______________________________________________ | Haskell-Cafe mailing list | Haskell-Cafe@haskell.org | http://www.haskell.org/mailman/listinfo/haskell-cafe

Hello Henning, Tuesday, April 29, 2008, 2:01:39 PM, you wrote:
However, in the Core output 'doubleFunc' does not get the __inline_me tag and thus will not be inlined, too. :-(
ghc is so smart that sometimes it fool itself :D i bet that in this case generic and specific functions are considered as equivalent :) ps: why you not wrote to ghc users list? -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com
participants (3)
-
Bulat Ziganshin
-
Henning Thielemann
-
Simon Peyton-Jones