[GHC] #683: RULES for recursive functions don't work properly
GHC
trac at galois.com
Tue Feb 28 06:56:10 EST 2006
#683: RULES for recursive functions don't work properly
-----------------------+----------------------------------------------------
Reporter: simonpj | Owner: simonpj
Type: bug | Status: new
Priority: normal | Milestone: 6.6
Component: Compiler | Version: 6.4.1
Severity: normal | Resolution:
Keywords: | Os: Unknown
Difficulty: Unknown | Architecture: Unknown
-----------------------+----------------------------------------------------
Old description:
> someone mentioned to me that this expression:
>
> mapM_ action [n..m]
>
> isn't being optimised properly, so I thought I'd look into it. Sure
> enough, we don't get down to a simple loop like we should, although the
> F/B transformation is happening (see ~simonmar/scratch/mapm.hs). The
> problem is that GHC.Enum.eftIntFB isn't being inlined, it's defined like
> this:
>
> {-# INLINE [0] eftIntFB #-}
> eftIntFB :: (Int -> r -> r) -> r -> Int# -> Int# -> r
> eftIntFB c n x y | x ># y = n
> | otherwise = go x
> where
> go x = I# x `c` if x ==# y then n else go (x +# 1#)
>
> but, strangely, the inlining doesn't appear in the interface:
>
> eftIntFB :: (GHC.Base.Int -> r -> r) -> r -> GHC.Prim.Int# ->
> GHC.Prim.Int# -> r
> {- Arity: 4 HasNoCafRefs Strictness: LLLL -}
>
> This is becuase the RULE make eftIntFB look recursive, so its inlining
> isnt' exposed. Bad, bad.
New description:
someone mentioned to me that this expression:
mapM_ action [n..m]
isn't being optimised properly, so I thought I'd look into it. Sure
enough, we don't get down to a simple loop like we should, although the
F/B transformation is happening (see ~simonmar/scratch/mapm.hs). The
problem is that GHC.Enum.eftIntFB isn't being inlined, it's defined like
this:
{{{
{-# INLINE [0] eftIntFB #-}
eftIntFB :: (Int -> r -> r) -> r -> Int# -> Int# -> r
eftIntFB c n x y | x ># y = n
| otherwise = go x
where
go x = I# x `c` if x ==# y then n else go (x +# 1#)
}}}
but, strangely, the inlining doesn't appear in the interface:
{{{
eftIntFB :: (GHC.Base.Int -> r -> r) -> r -> GHC.Prim.Int# ->
GHC.Prim.Int# -> r
{- Arity: 4 HasNoCafRefs Strictness: LLLL -}
}}}
This is becuase the RULE make eftIntFB look recursive, so its inlining
isnt' exposed. Bad, bad.
Comment (by simonpj):
Fix formmatting only
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/683>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list