[GHC] #8704: Use GHC.Exts.build in randoms, randomRs to achieve fusion
GHC
ghc-devs at haskell.org
Mon Jan 27 18:45:00 UTC 2014
#8704: Use GHC.Exts.build in randoms, randomRs to achieve fusion
-------------------------------------+------------------------------------
Reporter: ion1 | Owner:
Type: feature request | Status: patch
Priority: normal | Milestone:
Component: libraries/random | Version: 7.6.3
Resolution: | Keywords: fusion
Operating System: Unknown/Multiple | Architecture: Unknown/Multiple
Type of failure: None/Unknown | Difficulty: Unknown
Test Case: | Blocked By:
Blocking: | Related Tickets: #4218
-------------------------------------+------------------------------------
Comment (by ion1):
Yes, I tested with
{{{
main = do { gen <- newStdGen; mapM_ print (randoms gen) }
}}}
which resulted in the list data structure being optimized away entirely
(along with the pattern match for the empty case in `mapM_`).
I got around to doing some benchmarking after posting the patch and I seem
unable to come up with code for which `randoms` fusion makes a difference
in performance, though. Unless someone else thinks of something I didn’t,
this might not be worth it.
The `seq` fix for part of #4218 can be done independently.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8704#comment:3>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list