Skip to content

Commit

Permalink
Optimize encoding of mir::BinOp::Rem for unsigned integers (#1503)
Browse files Browse the repository at this point in the history
  • Loading branch information
fpoli authored Mar 1, 2024
1 parent 4f154f8 commit 45405dc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion prusti-viper/src/encoder/mir_encoder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,13 @@ impl<'p, 'v: 'p, 'tcx: 'v> MirEncoder<'p, 'v, 'tcx> {
mir::BinOp::Le => vir::Expr::le_cmp(left, right),
mir::BinOp::AddUnchecked | mir::BinOp::Add => vir::Expr::add(left, right),
mir::BinOp::SubUnchecked | mir::BinOp::Sub => vir::Expr::sub(left, right),
mir::BinOp::Rem => vir::Expr::rem(left, right),
mir::BinOp::Rem => {
if matches!(ty.kind(), ty::TyKind::Uint(_)) {
vir::Expr::modulo(left, right)
} else {
vir::Expr::rem(left, right)
}
}
mir::BinOp::Div => vir::Expr::div(left, right),
mir::BinOp::MulUnchecked | mir::BinOp::Mul => vir::Expr::mul(left, right),
mir::BinOp::BitAnd if is_bool => vir::Expr::and(left, right),
Expand Down

0 comments on commit 45405dc

Please sign in to comment.