Skip to content

Commit e17a570

Browse files
committed
Use BTreeMap to store block IDs
1 parent 7b28c59 commit e17a570

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,9 @@ pub(crate) struct BrilligInfo<'a> {
196196
/// For more information see [`ConstraintSimplificationCache`].
197197
#[derive(Default)]
198198
struct SimplificationCache {
199-
simplifications: HashMap<BasicBlockId, ValueId>,
199+
/// Simplified expressions where we found them.
200+
/// Using a `BTreeMap` for deterministic enumeration.
201+
simplifications: BTreeMap<BasicBlockId, ValueId>,
200202
}
201203

202204
impl SimplificationCache {
@@ -221,7 +223,9 @@ impl SimplificationCache {
221223
return Some(*value);
222224
}
223225
// Check if there is a dominating block we can take a simplification from.
224-
for (constraining_block, value) in self.simplifications.iter() {
226+
// Going backwards so that we find a constraint closest to what we have already processed
227+
// (assuming block IDs of blocks further down in the SSA are larger).
228+
for (constraining_block, value) in self.simplifications.iter().rev() {
225229
if dom.dominates(*constraining_block, block) {
226230
return Some(*value);
227231
}

0 commit comments

Comments
 (0)