Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
21 changes: 16 additions & 5 deletions compiler/noirc_evaluator/src/ssa/ir/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,10 +556,22 @@ impl Instruction {
/// If true the instruction will depend on `enable_side_effects` context during acir-gen.
pub(crate) fn requires_acir_gen_predicate(&self, dfg: &DataFlowGraph) -> bool {
match self {
Instruction::Binary(binary)
if matches!(binary.operator, BinaryOp::Div | BinaryOp::Mod) =>
{
true
Instruction::Binary(binary) => {
// Some binary math can overflow or underflow
match binary.operator {
BinaryOp::Add
| BinaryOp::Sub
| BinaryOp::Mul
| BinaryOp::Div
| BinaryOp::Mod => true,
BinaryOp::Eq
| BinaryOp::Lt
| BinaryOp::And
| BinaryOp::Or
| BinaryOp::Xor
| BinaryOp::Shl
| BinaryOp::Shr => false,
}
}

Instruction::ArrayGet { array, index } => {
Expand All @@ -577,7 +589,6 @@ impl Instruction {
_ => false,
},
Instruction::Cast(_, _)
| Instruction::Binary(_)
| Instruction::Not(_)
| Instruction::Truncate { .. }
| Instruction::Constrain(_, _, _)
Expand Down
7 changes: 7 additions & 0 deletions test_programs/execution_success/regression_6834/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "regression_6834"
version = "0.1.0"
type = "bin"
authors = [""]

[dependencies]
2 changes: 2 additions & 0 deletions test_programs/execution_success/regression_6834/Prover.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
year = 1
min_age = 1
9 changes: 9 additions & 0 deletions test_programs/execution_success/regression_6834/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
fn main(year: u32, min_age: u8) -> pub u32 {
if min_age == 0 {
(year - 2) / 4
} else if year > 1 {
(year - 2) / 4
} else {
0
}
}