opt_proof g (info st "Optimizer: remove 3") es c x
and opt_mutcase_plain g st es c uri tyno outty arg cases =
- let g st v ts = g st (C.MutCase (uri, tyno, outty, v, ts)) in
- g st arg cases
+ let g st v =
+ let g (st, ts) = g st (C.MutCase (uri, tyno, outty, v, ts)) in
+ let map h v (st, vs) =
+ let h st vv = h (st, vv :: vs) in opt_proof h st es c v
+ in
+ if es then H.list_fold_right_cps g map cases (st, []) else g (st, cases)
+ in
+ if es then opt_proof g st es c arg else g st arg
and opt_mutcase g =
if !critical then opt_mutcase_critical g else opt_mutcase_plain g
let optimize_obj = function
| C.Constant (name, Some bo, ty, pars, attrs) ->
+ let count_nodes = I.count_nodes ~meta:false 0 in
let st, c = {info = ""; dummy = ()}, [] in
let bo, ty = H.cic_bc c bo, H.cic_bc c ty in
let g st bo =
Ut.pp_term prerr_string [] c bo; prerr_newline ()
end;
(* let _ = H.get_type "opt" [] (C.Cast (bo, ty)) in *)
- let nodes = Printf.sprintf "Optimized nodes: %u" (I.count_nodes 0 bo) in
+ let nodes = Printf.sprintf "Optimized nodes: %u" (count_nodes bo) in
let st = info st nodes in
L.time_stamp ("PO: DONE " ^ name);
C.Constant (name, Some bo, ty, pars, attrs), st.info
in
L.time_stamp ("PO: OPTIMIZING " ^ name);
if !debug then Printf.eprintf "BEGIN: %s\n" name;
- let nodes = Printf.sprintf "Initial nodes: %u" (I.count_nodes 0 bo) in
+ let nodes = Printf.sprintf "Initial nodes: %u" (count_nodes bo) in
wrap g (info st nodes) c bo
| obj -> obj, ""