From 0222d11b2db45c55d2980ae4503d6053fa7b73e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9onard=20G=C3=A9rard?= Date: Wed, 2 Nov 2011 23:53:54 +0100 Subject: [PATCH] Do not introduce useless variable in [reset every] --- compiler/heptagon/transformations/reset.ml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/compiler/heptagon/transformations/reset.ml b/compiler/heptagon/transformations/reset.ml index 8262ad6..c1057ed 100644 --- a/compiler/heptagon/transformations/reset.ml +++ b/compiler/heptagon/transformations/reset.ml @@ -95,8 +95,12 @@ let block funs (res,_) b = Hept_mapfold.block funs (res,b.b_stateful) b (* Transform reset blocks in blocks with reseted exps, - create a var to store the reset condition evaluation. *) + create a var to store the reset condition evaluation if not already a var. *) let eqdesc funs (res,stateful) = function + | Ereset(b, ({ e_desc = Evar x } as e)) -> + let r = if stateful then merge_resets res (Some e) else res in + let b, _ = Hept_mapfold.block_it funs (r,stateful) b in + Eblock(b), (res,stateful) | Ereset(b, e) -> if stateful then ( let e, _ = Hept_mapfold.exp_it funs (res,stateful) e in