From 01d2b498ba47113f0d10fbd734c7dd99e3a39c76 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Sat, 7 Jan 2023 11:07:18 +0100 Subject: Improve PureMicroPasses.filter_useless and regenerate the betree code --- compiler/PureMicroPasses.ml | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'compiler/PureMicroPasses.ml') diff --git a/compiler/PureMicroPasses.ml b/compiler/PureMicroPasses.ml index 25d760fe..b9441397 100644 --- a/compiler/PureMicroPasses.ml +++ b/compiler/PureMicroPasses.ml @@ -828,6 +828,14 @@ let filter_useless (filter_monadic_calls : bool) (ctx : trans_ctx) let dont_filter () = let re, used_re = self#visit_texpression env re in let used = VarId.Set.union used (used_re ()) in + (* Simplify the left pattern if it only contains dummy variables *) + let lv = + if all_dummies then + let ty = lv.ty in + let value = PatDummy in + { value; ty } + else lv + in (Let (monadic, lv, re, e), fun _ -> used) in (* Potentially filter the let-binding *) -- cgit v1.2.3