Skip to content

Commit

Permalink
feat(performance): Use unchecked ops based upon known induction varia…
Browse files Browse the repository at this point in the history
…bles (#7344)

Co-authored-by: Tom French <15848336+TomAFrench@users.noreply.github.com>
  • Loading branch information
vezenovm and TomAFrench authored Feb 12, 2025
1 parent 1c5ae80 commit 10b377f
Show file tree
Hide file tree
Showing 2 changed files with 177 additions and 52 deletions.
18 changes: 18 additions & 0 deletions compiler/noirc_evaluator/src/ssa/ir/instruction/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,24 @@ impl BinaryOp {
BinaryOp::Shr => |x, y| Some(x >> y),
}
}

pub(crate) fn into_unchecked(self) -> Self {
match self {
BinaryOp::Add { .. } => BinaryOp::Add { unchecked: true },
BinaryOp::Sub { .. } => BinaryOp::Sub { unchecked: true },
BinaryOp::Mul { .. } => BinaryOp::Mul { unchecked: true },
_ => self,
}
}

pub(crate) fn is_unchecked(self) -> bool {
match self {
BinaryOp::Add { unchecked }
| BinaryOp::Sub { unchecked }
| BinaryOp::Mul { unchecked } => unchecked,
_ => true,
}
}
}

#[cfg(test)]
Expand Down
Loading

0 comments on commit 10b377f

Please sign in to comment.