mirror of
https://github.com/rust-lang/rust.git
synced 2025-04-14 21:16:50 +00:00
Do not codegen overflow check when not required.
This commit is contained in:
parent
3eb5c4581a
commit
4bd2ebc58b
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user