diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2023-02-08 21:17:29 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2023-02-18 21:35:02 +0000 |
| commit | 4bd2ebc58bed1ee5bf7ff934999e3db3c6e9f22d (patch) | |
| tree | 8398c286f37193405f1ddd01049b4769ee9aecc3 | |
| parent | 3eb5c4581a386b13c414e8c8bd73846ef37236d1 (diff) | |
| download | rust-4bd2ebc58bed1ee5bf7ff934999e3db3c6e9f22d.tar.gz rust-4bd2ebc58bed1ee5bf7ff934999e3db3c6e9f22d.zip | |
Do not codegen overflow check when not required.
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/mir/block.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index 9af408646ae..a7e74279a13 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -568,8 +568,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { // NOTE: Unlike binops, negation doesn't have its own // checked operation, just a comparison with the minimum // value, so we have to check for the assert message. - if !bx.check_overflow() { - if let AssertKind::OverflowNeg(_) = *msg { + if !bx.cx().check_overflow() { + if let AssertKind::OverflowNeg(_) + | AssertKind::Overflow( + mir::BinOp::Add + | mir::BinOp::Sub + | mir::BinOp::Mul + | mir::BinOp::Shl + | mir::BinOp::Shr, + .., + ) = *msg + { const_cond = Some(expected); } } |
