about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-03-17 12:12:27 +0000
committerbjorn3 <17426603+bjorn3@users.noreply.github.com>2023-03-17 12:12:27 +0000
commit5cfd41d8b4e035b964ff427c8c32423a6588d29a (patch)
tree3773728935b811a6f1e892d2391f970de057dbed
parentb1cf90c4dc7eeae3055d6e1bafa3be5739dd471a (diff)
parente42bea9fdef30787709ddd1de9259717954e7bd6 (diff)
downloadrust-5cfd41d8b4e035b964ff427c8c32423a6588d29a.tar.gz
rust-5cfd41d8b4e035b964ff427c8c32423a6588d29a.zip
Sync from rust 511364e7874dba9649a264100407e4bffe7b5425
-rw-r--r--src/num.rs23
1 files changed, 0 insertions, 23 deletions
diff --git a/src/num.rs b/src/num.rs
index 462742387a9..1357b7be1e0 100644
--- a/src/num.rs
+++ b/src/num.rs
@@ -170,14 +170,6 @@ pub(crate) fn codegen_checked_int_binop<'tcx>(
     in_lhs: CValue<'tcx>,
     in_rhs: CValue<'tcx>,
 ) -> CValue<'tcx> {
-    if bin_op != BinOp::Shl && bin_op != BinOp::Shr {
-        assert_eq!(
-            in_lhs.layout().ty,
-            in_rhs.layout().ty,
-            "checked int binop requires lhs and rhs of same type"
-        );
-    }
-
     let lhs = in_lhs.load_scalar(fx);
     let rhs = in_rhs.load_scalar(fx);
 
@@ -271,21 +263,6 @@ pub(crate) fn codegen_checked_int_binop<'tcx>(
                 _ => unreachable!("invalid non-integer type {}", ty),
             }
         }
-        BinOp::Shl => {
-            let val = fx.bcx.ins().ishl(lhs, rhs);
-            let ty = fx.bcx.func.dfg.value_type(val);
-            let max_shift = i64::from(ty.bits()) - 1;
-            let has_overflow = fx.bcx.ins().icmp_imm(IntCC::UnsignedGreaterThan, rhs, max_shift);
-            (val, has_overflow)
-        }
-        BinOp::Shr => {
-            let val =
-                if !signed { fx.bcx.ins().ushr(lhs, rhs) } else { fx.bcx.ins().sshr(lhs, rhs) };
-            let ty = fx.bcx.func.dfg.value_type(val);
-            let max_shift = i64::from(ty.bits()) - 1;
-            let has_overflow = fx.bcx.ins().icmp_imm(IntCC::UnsignedGreaterThan, rhs, max_shift);
-            (val, has_overflow)
-        }
         _ => bug!("binop {:?} on checked int/uint lhs: {:?} rhs: {:?}", bin_op, in_lhs, in_rhs),
     };