seqExpr (App f a) = seqExpr f `seq` seqExpr a
seqExpr (Lam b e) = seqBndr b `seq` seqExpr e
seqExpr (Let b e) = seqBind b `seq` seqExpr e
--- gaw 2004
seqExpr (Case e b t as) = seqExpr e `seq` seqBndr b `seq` seqType t `seq` seqAlts as
seqExpr (Cast e co) = seqExpr e `seq` seqType co
seqExpr (Note n e) = seqNote n `seq` seqExpr e
| AnnLit Literal
| AnnLam bndr (AnnExpr bndr annot)
| AnnApp (AnnExpr bndr annot) (AnnExpr bndr annot)
--- gaw 2004
| AnnCase (AnnExpr bndr annot) bndr Type [AnnAlt bndr annot]
| AnnLet (AnnBind bndr annot) (AnnExpr bndr annot)
| AnnCast (AnnExpr bndr annot) Coercion
deAnnBind (AnnNonRec var rhs) = NonRec var (deAnnotate rhs)
deAnnBind (AnnRec pairs) = Rec [(v,deAnnotate rhs) | (v,rhs) <- pairs]
--- gaw 2004
deAnnotate' (AnnCase scrut v t alts)
= Case (deAnnotate scrut) v t (map deAnnAlt alts)
-> SimplM FloatsWithExpr
mkAtomicArgsE env is_strict (Cast rhs co) thing_inside
+ | not (exprIsTrivial rhs)
-- Note [Float coersions]
+ -- See also Note [Take care] below
= do { id <- newId FSLIT("a") (exprType rhs)
; completeNonRecX env False id id rhs $ \ env ->
thing_inside env (Cast (Var id) co) }
= do { arg_id <- newId FSLIT("a") arg_ty
; completeNonRecX env False {- pessimistic -} arg_id arg_id arg $ \env ->
go env (App fun (Var arg_id)) args }
+ -- Note [Take care]:
+ -- This is sightly delicate. If completeNonRecX was to do a postInlineUnconditionally
+ -- (undoing the effect of introducing the let-binding), we'd find arg_id had
+ -- no binding. The exprIsTrivial is the only time that'll happen, though.
where
arg_ty = exprType arg
no_float_arg = not is_strict && (isUnLiftedType arg_ty) && not (exprOkForSpeculation arg)
-- if the strict-binding flag is on
mkAtomicArgs ok_float_unlifted (Cast rhs co)
+ | not (exprIsTrivial rhs)
-- Note [Float coersions]
= do { id <- newId FSLIT("a") (exprType rhs)
; (binds, rhs') <- mkAtomicArgs ok_float_unlifted rhs