Skip to content

Commit f203622

Browse files
committed
Simplify boolean optimisation
1 parent 3a001c7 commit f203622

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

compiler/core/lam_pass_remove_alias.ml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,19 @@
2424

2525
type outcome = Eval_false | Eval_true | Eval_unknown
2626

27-
let rec id_is_for_sure_true_in_boolean (tbl : Lam_stats.ident_tbl) id =
27+
let id_is_for_sure_true_in_boolean (tbl : Lam_stats.ident_tbl) id =
2828
match Hash_ident.find_opt tbl id with
29-
| Some
30-
(Normal_optional
31-
( Lprim {loc = _; primitive = Psome_not_nest; args = [Lvar id']}
32-
| Lvar id' )) ->
33-
id_is_for_sure_true_in_boolean tbl id'
3429
| Some
3530
(Normal_optional
3631
(Lconst (Const_js_false | Const_js_null | Const_js_undefined _))) ->
3732
Eval_false
38-
| Some (Normal_optional _)
39-
| Some (ImmutableBlock _)
40-
| Some (MutableBlock _)
41-
| Some (Constant (Const_block _ | Const_js_true)) ->
42-
Eval_true
33+
| Some (Constant Const_js_true) -> Eval_true
4334
| Some (Constant (Const_int {i})) -> if i = 0l then Eval_false else Eval_true
4435
| Some (Constant (Const_js_false | Const_js_null | Const_js_undefined _)) ->
4536
Eval_false
4637
| Some
47-
( Constant _ | Module _ | FunctionId _ | Exception | Parameter | NA
38+
( Normal_optional _ | ImmutableBlock _ | MutableBlock _ | Constant _
39+
| Module _ | FunctionId _ | Exception | Parameter | NA
4840
| OptionalBlock (_, (Undefined | Null | Null_undefined)) )
4941
| None ->
5042
Eval_unknown

0 commit comments

Comments
 (0)