@@ -168,20 +168,12 @@ pub(crate) fn codegen_int_binop<'tcx>(
168
168
BinOp :: BitXor => b. bxor ( lhs, rhs) ,
169
169
BinOp :: BitAnd => b. band ( lhs, rhs) ,
170
170
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) ,
177
172
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 ) ;
181
173
if signed {
182
- fx. bcx . ins ( ) . sshr ( lhs, actual_shift )
174
+ fx. bcx . ins ( ) . sshr ( lhs, rhs )
183
175
} else {
184
- fx. bcx . ins ( ) . ushr ( lhs, actual_shift )
176
+ fx. bcx . ins ( ) . ushr ( lhs, rhs )
185
177
}
186
178
}
187
179
// Compare binops handles by `codegen_binop`.
@@ -303,10 +295,7 @@ pub(crate) fn codegen_checked_int_binop<'tcx>(
303
295
}
304
296
}
305
297
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) ;
310
299
let ty = fx. bcx . func . dfg . value_type ( val) ;
311
300
let max_shift = i64:: from ( ty. bits ( ) ) - 1 ;
312
301
let has_overflow = fx
@@ -316,13 +305,10 @@ pub(crate) fn codegen_checked_int_binop<'tcx>(
316
305
( val, has_overflow)
317
306
}
318
307
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 ) ;
322
308
let val = if !signed {
323
- fx. bcx . ins ( ) . ushr ( lhs, actual_shift )
309
+ fx. bcx . ins ( ) . ushr ( lhs, rhs )
324
310
} else {
325
- fx. bcx . ins ( ) . sshr ( lhs, actual_shift )
311
+ fx. bcx . ins ( ) . sshr ( lhs, rhs )
326
312
} ;
327
313
let ty = fx. bcx . func . dfg . value_type ( val) ;
328
314
let max_shift = i64:: from ( ty. bits ( ) ) - 1 ;
0 commit comments