#2731: Avoid unnecessary evaluation when unpacking constructors
-----------------------------------------+----------------------------------
Reporter: simonpj | Owner:
Type: run-time performance bug | Status: new
Priority: normal | Milestone: 6.12 branch
Component: Compiler | Version: 6.8.3
Severity: normal | Keywords:
Difficulty: Unknown | Testcase:
Architecture: Unknown/Multiple | Os: Unknown/Multiple
-----------------------------------------+----------------------------------
Consider
{{{
data T a = MkT !a
foo :: T (a,b) -> a
foo (MkT (x,y)) = x
}}}
GHC will extract the first component of the `MkT`, ''evaluate it'', and
then extract the first component of the pair. The evaluation step isn't
needed, since the component is known to be already-evaluated. `UNPACK`
directives won't work here, because the component is polymorphic.
In the email thread, Tyson posted an example where this extra eval made a
significant difference to his inner loop:
[http://www.haskell.org/pipermail/glasgow-haskell-
users/2008-October/015796.html]
Simon
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2731>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs