| ... |
... |
@@ -2657,7 +2657,7 @@ fireRuleAFTER env rule_match arg_specs cont |
|
2657
|
2657
|
pushArgs env' Simplified (exprType rhs) rhs_args $
|
|
2658
|
2658
|
pushArgSpecs env' (drop (ruleArity rule) arg_specs) cont
|
|
2659
|
2659
|
; return $
|
|
2660
|
|
- if isEmptyBindWrapper wrap
|
|
|
2660
|
+ if isEmptyBindWrapper wrap -- Not very pretty
|
|
2661
|
2661
|
then (floats, e')
|
|
2662
|
2662
|
else (emptyFloats env', applyBindWrapper wrap $
|
|
2663
|
2663
|
wrapFloats floats e') }
|
| ... |
... |
@@ -2733,7 +2733,7 @@ tryRules env rules fn args |
|
2733
|
2733
|
trySeqRules :: SimplEnv
|
|
2734
|
2734
|
-> OutExpr -> InExpr -- Scrutinee and RHS
|
|
2735
|
2735
|
-> SimplCont
|
|
2736
|
|
- -> SimplM (Maybe (CoreExpr, SimplCont))
|
|
|
2736
|
+ -> SimplM (Maybe (RuleMatch, [ArgSpec], SimplCont))
|
|
2737
|
2737
|
-- See Note [User-defined RULES for seq]
|
|
2738
|
2738
|
-- `in_env` applies to `rhs :: InExpr` but not to `scrut :: OutExpr`
|
|
2739
|
2739
|
trySeqRules in_env scrut rhs cont
|
| ... |
... |
@@ -2742,7 +2742,7 @@ trySeqRules in_env scrut rhs cont |
|
2742
|
2742
|
; mb_match <- tryRules in_env seq_rules seqId out_args
|
|
2743
|
2743
|
; case mb_match of
|
|
2744
|
2744
|
Nothing -> return Nothing
|
|
2745
|
|
- Just rule_match -> Just <$> fireRuleAFTER in_env rule_match out_arg_specs cont }
|
|
|
2745
|
+ Just rule_match -> return (Just (rule_match, arg_specs, rule_cont)) }
|
|
2746
|
2746
|
where
|
|
2747
|
2747
|
no_cast_scrut = drop_casts scrut
|
|
2748
|
2748
|
|
| ... |
... |
@@ -2756,21 +2756,23 @@ trySeqRules in_env scrut rhs cont |
|
2756
|
2756
|
rhs_ty = substTy in_env (exprType rhs)
|
|
2757
|
2757
|
rhs_rep = getRuntimeRep rhs_ty
|
|
2758
|
2758
|
|
|
2759
|
|
- out_args = [Type rhs_rep, Type scrut_ty, Type rhs_ty, no_cast_scrut]
|
|
2760
|
|
- -- Cheaper than (map argSpecArg out_arg_specs)
|
|
2761
|
|
- out_arg_specs = [ TyArg { as_arg_ty = rhs_rep
|
|
2762
|
|
- , as_hole_ty = seq_id_ty }
|
|
2763
|
|
- , TyArg { as_arg_ty = scrut_ty
|
|
2764
|
|
- , as_hole_ty = res1_ty }
|
|
2765
|
|
- , TyArg { as_arg_ty = rhs_ty
|
|
2766
|
|
- , as_hole_ty = res2_ty }
|
|
2767
|
|
- , ValArg { as_arg = no_cast_scrut
|
|
2768
|
|
- , as_dmd = seqDmd
|
|
2769
|
|
- , as_hole_ty = res3_ty } ]
|
|
|
2759
|
+ arg_specs :: [ArgSpec]
|
|
|
2760
|
+ arg_specs = [ TyArg { as_arg_ty = rhs_rep
|
|
|
2761
|
+ , as_hole_ty = seq_id_ty }
|
|
|
2762
|
+ , TyArg { as_arg_ty = scrut_ty
|
|
|
2763
|
+ , as_hole_ty = res1_ty }
|
|
|
2764
|
+ , TyArg { as_arg_ty = rhs_ty
|
|
|
2765
|
+ , as_hole_ty = res2_ty }
|
|
|
2766
|
+ , ValArg { as_arg = no_cast_scrut
|
|
|
2767
|
+ , as_dmd = seqDmd
|
|
|
2768
|
+ , as_hole_ty = res3_ty } ]
|
|
2770
|
2769
|
rule_cont = ApplyToVal { sc_dup = NoDup, sc_arg = rhs
|
|
2771
|
2770
|
, sc_env = in_env, sc_cont = cont
|
|
2772
|
2771
|
, sc_hole_ty = res4_ty }
|
|
2773
|
2772
|
|
|
|
2773
|
+ out_args = [Type rhs_rep, Type scrut_ty, Type rhs_ty, no_cast_scrut]
|
|
|
2774
|
+ -- Cheaper than (map argSpecArg out_arg_specs)
|
|
|
2775
|
+
|
|
2774
|
2776
|
-- Lazily evaluated, so we don't do most of this
|
|
2775
|
2777
|
drop_casts (Cast e _) = drop_casts e
|
|
2776
|
2778
|
drop_casts e = e
|
| ... |
... |
@@ -3196,8 +3198,8 @@ rebuildCase env scrut case_bndr alts@[Alt _ bndrs rhs] cont |
|
3196
|
3198
|
| is_plain_seq
|
|
3197
|
3199
|
= do { mb_rule <- trySeqRules env scrut rhs cont
|
|
3198
|
3200
|
; case mb_rule of
|
|
3199
|
|
- Just (rule_rhs, cont') -> simplExprF (zapSubstEnv env) rule_rhs cont'
|
|
3200
|
|
- Nothing -> reallyRebuildCase env scrut case_bndr alts cont }
|
|
|
3201
|
+ Just (rm, ass, rcont) -> fireRuleAFTER env rm ass rcont
|
|
|
3202
|
+ Nothing -> reallyRebuildCase env scrut case_bndr alts cont }
|
|
3201
|
3203
|
|
|
3202
|
3204
|
--------------------------------------------------
|
|
3203
|
3205
|
-- 3. Primop-related case-rules
|