Skip to content

Commit aaab506

Browse files
authored
Merge 6c0348e into 49f80b3
2 parents 49f80b3 + 6c0348e commit aaab506

File tree

8 files changed

+1300
-400
lines changed

8 files changed

+1300
-400
lines changed

.noir-sync-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
68c32b4ffd9b069fe4b119327dbf4018c17ab9d4
1+
dace07849aa28795abb30b3f9d979ffc6b6487e6

noir/noir-repo/compiler/noirc_evaluator/src/ssa.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,23 @@ pub(crate) fn optimize_into_acir(
141141
ssa.to_brillig(options.enable_brillig_logging)
142142
});
143143

144+
let ssa_gen_span = span!(Level::TRACE, "ssa_generation");
145+
let ssa_gen_span_guard = ssa_gen_span.enter();
146+
147+
let ssa = SsaBuilder {
148+
ssa,
149+
print_ssa_passes: options.enable_ssa_logging,
150+
print_codegen_timings: options.print_codegen_timings,
151+
}
152+
.run_pass(
153+
|ssa| ssa.fold_constants_with_brillig(&brillig),
154+
"After Constant Folding with Brillig:",
155+
)
156+
.run_pass(Ssa::dead_instruction_elimination, "After Dead Instruction Elimination:")
157+
.finish();
158+
159+
drop(ssa_gen_span_guard);
160+
144161
let artifacts = time("SSA to ACIR", options.print_codegen_timings, || {
145162
ssa.into_acir(&brillig, options.expression_width)
146163
})?;

noir/noir-repo/compiler/noirc_evaluator/src/ssa/ir/instruction.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use fxhash::FxHasher64;
1111
use iter_extended::vecmap;
1212
use noirc_frontend::hir_def::types::Type as HirType;
1313

14-
use crate::ssa::opt::flatten_cfg::value_merger::ValueMerger;
14+
use crate::ssa::{ir::function::RuntimeType, opt::flatten_cfg::value_merger::ValueMerger};
1515

1616
use super::{
1717
basic_block::BasicBlockId,
@@ -478,8 +478,19 @@ impl Instruction {
478478
| ArraySet { .. }
479479
| MakeArray { .. } => true,
480480

481+
// Store instructions must be removed by DIE in acir code, any load
482+
// instructions should already be unused by that point.
483+
//
484+
// Note that this check assumes that it is being performed after the flattening
485+
// pass and after the last mem2reg pass. This is currently the case for the DIE
486+
// pass where this check is done, but does mean that we cannot perform mem2reg
487+
// after the DIE pass.
488+
Store { .. } => {
489+
matches!(function.runtime(), RuntimeType::Acir(_))
490+
&& function.reachable_blocks().len() == 1
491+
}
492+
481493
Constrain(..)
482-
| Store { .. }
483494
| EnableSideEffectsIf { .. }
484495
| IncrementRc { .. }
485496
| DecrementRc { .. }

0 commit comments

Comments
 (0)