[GHC] #7619: Make worker-wrapper unbox data families
GHC
cvs-ghc at haskell.org
Wed Jan 23 09:54:46 CET 2013
#7619: Make worker-wrapper unbox data families
-----------------------------+----------------------------------------------
Reporter: akio | Owner:
Type: feature request | Status: new
Priority: normal | Component: Compiler
Version: 7.7 | Keywords: type family
Os: Unknown/Multiple | Architecture: Unknown/Multiple
Failure: None/Unknown | Blockedby:
Blocking: | Related:
-----------------------------+----------------------------------------------
I noticed that the worker-wrapper optimization doesn't unbox arguments
whose type is a data family instance. For example in this module:
{{{
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE BangPatterns #-}
module Foo where
data family Foo a
data instance Foo Int = FooInt Int Int
foo :: Foo Int -> Int
foo (FooInt a b) = loop a b
where
loop 0 y = length $ replicate y b
loop x !y = loop (mod y x) x
foo1 :: (Int, Int) -> Int
foo1 (a, b) = loop a b
where
loop 0 y = length $ replicate y b
loop x !y = loop (mod y x) x
}}}
foo and foo1 both get worker-wrapper applied, with worker functions of the
following types:
{{{
$wfoo :: Foo Int -> Int#
$wfoo1 :: Int# -> Int# -> Int#
}}}
It would be nice if $wfoo could get the same type as $wfoo1.
This issue happened in real life with unboxed vectors from the vector
package, resulting in a lot of boxing with unboxed vector constructors
immediately followed by unboxing.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7619>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list