Skip to content

Commit cc6c5ec

Browse files
committed
Sync from rust 9cdfe285ca724c801dc9f78d22b24ea69b787f26
2 parents 39daa5a + 2c219ce commit cc6c5ec

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

src/base.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -609,14 +609,11 @@ fn codegen_stmt<'tcx>(
609609
let lhs = codegen_operand(fx, &lhs_rhs.0);
610610
let rhs = codegen_operand(fx, &lhs_rhs.1);
611611

612-
let res = crate::num::codegen_binop(fx, bin_op, lhs, rhs);
613-
lval.write_cvalue(fx, res);
614-
}
615-
Rvalue::CheckedBinaryOp(bin_op, ref lhs_rhs) => {
616-
let lhs = codegen_operand(fx, &lhs_rhs.0);
617-
let rhs = codegen_operand(fx, &lhs_rhs.1);
618-
619-
let res = crate::num::codegen_checked_int_binop(fx, bin_op, lhs, rhs);
612+
let res = if let Some(bin_op) = bin_op.overflowing_to_wrapping() {
613+
crate::num::codegen_checked_int_binop(fx, bin_op, lhs, rhs)
614+
} else {
615+
crate::num::codegen_binop(fx, bin_op, lhs, rhs)
616+
};
620617
lval.write_cvalue(fx, res);
621618
}
622619
Rvalue::UnaryOp(un_op, ref operand) => {

src/codegen_i128.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ pub(crate) fn maybe_codegen<'tcx>(
7070
}
7171
BinOp::Lt | BinOp::Le | BinOp::Eq | BinOp::Ge | BinOp::Gt | BinOp::Ne | BinOp::Cmp => None,
7272
BinOp::Shl | BinOp::ShlUnchecked | BinOp::Shr | BinOp::ShrUnchecked => None,
73+
BinOp::AddWithOverflow | BinOp::SubWithOverflow | BinOp::MulWithOverflow => unreachable!(),
7374
}
7475
}
7576

@@ -132,6 +133,7 @@ pub(crate) fn maybe_codegen_checked<'tcx>(
132133
Some(out_place.to_cvalue(fx))
133134
}
134135
BinOp::AddUnchecked | BinOp::SubUnchecked | BinOp::MulUnchecked => unreachable!(),
136+
BinOp::AddWithOverflow | BinOp::SubWithOverflow | BinOp::MulWithOverflow => unreachable!(),
135137
BinOp::Offset => unreachable!("offset should only be used on pointers, not 128bit ints"),
136138
BinOp::Div | BinOp::Rem => unreachable!(),
137139
BinOp::Cmp => unreachable!(),

src/intrinsics/simd.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
348348
| sym::simd_bswap
349349
| sym::simd_bitreverse
350350
| sym::simd_ctlz
351+
| sym::simd_ctpop
351352
| sym::simd_cttz => {
352353
intrinsic_args!(fx, args => (a); intrinsic);
353354

@@ -367,6 +368,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
367368
(ty::Uint(_) | ty::Int(_), sym::simd_bswap) => fx.bcx.ins().bswap(lane),
368369
(ty::Uint(_) | ty::Int(_), sym::simd_bitreverse) => fx.bcx.ins().bitrev(lane),
369370
(ty::Uint(_) | ty::Int(_), sym::simd_ctlz) => fx.bcx.ins().clz(lane),
371+
(ty::Uint(_) | ty::Int(_), sym::simd_ctpop) => fx.bcx.ins().popcnt(lane),
370372
(ty::Uint(_) | ty::Int(_), sym::simd_cttz) => fx.bcx.ins().ctz(lane),
371373

372374
_ => unreachable!(),

src/num.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,9 @@ pub(crate) fn codegen_int_binop<'tcx>(
179179
}
180180
}
181181
BinOp::Offset => unreachable!("Offset is not an integer operation"),
182+
BinOp::AddWithOverflow | BinOp::SubWithOverflow | BinOp::MulWithOverflow => {
183+
unreachable!("Overflow binops handled by `codegen_checked_int_binop`")
184+
}
182185
// Compare binops handles by `codegen_binop`.
183186
BinOp::Eq | BinOp::Ne | BinOp::Lt | BinOp::Le | BinOp::Gt | BinOp::Ge | BinOp::Cmp => {
184187
unreachable!("{:?}({:?}, {:?})", bin_op, in_lhs.layout().ty, in_rhs.layout().ty);

0 commit comments

Comments
 (0)