From 9f68fb4f6ad0b44434f92f3703a664676f5cfd85 Mon Sep 17 00:00:00 2001
From: Tom French <tom@tomfren.ch>
Date: Thu, 9 Jan 2025 17:57:14 +0000
Subject: [PATCH] feat: allow deduplicating `Truncate` and `Not` instructions

---
 compiler/noirc_evaluator/src/ssa/ir/instruction.rs | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/compiler/noirc_evaluator/src/ssa/ir/instruction.rs b/compiler/noirc_evaluator/src/ssa/ir/instruction.rs
index 17cde96cddc..c8057ab84b4 100644
--- a/compiler/noirc_evaluator/src/ssa/ir/instruction.rs
+++ b/compiler/noirc_evaluator/src/ssa/ir/instruction.rs
@@ -473,8 +473,8 @@ impl Instruction {
             // removed entirely.
             Noop => true,
 
-            // Cast instructions can always be deduplicated
-            Cast(_, _) => true,
+            // These instructions can always be deduplicated
+            Cast(_, _) | Truncate { .. } | Not(_) => true,
 
             // Arrays can be mutated in unconstrained code so code that handles this case must
             // take care to track whether the array was possibly mutated or not before
@@ -486,12 +486,7 @@ impl Instruction {
             // Replacing them with a similar instruction potentially enables replacing an instruction
             // with one that was disabled. See
             // https://github.com/noir-lang/noir/pull/4716#issuecomment-2047846328.
-            Binary(_)
-            | Not(_)
-            | Truncate { .. }
-            | IfElse { .. }
-            | ArrayGet { .. }
-            | ArraySet { .. } => {
+            Binary(_) | IfElse { .. } | ArrayGet { .. } | ArraySet { .. } => {
                 deduplicate_with_predicate || !self.requires_acir_gen_predicate(&function.dfg)
             }
         }