[GHC] #13016: SPECIALIZE INLINE doesn't necessarily inline specializations of a recursive function
GHC
ghc-devs at haskell.org
Wed Jan 17 13:59:33 UTC 2018
#13016: SPECIALIZE INLINE doesn't necessarily inline specializations of a recursive
function
-------------------------------------+-------------------------------------
Reporter: nfrisby | Owner: (none)
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
Resolution: | Keywords: Inlining
Operating System: Unknown/Multiple | Architecture:
Type of failure: Runtime | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: #13014 | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by andrewthad):
I also feel the behavior of `SPECIALIZE INLINE` is weird in this
situation, and I would prefer that it not be marked as a loop breaker.
Here's an example that I was toying with that led me to this ticket:
{{{!#hs
{-# language DataKinds #-}
{-# language GADTs #-}
{-# language KindSignatures #-}
{-# OPTIONS_GHC -O2 -fforce-recomp -ddump-simpl -dsuppress-all #-}
import Data.Kind
data Nat = Succ Nat | Zero
data SNat :: Nat -> Type where
SZero :: SNat 'Zero
SSucc :: SNat n -> SNat ('Succ n)
{-# SPECIALISE INLINE exponentiate :: SNat ('Succ n) -> Int -> Int #-}
{-# SPECIALISE INLINE exponentiate :: SNat 'Zero -> Int -> Int #-}
exponentiate :: SNat n -> Int -> Int
exponentiate SZero x = 1
exponentiate (SSucc s) x = x * (exponentiate s x)
main :: IO ()
main = print (exponentiate (SSucc (SSucc (SSucc (SSucc SZero)))) 3)
}}}
I would expect that the call to `exponentiate` be supercompiled, but it is
not.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13016#comment:11>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list