Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions compiler/noirc_evaluator/src/ssa/ir/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,10 @@ impl Instruction {

Instruction::ArrayGet { array, index, offset: _ } => {
// `ArrayGet`s which read from "known good" indices from an array should not need a predicate.
!dfg.is_safe_index(*index, *array)
// This extra out of bounds (OOB) check is only inserted in the ACIR runtime.
// Thus, in Brillig an `ArrayGet` is always a pure operation in isolation and
// it is expected that OOB checks are inserted separately.
dfg.runtime().is_acir() && !dfg.is_safe_index(*index, *array)
}

Instruction::EnableSideEffectsIf { .. } | Instruction::ArraySet { .. } => true,
Expand Down Expand Up @@ -553,7 +556,12 @@ impl Instruction {
Cast(_, _) | Not(_) | Truncate { .. } | IfElse { .. } => false,

// `ArrayGet`s which read from "known good" indices from an array have no side effects
ArrayGet { array, index, offset: _ } => !dfg.is_safe_index(*index, *array),
// This extra out of bounds (OOB) check is only inserted in the ACIR runtime.
// Thus, in Brillig an `ArrayGet` is always a pure operation in isolation and
// it is expected that OOB checks are inserted separately.
ArrayGet { array, index, offset: _ } => {
dfg.runtime().is_acir() && !dfg.is_safe_index(*index, *array)
}

// ArraySet has side effects
ArraySet { .. } => true,
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Loading