@@ -138,7 +138,7 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
138138 | Some v -> v <> Parameter
139139 | None -> true )
140140 | _ -> true ) ->
141- simpl (Lam_beta_reduce. propogate_beta_reduce meta params body args)
141+ simpl (Lam_beta_reduce. propagate_beta_reduce meta params body args)
142142 | _ -> Lam. apply (simpl l1) (Ext_list. map args simpl) ap_info)
143143 (* Function inlining interact with other optimizations...
144144
@@ -160,7 +160,7 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
160160 Some
161161 ( Lfunction ({ params; body; attr = { is_a_functor } } as m),
162162 rec_flag );
163- }) ->
163+ }) when Lam_analysis. lfunction_can_be_beta_reduced m ->
164164 if Ext_list. same_length ap_args params (* && false *) then
165165 if
166166 is_a_functor
@@ -174,7 +174,7 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
174174 (* Check: recursive applying may result in non-termination *)
175175 (* Ext_log.dwarn __LOC__ "beta .. %s/%d" v.name v.stamp ; *)
176176 simpl
177- (Lam_beta_reduce. propogate_beta_reduce meta params body
177+ (Lam_beta_reduce. propagate_beta_reduce meta params body
178178 ap_args)
179179 else if
180180 (* Lam_analysis.size body < Lam_analysis.small_inline_size *)
@@ -194,7 +194,7 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
194194 | false , (_ , param_map ) | true , (true , param_map ) -> (
195195 match rec_flag with
196196 | Lam_rec ->
197- Lam_beta_reduce. propogate_beta_reduce_with_map meta
197+ Lam_beta_reduce. propagate_beta_reduce_with_map meta
198198 param_map params body ap_args
199199 | Lam_self_rec -> normal ()
200200 | Lam_non_rec ->
@@ -205,15 +205,15 @@ let simplify_alias (meta : Lam_stats.t) (lam : Lam.t) : Lam.t =
205205 then normal ()
206206 else
207207 simpl
208- (Lam_beta_reduce. propogate_beta_reduce_with_map meta
208+ (Lam_beta_reduce. propagate_beta_reduce_with_map meta
209209 param_map params body ap_args))
210210 | _ -> normal ()
211211 else normal ()
212212 else normal ()
213213 | Some _ | None -> normal () )
214- | Lapply { ap_func = Lfunction { params; body }; ap_args = args; _ }
215- when Ext_list. same_length params args ->
216- simpl (Lam_beta_reduce. propogate_beta_reduce meta params body args)
214+ | Lapply { ap_func = Lfunction ( { params; body } as lfunction) ; ap_args = args; _ }
215+ when Ext_list. same_length params args && Lam_analysis. lfunction_can_be_beta_reduced lfunction ->
216+ simpl (Lam_beta_reduce. propagate_beta_reduce meta params body args)
217217 (* | Lapply{ fn = Lfunction{function_kind = Tupled; params; body}; *)
218218 (* args = [Lprim {primitive = Pmakeblock _; args; _}]; _} *)
219219 (* (\** TODO: keep track of this parameter in ocaml trunk, *)
0 commit comments