Skip to content

Commit 7201d3b

Browse files
committed
sca: remove Deque since the order should not matter anymore (for correctness)
1 parent f1aa7c5 commit 7201d3b

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

patronus-sca/src/lib.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,8 @@
33
// author: Kevin Laeufer <laeufer@cornell.edu>
44

55
use baa::{BitVecOps, BitVecValue, BitVecValueRef};
6-
use patronus::expr::{
7-
Context, DenseExprMetaData, Expr, ExprRef, ForEachChild, SerializableIrNode, Simplifier,
8-
TypeCheck, WidthInt, count_expr_uses, traversal,
9-
};
6+
use patronus::expr::*;
107
use polysub::{Coef, Term, VarIndex};
11-
use std::collections::VecDeque;
128
use std::fmt::{Display, Formatter};
139

1410
/// Returns a new expressions reference if simplification was possible
@@ -50,6 +46,8 @@ pub fn simplify_word_level_equality(ctx: &mut Context, p: ScaEqualityProblem) ->
5046
}
5147
}
5248

49+
/// Extracts a bit from a concatenation. We use this to avoid having to call the full blown
50+
/// simplifier.
5351
fn extract_bit(ctx: &mut Context, e: ExprRef, bit: WidthInt) -> ExprRef {
5452
match ctx[e].clone() {
5553
Expr::BVConcat(a, b, _) => {
@@ -90,7 +88,7 @@ fn is_gate(expr: &Expr) -> bool {
9088
)
9189
}
9290

93-
fn backwards_sub(ctx: &Context, mut todo: VecDeque<(VarIndex, ExprRef)>, mut spec: Poly) -> Poly {
91+
fn backwards_sub(ctx: &Context, mut todo: Vec<(VarIndex, ExprRef)>, mut spec: Poly) -> Poly {
9492
let mut var_roots: Vec<_> = todo.iter().map(|(v, _)| *v).collect();
9593
var_roots.sort();
9694

@@ -103,7 +101,7 @@ fn backwards_sub(ctx: &Context, mut todo: VecDeque<(VarIndex, ExprRef)>, mut spe
103101
let mut uses = count_expr_uses(ctx, roots);
104102
let mut replaced = vec![];
105103

106-
while let Some((output_var, gate)) = todo.pop_back() {
104+
while let Some((output_var, gate)) = todo.pop() {
107105
replaced.push(output_var);
108106

109107
let add_children = match ctx[gate].clone() {
@@ -168,7 +166,7 @@ fn backwards_sub(ctx: &Context, mut todo: VecDeque<(VarIndex, ExprRef)>, mut spe
168166
uses[e] = prev_uses - 1;
169167
// did the use count just go down to zero?
170168
if prev_uses == 1 && is_gate(&ctx[e]) {
171-
todo.push_front((expr_to_var(e), e));
169+
todo.push((expr_to_var(e), e));
172170
}
173171
});
174172
}

0 commit comments

Comments
 (0)