Skip to content

Commit d9714db

Browse files
fix: handle predicate value reduction in array get also for the databus (#7730)
Co-authored-by: TomAFrench <tom@tomfren.ch>
1 parent 3c76878 commit d9714db

File tree

4 files changed

+29
-11
lines changed

4 files changed

+29
-11
lines changed

compiler/noirc_evaluator/src/acir/mod.rs

+10-11
Original file line numberDiff line numberDiff line change
@@ -1392,22 +1392,21 @@ impl<'a> Context<'a> {
13921392
// Get operations to call-data parameters are replaced by a get to the call-data-bus array
13931393
let call_data =
13941394
self.data_bus.call_data.iter().find(|cd| cd.index_map.contains_key(&array)).cloned();
1395-
if let Some(call_data) = call_data {
1395+
let mut value = if let Some(call_data) = call_data {
13961396
let call_data_block = self.ensure_array_is_initialized(call_data.array_id, dfg)?;
13971397
let bus_index = self
13981398
.acir_context
13991399
.add_constant(FieldElement::from(call_data.index_map[&array] as i128));
14001400
let mut current_index = self.acir_context.add_var(bus_index, var_index)?;
1401-
let result = self.get_from_call_data(&mut current_index, call_data_block, &res_typ)?;
1402-
self.define_result(dfg, instruction, result.clone());
1403-
return Ok(result);
1404-
}
1405-
// Compiler sanity check
1406-
assert!(
1407-
!res_typ.contains_slice_element(),
1408-
"ICE: Nested slice result found during ACIR generation"
1409-
);
1410-
let mut value = self.array_get_value(&res_typ, block_id, &mut var_index)?;
1401+
self.get_from_call_data(&mut current_index, call_data_block, &res_typ)?
1402+
} else {
1403+
// Compiler sanity check
1404+
assert!(
1405+
!res_typ.contains_slice_element(),
1406+
"ICE: Nested slice result found during ACIR generation"
1407+
);
1408+
self.array_get_value(&res_typ, block_id, &mut var_index)?
1409+
};
14111410

14121411
if let AcirValue::Var(value_var, typ) = &value {
14131412
let array_typ = dfg.type_of_value(array);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "regression_7612"
3+
type = "bin"
4+
authors = [""]
5+
6+
[dependencies]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
array = [{ counter = 8, fields = ["0x200000000"] }]
2+
x = true
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
pub struct Data {
2+
fields: [Field; 1],
3+
counter: u32,
4+
}
5+
6+
fn main(array: call_data(0) [Data; 1], x: bool) {
7+
let index = if x { 0 } else { 1 };
8+
if index != 0 {
9+
assert(array[index - 1].counter < 3);
10+
}
11+
}

0 commit comments

Comments
 (0)