Skip to content

Commit 5cfd41d

Browse files
committed
Sync from rust 511364e7874dba9649a264100407e4bffe7b5425
2 parents b1cf90c + e42bea9 commit 5cfd41d

File tree

1 file changed

+0
-23
lines changed

1 file changed

+0
-23
lines changed

src/num.rs

-23
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,6 @@ pub(crate) fn codegen_checked_int_binop<'tcx>(
170170
in_lhs: CValue<'tcx>,
171171
in_rhs: CValue<'tcx>,
172172
) -> CValue<'tcx> {
173-
if bin_op != BinOp::Shl && bin_op != BinOp::Shr {
174-
assert_eq!(
175-
in_lhs.layout().ty,
176-
in_rhs.layout().ty,
177-
"checked int binop requires lhs and rhs of same type"
178-
);
179-
}
180-
181173
let lhs = in_lhs.load_scalar(fx);
182174
let rhs = in_rhs.load_scalar(fx);
183175

@@ -271,21 +263,6 @@ pub(crate) fn codegen_checked_int_binop<'tcx>(
271263
_ => unreachable!("invalid non-integer type {}", ty),
272264
}
273265
}
274-
BinOp::Shl => {
275-
let val = fx.bcx.ins().ishl(lhs, rhs);
276-
let ty = fx.bcx.func.dfg.value_type(val);
277-
let max_shift = i64::from(ty.bits()) - 1;
278-
let has_overflow = fx.bcx.ins().icmp_imm(IntCC::UnsignedGreaterThan, rhs, max_shift);
279-
(val, has_overflow)
280-
}
281-
BinOp::Shr => {
282-
let val =
283-
if !signed { fx.bcx.ins().ushr(lhs, rhs) } else { fx.bcx.ins().sshr(lhs, rhs) };
284-
let ty = fx.bcx.func.dfg.value_type(val);
285-
let max_shift = i64::from(ty.bits()) - 1;
286-
let has_overflow = fx.bcx.ins().icmp_imm(IntCC::UnsignedGreaterThan, rhs, max_shift);
287-
(val, has_overflow)
288-
}
289266
_ => bug!("binop {:?} on checked int/uint lhs: {:?} rhs: {:?}", bin_op, in_lhs, in_rhs),
290267
};
291268

0 commit comments

Comments
 (0)