Do not codegen overflow check when not required.
This commit is contained in:
parent
3eb5c4581a
commit
4bd2ebc58b
1 changed files with 11 additions and 2 deletions
|
@ -568,8 +568,17 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
// NOTE: Unlike binops, negation doesn't have its own
|
// NOTE: Unlike binops, negation doesn't have its own
|
||||||
// checked operation, just a comparison with the minimum
|
// checked operation, just a comparison with the minimum
|
||||||
// value, so we have to check for the assert message.
|
// value, so we have to check for the assert message.
|
||||||
if !bx.check_overflow() {
|
if !bx.cx().check_overflow() {
|
||||||
if let AssertKind::OverflowNeg(_) = *msg {
|
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);
|
const_cond = Some(expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue