Skip to content

Commit

Permalink
fix: correct incorrect logic
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed Nov 27, 2023
1 parent 3d6465a commit 789ab00
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions compiler/noirc_evaluator/src/ssa/acir_gen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1038,7 +1038,7 @@ impl Context {
}
}

let element_type_sizes = if can_omit_element_sizes_array(&array_typ) {
let element_type_sizes = if !can_omit_element_sizes_array(&array_typ) {
Some(self.init_element_type_sizes_array(&array_typ, array_id, None, dfg)?)
} else {
None
Expand Down Expand Up @@ -1305,7 +1305,7 @@ impl Context {
var_index: AcirVar,
dfg: &DataFlowGraph,
) -> Result<AcirVar, RuntimeError> {
if can_omit_element_sizes_array(array_typ) {
if !can_omit_element_sizes_array(array_typ) {
let element_type_sizes =
self.init_element_type_sizes_array(array_typ, array_id, None, dfg)?;

Expand Down Expand Up @@ -1792,7 +1792,7 @@ impl Context {
let mut var_index = slice_length;
self.array_set_value(element, result_block_id, &mut var_index)?;

let element_type_sizes = if can_omit_element_sizes_array(&array_typ) {
let element_type_sizes = if !can_omit_element_sizes_array(&array_typ) {
Some(self.init_element_type_sizes_array(
&array_typ,
array_id,
Expand Down Expand Up @@ -2061,5 +2061,14 @@ impl Context {
// We can omit the element size array for arrays which have elements of size 1 and do not contain slices.
// TODO: remove restriction on size 1 elements.
fn can_omit_element_sizes_array(array_typ: &Type) -> bool {
array_typ.contains_slice_element() || array_typ.flattened_size() > 1
if array_typ.contains_slice_element() {
return false;
}
let Type::Array(types, _) = array_typ else {
panic!("ICE: expected array type");
};

let should_omit = types.len() == 1 && types[0].flattened_size() == 1;
println!("{should_omit}");
should_omit
}

0 comments on commit 789ab00

Please sign in to comment.