summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Campbell2018-02-02 16:31:25 +0000
committerBrian Campbell2018-02-02 16:31:25 +0000
commitf5723aebea8a0e22def3072710384f2410f65e46 (patch)
treeca001e2ca4c64a141d3853c8424d5f237947ed73 /src
parent3ebce8457eb25f3ddceda77530c81580003296de (diff)
Extra nexp simplification
Diffstat (limited to 'src')
-rw-r--r--src/ast_util.ml4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/ast_util.ml b/src/ast_util.ml
index 891990b4..6b605886 100644
--- a/src/ast_util.ml
+++ b/src/ast_util.ml
@@ -193,6 +193,10 @@ let rec is_nexp_constant (Nexp_aux (nexp, _)) = match nexp with
let rec nexp_simp (Nexp_aux (nexp, l)) = Nexp_aux (nexp_simp_aux nexp, l)
and nexp_simp_aux = function
+ (* (n - (n - m)) often appears in foreach loops *)
+ | Nexp_minus (nexp1, Nexp_aux (Nexp_minus (nexp2, Nexp_aux (n3,_)),_))
+ when nexp_identical nexp1 nexp2 ->
+ nexp_simp_aux n3
| Nexp_minus (Nexp_aux (Nexp_sum (Nexp_aux (n1, _), nexp2), _), nexp3)
when nexp_identical nexp2 nexp3 ->
nexp_simp_aux n1