projects
/
ghc-hetmet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Improve arity propagation in the specialiser
[ghc-hetmet.git]
/
compiler
/
specialise
/
Specialise.lhs
diff --git
a/compiler/specialise/Specialise.lhs
b/compiler/specialise/Specialise.lhs
index
4d8efdd
..
037db7a
100644
(file)
--- a/
compiler/specialise/Specialise.lhs
+++ b/
compiler/specialise/Specialise.lhs
@@
-15,8
+15,8
@@
module Specialise ( specProgram ) where
#include "HsVersions.h"
import Id ( Id, idName, idType, mkUserLocal, idCoreRules,
#include "HsVersions.h"
import Id ( Id, idName, idType, mkUserLocal, idCoreRules,
- idInlinePragma, setInlinePragma, setIdUnfolding,
- isLocalId )
+ idInlineActivation, setInlineActivation, setIdUnfolding,
+ isLocalId, idArity, setIdArity )
import TcType ( Type, mkTyVarTy, tcSplitSigmaTy,
tyVarsOfTypes, tyVarsOfTheta, isClassPred,
tcCmpType, isUnLiftedType
import TcType ( Type, mkTyVarTy, tcSplitSigmaTy,
tyVarsOfTypes, tyVarsOfTheta, isClassPred,
tcCmpType, isUnLiftedType
@@
-826,10
+826,11
@@
specDefn subst calls fn rhs
where
fn_type = idType fn
where
fn_type = idType fn
+ fn_arity = idArity fn
(tyvars, theta, _) = tcSplitSigmaTy fn_type
n_tyvars = length tyvars
n_dicts = length theta
(tyvars, theta, _) = tcSplitSigmaTy fn_type
n_tyvars = length tyvars
n_dicts = length theta
- inline_prag = idInlinePragma fn
+ inline_act = idInlineActivation fn
-- It's important that we "see past" any INLINE pragma
-- else we'll fail to specialise an INLINE thing
-- It's important that we "see past" any INLINE pragma
-- else we'll fail to specialise an INLINE thing
@@
-906,6
+907,10
@@
specDefn subst calls fn rhs
spec_id_ty = mkPiTypes lam_args body_ty
; spec_f <- newSpecIdSM fn spec_id_ty
spec_id_ty = mkPiTypes lam_args body_ty
; spec_f <- newSpecIdSM fn spec_id_ty
+ ; let spec_f_w_arity = setIdArity spec_f (max 0 (fn_arity - n_dicts))
+ -- Adding arity information just propagates it a bit faster
+ -- See Note [Arity decrease] in Simplify
+
; (spec_rhs, rhs_uds) <- specExpr rhs_subst2 (mkLams lam_args body)
; let
-- The rule to put in the function's specialisation is:
; (spec_rhs, rhs_uds) <- specExpr rhs_subst2 (mkLams lam_args body)
; let
-- The rule to put in the function's specialisation is:
@@
-913,17
+918,17
@@
specDefn subst calls fn rhs
rule_name = mkFastString ("SPEC " ++ showSDoc (ppr fn <+> ppr spec_ty_args))
spec_env_rule = mkLocalRule
rule_name
rule_name = mkFastString ("SPEC " ++ showSDoc (ppr fn <+> ppr spec_ty_args))
spec_env_rule = mkLocalRule
rule_name
- inline_prag -- Note [Auto-specialisation and RULES]
+ inline_act -- Note [Auto-specialisation and RULES]
(idName fn)
(poly_tyvars ++ inst_dict_ids)
inst_args
(idName fn)
(poly_tyvars ++ inst_dict_ids)
inst_args
- (mkVarApps (Var spec_f) app_args)
+ (mkVarApps (Var spec_f_w_arity) app_args)
-- Add the { d1' = dx1; d2' = dx2 } usage stuff
final_uds = foldr addDictBind rhs_uds dx_binds
-- Add the { d1' = dx1; d2' = dx2 } usage stuff
final_uds = foldr addDictBind rhs_uds dx_binds
- spec_pr | inline_rhs = (spec_f `setInlinePragma` inline_prag, Note InlineMe spec_rhs)
- | otherwise = (spec_f, spec_rhs)
+ spec_pr | inline_rhs = (spec_f_w_arity `setInlineActivation` inline_act, Note InlineMe spec_rhs)
+ | otherwise = (spec_f_w_arity, spec_rhs)
; return (Just (spec_pr, final_uds, spec_env_rule)) } }
where
; return (Just (spec_pr, final_uds, spec_env_rule)) } }
where
@@
-1068,7
+1073,8
@@
Note [Inline specialisations]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We transfer to the specialised function any INLINE stuff from the
original. This means (a) the Activation in the IdInfo, and (b) any
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
We transfer to the specialised function any INLINE stuff from the
original. This means (a) the Activation in the IdInfo, and (b) any
-InlineMe on the RHS.
+InlineMe on the RHS. We do not, however, transfer the RuleMatchInfo
+since we do not expect the specialisation to occur in rewrite rules.
This is a change (Jun06). Previously the idea is that the point of
inlining was precisely to specialise the function at its call site,
This is a change (Jun06). Previously the idea is that the point of
inlining was precisely to specialise the function at its call site,