Skip to content

Commit

Permalink
Merge 9fdc801 into 35dedb5
Browse files Browse the repository at this point in the history
  • Loading branch information
jfecher authored Nov 5, 2024
2 parents 35dedb5 + 9fdc801 commit 6cbc6ff
Show file tree
Hide file tree
Showing 7 changed files with 149 additions and 260 deletions.
4 changes: 2 additions & 2 deletions compiler/noirc_evaluator/src/ssa/ir/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use super::{
basic_block::BasicBlockId,
dfg::{CallStack, DataFlowGraph},
map::Id,
types::{NumericType, Type},
types::Type,
value::{Value, ValueId},
};

Expand Down Expand Up @@ -387,8 +387,8 @@ impl Instruction {
| ArraySet { .. } => true,

Constrain(..)
| Store { .. }
| EnableSideEffectsIf { .. }
| Store { .. }
| IncrementRc { .. }
| DecrementRc { .. }
| RangeCheck { .. } => false,
Expand Down
6 changes: 3 additions & 3 deletions compiler/noirc_evaluator/src/ssa/ir/instruction/binary.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use acvm::{acir::AcirField, FieldElement};
use serde::{Deserialize, Serialize};

use super::{
DataFlowGraph, Instruction, InstructionResultType, NumericType, SimplifyResult, Type, ValueId,
};
use crate::ssa::ir::types::NumericType;

use super::{DataFlowGraph, Instruction, InstructionResultType, SimplifyResult, Type, ValueId};

/// Binary Operations allowed in the IR.
/// Aside from the comparison operators (Eq and Lt), all operators
Expand Down
4 changes: 3 additions & 1 deletion compiler/noirc_evaluator/src/ssa/ir/instruction/cast.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use acvm::{acir::AcirField, FieldElement};
use num_bigint::BigUint;

use super::{DataFlowGraph, Instruction, NumericType, SimplifyResult, Type, Value, ValueId};
use crate::ssa::ir::types::NumericType;

use super::{DataFlowGraph, Instruction, SimplifyResult, Type, Value, ValueId};

/// Try to simplify this cast instruction. If the instruction can be simplified to a known value,
/// that value is returned. Otherwise None is returned.
Expand Down
4 changes: 4 additions & 0 deletions compiler/noirc_evaluator/src/ssa/opt/die.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ impl Context {
if instruction.can_eliminate_if_unused(&function.dfg) {
let results = function.dfg.instruction_results(instruction_id);
results.iter().all(|result| !self.used_values.contains(result))
} else if let Instruction::Store { address, .. } = instruction {
// If there's only one block in the function we can remove it as long as the address
// hasn't been referenced afterward.
(function.reachable_blocks().len() == 1) && !self.used_values.contains(address)
} else if let Instruction::Call { func, arguments } = instruction {
// TODO: make this more general for instructions which don't have results but have side effects "sometimes" like `Intrinsic::AsWitness`
let as_witness_id = function.dfg.get_intrinsic(Intrinsic::AsWitness);
Expand Down
Loading

0 comments on commit 6cbc6ff

Please sign in to comment.