Skip to content

Commit 8f46e59

Browse files
committed
Revert "Fix CSE equations on params (#2628)"
This reverts commit 7676c07.
1 parent 9df4c64 commit 8f46e59

File tree

1 file changed

+5
-23
lines changed

1 file changed

+5
-23
lines changed

middle_end/flambda2/simplify/common_subexpression_elimination.ml

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -105,33 +105,18 @@ end
105105

106106
let cse_with_eligible_lhs ~typing_env_at_fork ~cse_at_each_use ~params prev_cse
107107
(extra_bindings : EPA.t) extra_equations =
108-
let params_set =
109-
List.map params ~f:Bound_parameter.name |> Name.Set.of_list
110-
in
111-
let params = List.map params ~f:Bound_parameter.simple in
108+
let params = List.map params ~f:Bound_parameter.name |> Name.Set.of_list in
112109
let is_param simple =
113110
Simple.pattern_match simple
114-
~name:(fun name ~coercion:_ -> Name.Set.mem name params_set)
111+
~name:(fun name ~coercion:_ -> Name.Set.mem name params)
115112
~const:(fun _ -> false)
116113
in
117114
List.fold_left cse_at_each_use ~init:EP.Map.empty
118115
~f:(fun eligible (env_at_use, id, cse) ->
119116
let find_new_name =
120-
let find_param simple params =
121-
List.find_opt
122-
~f:(fun param ->
123-
match
124-
TE.get_canonical_simple_exn env_at_use param
125-
~min_name_mode:NM.normal
126-
~name_mode_of_existing_simple:NM.normal
127-
with
128-
| exception Not_found -> false
129-
| arg -> Simple.equal arg simple)
130-
params
131-
in
132117
match (extra_bindings : EPA.t) with
133-
| Empty -> fun arg -> find_param arg params
134-
| Non_empty { extra_args; extra_params } -> (
118+
| Empty -> fun _arg -> None
119+
| Non_empty { extra_args; extra_params } ->
135120
let extra_args = RI.Map.find id extra_args in
136121
let rec find_name simple params args =
137122
match args, params with
@@ -152,10 +137,7 @@ let cse_with_eligible_lhs ~typing_env_at_fork ~cse_at_each_use ~params prev_cse
152137
find_name simple params args)
153138
in
154139
fun arg ->
155-
match find_param arg params with
156-
| None ->
157-
find_name arg (Bound_parameters.to_list extra_params) extra_args
158-
| Some _ as r -> r)
140+
find_name arg (Bound_parameters.to_list extra_params) extra_args
159141
in
160142
EP.Map.fold
161143
(fun prim bound_to eligible ->

0 commit comments

Comments
 (0)