File tree 1 file changed +6
-2
lines changed
compiler/noirc_evaluator/src/ssa/opt
1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -196,7 +196,9 @@ pub(crate) struct BrilligInfo<'a> {
196
196
/// For more information see [`ConstraintSimplificationCache`].
197
197
#[ derive( Default ) ]
198
198
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 > ,
200
202
}
201
203
202
204
impl SimplificationCache {
@@ -221,7 +223,9 @@ impl SimplificationCache {
221
223
return Some ( * value) ;
222
224
}
223
225
// 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 ( ) {
225
229
if dom. dominates ( * constraining_block, block) {
226
230
return Some ( * value) ;
227
231
}
You can’t perform that action at this time.
0 commit comments