| ... |
... |
@@ -343,7 +343,7 @@ mk_tick preserve_anf t orig_expr = mkTick' orig_expr |
|
343
|
343
|
mkTick' expr
|
|
344
|
344
|
-- Deal with ticking a expression headed by one or more ticks.
|
|
345
|
345
|
| Just (ts, e) <- tickedExpr_maybe expr
|
|
346
|
|
- = tickTickedExpr t ts e
|
|
|
346
|
+ = tickTickedExpr preserve_anf t ts e
|
|
347
|
347
|
mkTick' expr = case expr of
|
|
348
|
348
|
|
|
349
|
349
|
Lam x e
|
| ... |
... |
@@ -413,11 +413,13 @@ mk_tick preserve_anf t orig_expr = mkTick' orig_expr |
|
413
|
413
|
|
|
414
|
414
|
-- | Apply a tick to an expression headed by ticks.
|
|
415
|
415
|
tickTickedExpr
|
|
416
|
|
- :: CoreTickish -- ^ tick to add
|
|
|
416
|
+ :: Bool -- ^ preserve ANF? (See 'mkTickCpe' and
|
|
|
417
|
+ -- Note [mkTick breaks ANF] in GHC.CoreToStg.Prep)
|
|
|
418
|
+ -> CoreTickish -- ^ tick to add
|
|
417
|
419
|
-> NE.NonEmpty CoreTickish -- ^ existing stack of ticks
|
|
418
|
420
|
-> CoreExpr -- ^ inner core expression
|
|
419
|
421
|
-> CoreExpr
|
|
420
|
|
-tickTickedExpr t1 t2s e
|
|
|
422
|
+tickTickedExpr preserve_anf t1 t2s e
|
|
421
|
423
|
|
|
422
|
424
|
-- Case 1: common up 't1' with a tick in the stack.
|
|
423
|
425
|
--
|
| ... |
... |
@@ -431,8 +433,24 @@ tickTickedExpr t1 t2s e |
|
431
|
433
|
-- Case 2: 't1' can be commuted past all the ticks in the stack, e.g. because
|
|
432
|
434
|
-- it has tighter placement properties than all the ticks in the stack.
|
|
433
|
435
|
-- Push it inwards to expose cancellation opportunities.
|
|
|
436
|
+ --
|
|
|
437
|
+ -- We must thread 'preserve_anf' through here. Otherwise we may turn the
|
|
|
438
|
+ -- argument
|
|
|
439
|
+ --
|
|
|
440
|
+ -- scc<f> (src<l> (Just x))
|
|
|
441
|
+ --
|
|
|
442
|
+ -- into the ill-formed argument
|
|
|
443
|
+ --
|
|
|
444
|
+ -- src<l> (Just (scc<f> x)) -- SCC on an argument: not a CpeArg!
|
|
|
445
|
+ --
|
|
|
446
|
+ -- whereas with preserve_anf we keep the SCC outside the application,
|
|
|
447
|
+ -- respecting ANF:
|
|
|
448
|
+ --
|
|
|
449
|
+ -- src<l> (scc<f> (Just breakpoint))
|
|
|
450
|
+ --
|
|
|
451
|
+ -- See Note [mkTick breaks ANF] in GHC.CoreToStg.Prep and #27415.
|
|
434
|
452
|
| all (tickishCommutable t1) t2s
|
|
435
|
|
- = apply_ticks t2s $ mkTick t1 e
|
|
|
453
|
+ = apply_ticks t2s $ mk_tick preserve_anf t1 e
|
|
436
|
454
|
|
|
437
|
455
|
-- Fallback: keep the new tick on the outside.
|
|
438
|
456
|
| otherwise
|
| ... |
... |
@@ -455,7 +473,7 @@ tickTickedExpr t1 t2s e |
|
455
|
473
|
|
|
456
|
474
|
{- Note [Pushing SCCs inwards]
|
|
457
|
475
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
458
|
|
-Amongst all ticks, SCCs have the laxest placement properties (PlaceCostCentre,
|
|
|
476
|
+Amongst all ticks, SCCs have the most lax placement properties (PlaceCostCentre,
|
|
459
|
477
|
as described in Note [Tickish placement] GHC.Types.Tickish):
|
|
460
|
478
|
|
|
461
|
479
|
(PSCC1) SCCs around non-function variables can be eliminated.
|