@@ -168,20 +168,12 @@ pub(crate) fn codegen_int_binop<'tcx>(
168168 BinOp :: BitXor => b. bxor ( lhs, rhs) ,
169169 BinOp :: BitAnd => b. band ( lhs, rhs) ,
170170 BinOp :: BitOr => b. bor ( lhs, rhs) ,
171- BinOp :: Shl => {
172- let lhs_ty = fx. bcx . func . dfg . value_type ( lhs) ;
173- let actual_shift = fx. bcx . ins ( ) . band_imm ( rhs, i64:: from ( lhs_ty. bits ( ) - 1 ) ) ;
174- let actual_shift = clif_intcast ( fx, actual_shift, types:: I8 , false ) ;
175- fx. bcx . ins ( ) . ishl ( lhs, actual_shift)
176- }
171+ BinOp :: Shl => fx. bcx . ins ( ) . ishl ( lhs, rhs) ,
177172 BinOp :: Shr => {
178- let lhs_ty = fx. bcx . func . dfg . value_type ( lhs) ;
179- let actual_shift = fx. bcx . ins ( ) . band_imm ( rhs, i64:: from ( lhs_ty. bits ( ) - 1 ) ) ;
180- let actual_shift = clif_intcast ( fx, actual_shift, types:: I8 , false ) ;
181173 if signed {
182- fx. bcx . ins ( ) . sshr ( lhs, actual_shift )
174+ fx. bcx . ins ( ) . sshr ( lhs, rhs )
183175 } else {
184- fx. bcx . ins ( ) . ushr ( lhs, actual_shift )
176+ fx. bcx . ins ( ) . ushr ( lhs, rhs )
185177 }
186178 }
187179 // Compare binops handles by `codegen_binop`.
@@ -303,10 +295,7 @@ pub(crate) fn codegen_checked_int_binop<'tcx>(
303295 }
304296 }
305297 BinOp :: Shl => {
306- let lhs_ty = fx. bcx . func . dfg . value_type ( lhs) ;
307- let actual_shift = fx. bcx . ins ( ) . band_imm ( rhs, i64:: from ( lhs_ty. bits ( ) - 1 ) ) ;
308- let actual_shift = clif_intcast ( fx, actual_shift, types:: I8 , false ) ;
309- let val = fx. bcx . ins ( ) . ishl ( lhs, actual_shift) ;
298+ let val = fx. bcx . ins ( ) . ishl ( lhs, rhs) ;
310299 let ty = fx. bcx . func . dfg . value_type ( val) ;
311300 let max_shift = i64:: from ( ty. bits ( ) ) - 1 ;
312301 let has_overflow = fx
@@ -316,13 +305,10 @@ pub(crate) fn codegen_checked_int_binop<'tcx>(
316305 ( val, has_overflow)
317306 }
318307 BinOp :: Shr => {
319- let lhs_ty = fx. bcx . func . dfg . value_type ( lhs) ;
320- let actual_shift = fx. bcx . ins ( ) . band_imm ( rhs, i64:: from ( lhs_ty. bits ( ) - 1 ) ) ;
321- let actual_shift = clif_intcast ( fx, actual_shift, types:: I8 , false ) ;
322308 let val = if !signed {
323- fx. bcx . ins ( ) . ushr ( lhs, actual_shift )
309+ fx. bcx . ins ( ) . ushr ( lhs, rhs )
324310 } else {
325- fx. bcx . ins ( ) . sshr ( lhs, actual_shift )
311+ fx. bcx . ins ( ) . sshr ( lhs, rhs )
326312 } ;
327313 let ty = fx. bcx . func . dfg . value_type ( val) ;
328314 let max_shift = i64:: from ( ty. bits ( ) ) - 1 ;
0 commit comments