Skip to content

Commit

Permalink
Merge 948f0c5 into 2eb4a2c
Browse files Browse the repository at this point in the history
  • Loading branch information
vezenovm authored Oct 2, 2024
2 parents 2eb4a2c + 948f0c5 commit 14cfd45
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use super::{
};
use acvm::acir::{brillig::MemoryAddress, AcirField};

pub(crate) const MAX_STACK_SIZE: usize = 2048;
pub(crate) const MAX_STACK_SIZE: usize = 32768;
pub(crate) const MAX_SCRATCH_SPACE: usize = 64;

impl<F: AcirField + DebugToString> BrilligContext<F, Stack> {
Expand Down
30 changes: 26 additions & 4 deletions compiler/noirc_evaluator/src/ssa/ir/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,9 +630,9 @@ impl Instruction {
}
}
Instruction::ArraySet { array, index, value, .. } => {
let array = dfg.get_array_constant(*array);
let index = dfg.get_numeric_constant(*index);
if let (Some((array, element_type)), Some(index)) = (array, index) {
let array_const = dfg.get_array_constant(*array);
let index_const = dfg.get_numeric_constant(*index);
if let (Some((array, element_type)), Some(index)) = (array_const, index_const) {
let index =
index.try_to_u32().expect("Expected array index to fit in u32") as usize;

Expand All @@ -641,7 +641,8 @@ impl Instruction {
return SimplifiedTo(new_array);
}
}
None

try_optimize_array_set_from_previous_get(dfg, *array, *index, *value)
}
Instruction::Truncate { value, bit_size, max_bit_size } => {
if bit_size == max_bit_size {
Expand Down Expand Up @@ -817,6 +818,27 @@ fn try_optimize_array_get_from_previous_set(
SimplifyResult::None
}

fn try_optimize_array_set_from_previous_get(
dfg: &DataFlowGraph,
array_id: ValueId,
target_index: ValueId,
target_value: ValueId,
) -> SimplifyResult {
match &dfg[target_value] {
Value::Instruction { instruction, .. } => match &dfg[*instruction] {
Instruction::ArrayGet { array, index } => {
if *array == array_id && *index == target_index {
SimplifyResult::SimplifiedTo(array_id)
} else {
SimplifyResult::None
}
}
_ => SimplifyResult::None,
},
_ => SimplifyResult::None,
}
}

pub(crate) type ErrorType = HirType;

pub(crate) fn error_selector_from_type(typ: &ErrorType) -> ErrorSelector {
Expand Down

0 comments on commit 14cfd45

Please sign in to comment.