preserve call cache between inlining passes, propagate uinteq
This commit is contained in:
parent
4bbde1f02e
commit
70d545879e
3 changed files with 17 additions and 8 deletions
6
test.zok
6
test.zok
|
@ -1,6 +0,0 @@
|
|||
def bar<K>(field[K] a, field[K] b) -> field[K]:
|
||||
return a
|
||||
|
||||
def main(u32 s) -> field[1]:
|
||||
field[s - 3] c = [1]
|
||||
return bar([1], c)
|
|
@ -1037,6 +1037,17 @@ impl<'ast, T: Field> Folder<'ast, T> for Propagator<'ast, T> {
|
|||
(e1, e2) => BooleanExpression::FieldEq(box e1, box e2),
|
||||
}
|
||||
}
|
||||
BooleanExpression::UintEq(box e1, box e2) => {
|
||||
let e1 = self.fold_uint_expression(e1);
|
||||
let e2 = self.fold_uint_expression(e2);
|
||||
|
||||
match (e1.as_inner(), e2.as_inner()) {
|
||||
(UExpressionInner::Value(v1), UExpressionInner::Value(v2)) => {
|
||||
BooleanExpression::Value(v1 == v2)
|
||||
}
|
||||
_ => BooleanExpression::UintEq(box e1, box e2),
|
||||
}
|
||||
}
|
||||
BooleanExpression::BoolEq(box e1, box e2) => {
|
||||
let e1 = self.fold_boolean_expression(e1);
|
||||
let e2 = self.fold_boolean_expression(e2);
|
||||
|
|
|
@ -228,7 +228,7 @@ struct Reducer<'ast, 'a, T> {
|
|||
program: &'a TypedProgram<'ast, T>,
|
||||
versions: &'a mut Versions<'ast>,
|
||||
substitutions: &'a mut Substitutions<'ast>,
|
||||
cache: CallCache<'ast, T>,
|
||||
cache: &'a mut CallCache<'ast, T>,
|
||||
complete: bool,
|
||||
}
|
||||
|
||||
|
@ -237,6 +237,7 @@ impl<'ast, 'a, T: Field> Reducer<'ast, 'a, T> {
|
|||
program: &'a TypedProgram<'ast, T>,
|
||||
versions: &'a mut Versions<'ast>,
|
||||
substitutions: &'a mut Substitutions<'ast>,
|
||||
cache: &'a mut CallCache<'ast, T>,
|
||||
for_loop_versions: Vec<Versions<'ast>>,
|
||||
) -> Self {
|
||||
// we reverse the vector as it's cheaper to `pop` than to take from
|
||||
|
@ -249,7 +250,7 @@ impl<'ast, 'a, T: Field> Reducer<'ast, 'a, T> {
|
|||
statement_buffer: vec![],
|
||||
for_loop_versions_after: vec![],
|
||||
for_loop_versions,
|
||||
cache: CallCache::default(),
|
||||
cache: cache,
|
||||
substitutions,
|
||||
program,
|
||||
versions,
|
||||
|
@ -601,6 +602,8 @@ fn reduce_function<'ast, T: Field>(
|
|||
|
||||
let mut substitutions = Substitutions::default();
|
||||
|
||||
let mut call_cache = CallCache::new();
|
||||
|
||||
let mut hash = None;
|
||||
|
||||
loop {
|
||||
|
@ -608,6 +611,7 @@ fn reduce_function<'ast, T: Field>(
|
|||
&program,
|
||||
&mut versions,
|
||||
&mut substitutions,
|
||||
&mut call_cache,
|
||||
for_loop_versions,
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue