|
Re: [GHC] #683: RULES for recursive functions don't work properly: msg#00091lang.haskell.glasgow.bugs
#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_______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@xxxxxxxxxxx http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Re: the MPTC Dilemma (please solve), Claus Reinke |
|---|---|
| Next by Date: | Re: [GHC] #707: foldr/build seems to be broken, GHC |
| Previous by Thread: | [GHC] #683: RULES for recursive functions don't work properly, GHC |
| Next by Thread: | Re: [GHC] #683: RULES for recursive functions don't work properly, GHC |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |