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
9987e900c0
61 changed files with 212 additions and 215 deletions
|
@ -576,6 +576,22 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
}
|
||||
}
|
||||
|
||||
mir::Rvalue::BinaryOp(op_with_overflow, box (ref lhs, ref rhs))
|
||||
if let Some(op) = op_with_overflow.overflowing_to_wrapping() =>
|
||||
{
|
||||
let lhs = self.codegen_operand(bx, lhs);
|
||||
let rhs = self.codegen_operand(bx, rhs);
|
||||
let result = self.codegen_scalar_checked_binop(
|
||||
bx,
|
||||
op,
|
||||
lhs.immediate(),
|
||||
rhs.immediate(),
|
||||
lhs.layout.ty,
|
||||
);
|
||||
let val_ty = op.ty(bx.tcx(), lhs.layout.ty, rhs.layout.ty);
|
||||
let operand_ty = Ty::new_tup(bx.tcx(), &[val_ty, bx.tcx().types.bool]);
|
||||
OperandRef { val: result, layout: bx.cx().layout_of(operand_ty) }
|
||||
}
|
||||
mir::Rvalue::BinaryOp(op, box (ref lhs, ref rhs)) => {
|
||||
let lhs = self.codegen_operand(bx, lhs);
|
||||
let rhs = self.codegen_operand(bx, rhs);
|
||||
|
@ -604,20 +620,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
layout: bx.cx().layout_of(op.ty(bx.tcx(), lhs.layout.ty, rhs.layout.ty)),
|
||||
}
|
||||
}
|
||||
mir::Rvalue::CheckedBinaryOp(op, box (ref lhs, ref rhs)) => {
|
||||
let lhs = self.codegen_operand(bx, lhs);
|
||||
let rhs = self.codegen_operand(bx, rhs);
|
||||
let result = self.codegen_scalar_checked_binop(
|
||||
bx,
|
||||
op,
|
||||
lhs.immediate(),
|
||||
rhs.immediate(),
|
||||
lhs.layout.ty,
|
||||
);
|
||||
let val_ty = op.ty(bx.tcx(), lhs.layout.ty, rhs.layout.ty);
|
||||
let operand_ty = Ty::new_tup(bx.tcx(), &[val_ty, bx.tcx().types.bool]);
|
||||
OperandRef { val: result, layout: bx.cx().layout_of(operand_ty) }
|
||||
}
|
||||
|
||||
mir::Rvalue::UnaryOp(op, ref operand) => {
|
||||
let operand = self.codegen_operand(bx, operand);
|
||||
|
@ -928,6 +930,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
bx.select(is_lt, bx.cx().const_i8(Ordering::Less as i8), ge)
|
||||
}
|
||||
}
|
||||
mir::BinOp::AddWithOverflow
|
||||
| mir::BinOp::SubWithOverflow
|
||||
| mir::BinOp::MulWithOverflow => {
|
||||
bug!("{op:?} needs to return a pair, so call codegen_scalar_checked_binop instead")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1040,7 +1047,6 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
mir::Rvalue::Cast(..) | // (*)
|
||||
mir::Rvalue::ShallowInitBox(..) | // (*)
|
||||
mir::Rvalue::BinaryOp(..) |
|
||||
mir::Rvalue::CheckedBinaryOp(..) |
|
||||
mir::Rvalue::UnaryOp(..) |
|
||||
mir::Rvalue::Discriminant(..) |
|
||||
mir::Rvalue::NullaryOp(..) |
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue