Skip to content

Commit ffcc6f8

Browse files
authored
fix(performance): Accurately mark safe constant indices for arrays of complex types (#7491)
1 parent 8e68ce6 commit ffcc6f8

File tree

1 file changed

+5
-1
lines changed
  • compiler/noirc_evaluator/src/ssa/ir

1 file changed

+5
-1
lines changed

compiler/noirc_evaluator/src/ssa/ir/dfg.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,11 @@ impl DataFlowGraph {
658658
pub(crate) fn is_safe_index(&self, index: ValueId, array: ValueId) -> bool {
659659
#[allow(clippy::match_like_matches_macro)]
660660
match (self.type_of_value(array), self.get_numeric_constant(index)) {
661-
(Type::Array(_, len), Some(index)) if index.to_u128() < (len as u128) => true,
661+
(Type::Array(elements, len), Some(index))
662+
if index.to_u128() < (len as u128 * elements.len() as u128) =>
663+
{
664+
true
665+
}
662666
_ => false,
663667
}
664668
}

0 commit comments

Comments
 (0)