Run float-inwards immediately before the strictness analyser.
authorSimon Peyton Jones <simonpj@microsoft.com>
Fri, 23 May 2014 12:42:05 +0000 (13:42 +0100)
committerSimon Peyton Jones <simonpj@microsoft.com>
Thu, 28 Aug 2014 10:14:15 +0000 (11:14 +0100)
Doing so pushes bindings nearer their use site and hence makes
them more likely to be strict. These bindings might only show
up after the inlining from simplification.  Example in fulsom,
Csg.calc, where an arg of timesDouble thereby becomes strict.

Very few programs are affected, but it's basically good news.

        Program           Size    Allocs   Runtime   Elapsed  TotalMem
--------------------------------------------------------------------------------
            fft          -0.2%     +1.3%      0.06      0.06    -10.0%
         fulsom          -0.0%     -2.6%     -4.3%     -4.7%     -6.7%
         simple          +0.0%     -0.8%      0.0%      0.0%      0.0%
--------------------------------------------------------------------------------
            Min          -0.5%     -2.6%     -4.5%     -4.7%    -10.0%
            Max          +0.1%     +1.3%     +3.3%     +3.4%     +2.6%
 Geometric Mean          -0.0%     -0.0%     -0.6%     -0.6%     -0.2%

The lossage in fft is the loss of detecting a common sub-expression,
and can be fixed by doing earlier CSE.  But that is in any case a bit
of a fluke so I don't mind losing it in exchange for this more reliable
gain.

compiler/simplCore/SimplCore.lhs

index 1a7fd67..2a70dcf 100644 (file)
@@ -246,8 +246,6 @@ getCoreToDo dflags
                 -- but maybe we save some unnecessary to-and-fro in
                 -- the simplifier.
 
-        runWhen do_float_in CoreDoFloatInwards,
-
         simpl_phases,
 
                 -- Phase 0: allow all Ids to be inlined now
@@ -262,6 +260,13 @@ getCoreToDo dflags
                 -- Don't stop now!
         simpl_phase 0 ["main"] (max max_iter 3),
 
+        runWhen do_float_in CoreDoFloatInwards,
+            -- Run float-inwards immediately before the strictness analyser
+            -- Doing so pushes bindings nearer their use site and hence makes
+            -- them more likely to be strict. These bindings might only show
+            -- up after the inlining from simplification.  Example in fulsom,
+            -- Csg.calc, where an arg of timesDouble thereby becomes strict.
+
         runWhen call_arity $ CoreDoPasses
             [ CoreDoCallArity
             , simpl_phase 0 ["post-call-arity"] max_iter