[GHC] #10260: last uses too much space with optimizations disabled
GHC
ghc-devs at haskell.org
Thu Apr 16 12:38:10 UTC 2015
#10260: last uses too much space with optimizations disabled
-------------------------------------+-------------------------------------
Reporter: rwbarton | Owner: nomeata
Type: bug | Status: patch
Priority: normal | Milestone:
Component: Core Libraries | Version: 7.10.1
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Runtime | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Revisions: Phab:D844
-------------------------------------+-------------------------------------
Comment (by nomeata):
`INLINEABLE` does not work; probably because the unfolding looks too
large. But `INLINE` seems to work. So with this patch
{{{
-last = foldl (\_ x -> x) (errorEmptyList "last")
+last xs = foldl (\_ x -> x) lastError xs
+{-# INLINE last #-}
+lastError = errorEmptyList "last"
}}}
we have
* that `GHC.List.last` is used without `-O`, with the desired memory
behaviour,
* with `-O`, `last` gets inlined and fusion can happen.
(`lastError` pulled out to not copy that wherever `last` is used).
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10260#comment:7>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list