... |
... |
@@ -432,9 +432,20 @@ idRuleAndUnfoldingVars of x. No need for type variables, hence not using |
432
|
432
|
idFreeVars.
|
433
|
433
|
-}
|
434
|
434
|
|
|
435
|
+fiExpr platform to_drop (_,AnnLet (AnnNonRec bndr (rhs_fvs, rhs)) body)
|
|
436
|
+ | Just bind' <- is_tyco_rhs rhs -- See Note [Don't float in type or coercion lets]
|
|
437
|
+ = wrapFloats drop_here $
|
|
438
|
+ Let bind' (fiExpr platform body_drop body)
|
|
439
|
+ where
|
|
440
|
+ is_tyco_rhs :: CoreExprWithFVs' -> Maybe CoreBind
|
|
441
|
+ is_tyco_rhs (AnnType ty) = Just (NonRec bndr (Type ty))
|
|
442
|
+ is_tyco_rhs (AnnCoercion co) = Just (NonRec bndr (Coercion co))
|
|
443
|
+ is_tyco_rhs _ = Nothing
|
|
444
|
+
|
|
445
|
+ (drop_here, [body_drop]) = sepBindsByDropPoint platform False to_drop
|
|
446
|
+ rhs_fvs [freeVarsOf body]
|
|
447
|
+
|
435
|
448
|
fiExpr platform to_drop (_,AnnLet bind body)
|
436
|
|
- | Just bind' <- is_tyco_bind bind -- See Note [Don't float in type or coercion lets]
|
437
|
|
- = Let bind' (fiExpr platform to_drop body)
|
438
|
449
|
| otherwise
|
439
|
450
|
= fiExpr platform (after ++ new_float : before) body
|
440
|
451
|
-- to_drop is in reverse dependency order
|
... |
... |
@@ -442,10 +453,6 @@ fiExpr platform to_drop (_,AnnLet bind body) |
442
|
453
|
(before, new_float, after) = fiBind platform to_drop bind body_fvs
|
443
|
454
|
body_fvs = freeVarsOf body
|
444
|
455
|
|
445
|
|
- is_tyco_bind :: CoreBindWithFVs -> Maybe CoreBind
|
446
|
|
- is_tyco_bind (AnnNonRec bndr (_, AnnType ty)) = Just (NonRec bndr (Type ty))
|
447
|
|
- is_tyco_bind (AnnNonRec bndr (_, AnnCoercion co)) = Just (NonRec bndr (Coercion co))
|
448
|
|
- is_tyco_bind _ = Nothing
|
449
|
456
|
|
450
|
457
|
{- Note [Floating primops]
|
451
|
458
|
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
... |
... |
@@ -530,7 +537,7 @@ Note [Don't float in type or coercion lets] |
530
|
537
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
531
|
538
|
We don't float type-lets or coercion-lets inward. Doing so does not
|
532
|
539
|
save allocation; and if we did we't have to be careful of the variables
|
533
|
|
-mentiond in the idType of the case-binder. For example
|
|
540
|
+mentioned in the idType of the case-binder. For example
|
534
|
541
|
\(x :: Maybe b) -> let a = Maybe b in
|
535
|
542
|
case x of (cb :: a) of { Just y -> ... }
|
536
|
543
|
We must not float the `a = Maybe b` into the case alternatives, because
|