Skip to content

Commit 90d43a2

Browse files
committed
Do not codegen overflow check when not required.
1 parent 9ee5a2c commit 90d43a2

File tree

1 file changed

+11
-2
lines changed
  • compiler/rustc_codegen_ssa/src/mir

1 file changed

+11
-2
lines changed

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -568,8 +568,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
568568
// NOTE: Unlike binops, negation doesn't have its own
569569
// checked operation, just a comparison with the minimum
570570
// value, so we have to check for the assert message.
571-
if !bx.check_overflow() {
572-
if let AssertKind::OverflowNeg(_) = *msg {
571+
if !bx.cx().check_overflow() {
572+
if let AssertKind::OverflowNeg(_)
573+
| AssertKind::Overflow(
574+
mir::BinOp::Add
575+
| mir::BinOp::Sub
576+
| mir::BinOp::Mul
577+
| mir::BinOp::Shl
578+
| mir::BinOp::Shr,
579+
..,
580+
) = *msg
581+
{
573582
const_cond = Some(expected);
574583
}
575584
}

0 commit comments

Comments
 (0)