Tidy up computation of result discounts in CoreUnfold
authorsimonpj@microsoft.com <unknown>
Mon, 14 Dec 2009 13:46:47 +0000 (13:46 +0000)
committersimonpj@microsoft.com <unknown>
Mon, 14 Dec 2009 13:46:47 +0000 (13:46 +0000)
commitaff23274b14d6e8551e949c3290adaf265e31371
treeebb10d35cb37686f0697eb0910be05cd1afee52c
parent21eeb926c8bf398e38919429d2375b78be45b14b
Tidy up computation of result discounts in CoreUnfold

Mostly this patch is a tidy-up, but it did reveal one inconsistency
that I fixed.  When computing result discounts for case expressions,
we were *adding* result-discounts for cases on non-arguments, but
*picking the one for the max-size branch* for arguments. I think you
could argue the toss, but it seems neater (and the code is nicer)
to be consistent (ie always add).  See Note [addAltSize result discounts].

The nofib results seem fine

        Program           Size    Allocs   Runtime   Elapsed
--------------------------------------------------------------------------------
          boyer          -0.8%     -4.8%      0.06      0.07
         sphere          -0.7%     -2.5%      0.15      0.16
--------------------------------------------------------------------------------
            Min          -0.8%     -4.8%    -19.1%    -24.8%
            Max          -0.5%     +0.0%     +3.4%   +127.1%
 Geometric Mean          -0.7%     -0.1%     -4.3%     -1.3%

The +127% elapsed is a timing error; I re-ran the same binary and it's
unchanged from the baseline.
compiler/coreSyn/CoreUnfold.lhs