From cbd4eedf0d278572e70b04d9e9ef8750c4cae0a4 Mon Sep 17 00:00:00 2001 From: Thomas Bauereiss Date: Thu, 13 Dec 2018 20:37:36 +0000 Subject: Remove redundant zero extensions more aggressively in mono rewrites subrange_subrange_concat does a zero extension internally, so another zero extension of its result is redundant and can lead to a type error in Lem (because Lem's type system cannot calculate the length of the intermediate result of subrange_subrange_concat). --- lib/mono_rewrites.sail | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/mono_rewrites.sail b/lib/mono_rewrites.sail index 0825f9d0..93ad3db5 100644 --- a/lib/mono_rewrites.sail +++ b/lib/mono_rewrites.sail @@ -82,15 +82,13 @@ function subrange_subrange_eq (xs, i, j, ys, i', j') = { xs == ys } -val subrange_subrange_concat : forall 'n 'o 'p 'm 'q 'r 's, 's == 'o - ('p - 1) + 'q - ('r - 1) & 'n >= 0 & 'm >= 0. +val subrange_subrange_concat : forall 'n 'o 'p 'm 'q 'r 's, 's >= 0 & 'n >= 0 & 'm >= 0. (bits('n), atom('o), atom('p), bits('m), atom('q), atom('r)) -> bits('s) effect pure function subrange_subrange_concat (xs, i, j, ys, i', j') = { let xs = (xs & slice_mask(j,i-j+1)) >> j in let ys = (ys & slice_mask(j',i'-j'+1)) >> j' in - // We need to avoid sizeof-rewriting - // extzv(xs) << (i' - j' + 1) | extzv(ys) - extz_vec(i - (j - 1) + i' - (j' - 1), xs) << (i' - j' + 1) | extz_vec(i - (j - 1) + i' - (j' - 1), ys) + extzv(xs) << (i' - j' + 1) | extzv(ys) } val place_subrange : forall 'n 'm, 'n >= 0 & 'm >= 0. -- cgit v1.2.3