Re: [GHC] #2289: Needless reboxing of values when returning from a tight loop

#2289: Needless reboxing of values when returning from a tight loop
-------------------------------------+-------------------------------------
Reporter: dons | Owner:
Type: bug | Status: new
Priority: lowest | Milestone:
Component: Compiler | Version: 6.8.2
Resolution: | Keywords: boxing,
| loops, performance
Operating System: Unknown/Multiple | Architecture:
Type of failure: Runtime | Unknown/Multiple
performance bug | Test Case:
Blocked By: | Blocking:
Related Tickets: #2387,#1600 | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by twhitehead):
I was just going to open a ticket to report that I had discovered that the
compiler can't unbox multiple return values.
That is, anytime you create a non-inlined function (such as a loop) that
returns multiple values, you must pay the boxing and unboxing penalty.
My reading of these tickets (#1600, #2289, and #2387) though is that this
is already known. I'll just add a simple example here
{{{
#!haskell
main :: IO ()
main = case loop2 100 (10,10) of (au,ad) -> print (au - ad)
loop2 :: Int -> (Int,Int) -> (Int,Int)
loop2 n (au,ad) | n > 0 = loop2 (n-1) (au+1,ad-1)
| otherwise = (au,ad)
}}}
yielding (with ''-ddump-simpl -dsuppress-all -dno-suppress-type-
signatures'')
{{{
#!haskell
Rec {
main_$s$wloop2 [Occ=LoopBreaker]
:: Int# -> Int# -> Int# -> (# Int, Int #)
[GblId, Arity=3, Caf=NoCafRefs, Str=DmdType
participants (1)
-
GHC