| ... |
... |
@@ -29,6 +29,7 @@ import GHC.Core.Ppr ( pprCoreBindings, pprRules ) |
|
29
|
29
|
import GHC.Core.Utils ( dumpIdInfoOfProgram, diffBinds, stripTicksE )
|
|
30
|
30
|
import GHC.Core.Lint.Interactive ( interactiveInScope )
|
|
31
|
31
|
import GHC.Core.Opt.Simplify ( simplifyExpr, simplifyPgm )
|
|
|
32
|
+import GHC.Core.Opt.Simplify.Env ( SimplMode(..) )
|
|
32
|
33
|
import GHC.Core.Opt.Simplify.Monad
|
|
33
|
34
|
import GHC.Core.Opt.Monad
|
|
34
|
35
|
import GHC.Core.Opt.Pipeline.Types
|
| ... |
... |
@@ -172,6 +173,24 @@ getCoreToDo dflags hpt_rule_base extra_vars |
|
172
|
173
|
simpl_gently = CoreDoSimplify $ initSimplifyOpts dflags extra_vars max_iter
|
|
173
|
174
|
(initGentleSimplMode dflags) hpt_rule_base
|
|
174
|
175
|
|
|
|
176
|
+ first_float_switches = FloatOutSwitches
|
|
|
177
|
+ { floatOutLambdas = Just 0
|
|
|
178
|
+ , floatOutConstants = True
|
|
|
179
|
+ , floatOutOverSatApps = False
|
|
|
180
|
+ , floatToTopLevelOnly = False
|
|
|
181
|
+ , floatJoinsToTop = False -- Initially, don't float join points at all
|
|
|
182
|
+ }
|
|
|
183
|
+
|
|
|
184
|
+ -- EXPERIMENT (#28016): before each phase, let full laziness float to top
|
|
|
185
|
+ -- level the constants that the unfoldings active from that phase expose,
|
|
|
186
|
+ -- before case-of-case moves a continuation into them, as the gentle run
|
|
|
187
|
+ -- does for the first float-out. See Note [Case-of-case and full laziness].
|
|
|
188
|
+ pre_float phase = runWhen full_laziness $ CoreDoPasses
|
|
|
189
|
+ [ CoreDoSimplify $ initSimplifyOpts dflags extra_vars 1
|
|
|
190
|
+ ((initSimplMode dflags phase "pre-float") { sm_case_case = False })
|
|
|
191
|
+ hpt_rule_base
|
|
|
192
|
+ , CoreDoFloatOutwards first_float_switches { floatToTopLevelOnly = True } ]
|
|
|
193
|
+
|
|
175
|
194
|
dmd_cpr_ww = if ww_on then [CoreDoDemand True,CoreDoCpr,CoreDoWorkerWrapper]
|
|
176
|
195
|
else [CoreDoDemand False] -- NB: No CPR! See Note [Don't change boxity without worker/wrapper]
|
|
177
|
196
|
|
| ... |
... |
@@ -206,14 +225,7 @@ getCoreToDo dflags hpt_rule_base extra_vars |
|
206
|
225
|
-- so that overloaded functions have all their dictionary lambdas manifest
|
|
207
|
226
|
runWhen do_specialise CoreDoSpecialising,
|
|
208
|
227
|
|
|
209
|
|
- runWhen full_laziness
|
|
210
|
|
- (CoreDoFloatOutwards $ FloatOutSwitches
|
|
211
|
|
- { floatOutLambdas = Just 0
|
|
212
|
|
- , floatOutConstants = True
|
|
213
|
|
- , floatOutOverSatApps = False
|
|
214
|
|
- , floatToTopLevelOnly = False
|
|
215
|
|
- , floatJoinsToTop = False -- Initially, don't float join points at all
|
|
216
|
|
- }),
|
|
|
228
|
+ runWhen full_laziness (CoreDoFloatOutwards first_float_switches),
|
|
217
|
229
|
-- I have no idea why, but not floating constants to
|
|
218
|
230
|
-- top level is very bad in some cases.
|
|
219
|
231
|
--
|
| ... |
... |
@@ -232,9 +244,11 @@ getCoreToDo dflags hpt_rule_base extra_vars |
|
232
|
244
|
|
|
233
|
245
|
-- Run the simplifier phases 2,1,0 to allow rewrite rules to fire
|
|
234
|
246
|
runWhen do_simpl3
|
|
235
|
|
- (CoreDoPasses $ [ simpl_phase (Phase phase) "main" max_iter
|
|
236
|
|
- | phase <- [phases, phases-1 .. 1] ] ++
|
|
237
|
|
- [ simpl_phase (Phase 0) "main" (max max_iter 3) ]),
|
|
|
247
|
+ (CoreDoPasses $ concat [ [ pre_float (Phase phase)
|
|
|
248
|
+ , simpl_phase (Phase phase) "main" max_iter ]
|
|
|
249
|
+ | phase <- [phases, phases-1 .. 1] ] ++
|
|
|
250
|
+ [ pre_float (Phase 0)
|
|
|
251
|
+ , simpl_phase (Phase 0) "main" (max max_iter 3) ]),
|
|
238
|
252
|
-- Phase 0: allow all Ids to be inlined now
|
|
239
|
253
|
-- This gets foldr inlined before strictness analysis
|
|
240
|
254
|
|