Rollup merge of #125173 - scottmcm:never-checked, r=davidtwco
Remove `Rvalue::CheckedBinaryOp` Zulip conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/intrinsics.20vs.20binop.2Funop/near/438729996> cc `@RalfJung` While it's a draft, r? ghost
This commit is contained in:
commit
14134c1482
13
src/base.rs
13
src/base.rs
@ -609,14 +609,11 @@ fn codegen_stmt<'tcx>(
|
|||||||
let lhs = codegen_operand(fx, &lhs_rhs.0);
|
let lhs = codegen_operand(fx, &lhs_rhs.0);
|
||||||
let rhs = codegen_operand(fx, &lhs_rhs.1);
|
let rhs = codegen_operand(fx, &lhs_rhs.1);
|
||||||
|
|
||||||
let res = crate::num::codegen_binop(fx, bin_op, lhs, rhs);
|
let res = if let Some(bin_op) = bin_op.overflowing_to_wrapping() {
|
||||||
lval.write_cvalue(fx, res);
|
crate::num::codegen_checked_int_binop(fx, bin_op, lhs, rhs)
|
||||||
}
|
} else {
|
||||||
Rvalue::CheckedBinaryOp(bin_op, ref lhs_rhs) => {
|
crate::num::codegen_binop(fx, bin_op, lhs, rhs)
|
||||||
let lhs = codegen_operand(fx, &lhs_rhs.0);
|
};
|
||||||
let rhs = codegen_operand(fx, &lhs_rhs.1);
|
|
||||||
|
|
||||||
let res = crate::num::codegen_checked_int_binop(fx, bin_op, lhs, rhs);
|
|
||||||
lval.write_cvalue(fx, res);
|
lval.write_cvalue(fx, res);
|
||||||
}
|
}
|
||||||
Rvalue::UnaryOp(un_op, ref operand) => {
|
Rvalue::UnaryOp(un_op, ref operand) => {
|
||||||
|
@ -70,6 +70,7 @@ pub(crate) fn maybe_codegen<'tcx>(
|
|||||||
}
|
}
|
||||||
BinOp::Lt | BinOp::Le | BinOp::Eq | BinOp::Ge | BinOp::Gt | BinOp::Ne | BinOp::Cmp => None,
|
BinOp::Lt | BinOp::Le | BinOp::Eq | BinOp::Ge | BinOp::Gt | BinOp::Ne | BinOp::Cmp => None,
|
||||||
BinOp::Shl | BinOp::ShlUnchecked | BinOp::Shr | BinOp::ShrUnchecked => None,
|
BinOp::Shl | BinOp::ShlUnchecked | BinOp::Shr | BinOp::ShrUnchecked => None,
|
||||||
|
BinOp::AddWithOverflow | BinOp::SubWithOverflow | BinOp::MulWithOverflow => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,6 +133,7 @@ pub(crate) fn maybe_codegen_checked<'tcx>(
|
|||||||
Some(out_place.to_cvalue(fx))
|
Some(out_place.to_cvalue(fx))
|
||||||
}
|
}
|
||||||
BinOp::AddUnchecked | BinOp::SubUnchecked | BinOp::MulUnchecked => unreachable!(),
|
BinOp::AddUnchecked | BinOp::SubUnchecked | BinOp::MulUnchecked => unreachable!(),
|
||||||
|
BinOp::AddWithOverflow | BinOp::SubWithOverflow | BinOp::MulWithOverflow => unreachable!(),
|
||||||
BinOp::Offset => unreachable!("offset should only be used on pointers, not 128bit ints"),
|
BinOp::Offset => unreachable!("offset should only be used on pointers, not 128bit ints"),
|
||||||
BinOp::Div | BinOp::Rem => unreachable!(),
|
BinOp::Div | BinOp::Rem => unreachable!(),
|
||||||
BinOp::Cmp => unreachable!(),
|
BinOp::Cmp => unreachable!(),
|
||||||
|
@ -179,6 +179,9 @@ pub(crate) fn codegen_int_binop<'tcx>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
BinOp::Offset => unreachable!("Offset is not an integer operation"),
|
BinOp::Offset => unreachable!("Offset is not an integer operation"),
|
||||||
|
BinOp::AddWithOverflow | BinOp::SubWithOverflow | BinOp::MulWithOverflow => {
|
||||||
|
unreachable!("Overflow binops handled by `codegen_checked_int_binop`")
|
||||||
|
}
|
||||||
// Compare binops handles by `codegen_binop`.
|
// Compare binops handles by `codegen_binop`.
|
||||||
BinOp::Eq | BinOp::Ne | BinOp::Lt | BinOp::Le | BinOp::Gt | BinOp::Ge | BinOp::Cmp => {
|
BinOp::Eq | BinOp::Ne | BinOp::Lt | BinOp::Le | BinOp::Gt | BinOp::Ge | BinOp::Cmp => {
|
||||||
unreachable!("{:?}({:?}, {:?})", bin_op, in_lhs.layout().ty, in_rhs.layout().ty);
|
unreachable!("{:?}({:?}, {:?})", bin_op, in_lhs.layout().ty, in_rhs.layout().ty);
|
||||||
|
Loading…
Reference in New Issue
Block a user