From 2d321faa66e5a17d159c298a733e8b8560affe19 Mon Sep 17 00:00:00 2001 From: Tom French <15848336+TomAFrench@users.noreply.github.com> Date: Wed, 13 Nov 2024 19:28:35 +0000 Subject: [PATCH] feat: parallelize DIE pass (#9933) We can parallelize the DIE pass across different functions to speed up this pass. --- noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/die.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/die.rs b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/die.rs index 57af27e8dcd..f28b076a5f9 100644 --- a/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/die.rs +++ b/noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/die.rs @@ -3,6 +3,7 @@ use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet}; use im::Vector; use noirc_errors::Location; +use rayon::iter::{IntoParallelRefMutIterator, ParallelIterator}; use crate::ssa::{ ir::{ @@ -24,9 +25,8 @@ impl Ssa { /// unused results. #[tracing::instrument(level = "trace", skip(self))] pub(crate) fn dead_instruction_elimination(mut self) -> Ssa { - for function in self.functions.values_mut() { - function.dead_instruction_elimination(true); - } + self.functions.par_iter_mut().for_each(|(_, func)| func.dead_instruction_elimination(true)); + self } }