@@ -150,18 +150,12 @@ pub(crate) fn codegen_int_binop<'tcx>(
150
150
BinOp :: BitXor => b. bxor ( lhs, rhs) ,
151
151
BinOp :: BitAnd => b. band ( lhs, rhs) ,
152
152
BinOp :: BitOr => b. bor ( lhs, rhs) ,
153
- BinOp :: Shl => {
154
- let lhs_ty = fx. bcx . func . dfg . value_type ( lhs) ;
155
- let actual_shift = fx. bcx . ins ( ) . band_imm ( rhs, i64:: from ( lhs_ty. bits ( ) - 1 ) ) ;
156
- fx. bcx . ins ( ) . ishl ( lhs, actual_shift)
157
- }
153
+ BinOp :: Shl => b. ishl ( lhs, rhs) ,
158
154
BinOp :: Shr => {
159
- let lhs_ty = fx. bcx . func . dfg . value_type ( lhs) ;
160
- let actual_shift = fx. bcx . ins ( ) . band_imm ( rhs, i64:: from ( lhs_ty. bits ( ) - 1 ) ) ;
161
155
if signed {
162
- fx . bcx . ins ( ) . sshr ( lhs, actual_shift )
156
+ b . sshr ( lhs, rhs )
163
157
} else {
164
- fx . bcx . ins ( ) . ushr ( lhs, actual_shift )
158
+ b . ushr ( lhs, rhs )
165
159
}
166
160
}
167
161
// Compare binops handles by `codegen_binop`.
@@ -279,22 +273,15 @@ pub(crate) fn codegen_checked_int_binop<'tcx>(
279
273
}
280
274
}
281
275
BinOp :: Shl => {
282
- let lhs_ty = fx. bcx . func . dfg . value_type ( lhs) ;
283
- let masked_shift = fx. bcx . ins ( ) . band_imm ( rhs, i64:: from ( lhs_ty. bits ( ) - 1 ) ) ;
284
- let val = fx. bcx . ins ( ) . ishl ( lhs, masked_shift) ;
276
+ let val = fx. bcx . ins ( ) . ishl ( lhs, rhs) ;
285
277
let ty = fx. bcx . func . dfg . value_type ( val) ;
286
278
let max_shift = i64:: from ( ty. bits ( ) ) - 1 ;
287
279
let has_overflow = fx. bcx . ins ( ) . icmp_imm ( IntCC :: UnsignedGreaterThan , rhs, max_shift) ;
288
280
( val, has_overflow)
289
281
}
290
282
BinOp :: Shr => {
291
- let lhs_ty = fx. bcx . func . dfg . value_type ( lhs) ;
292
- let masked_shift = fx. bcx . ins ( ) . band_imm ( rhs, i64:: from ( lhs_ty. bits ( ) - 1 ) ) ;
293
- let val = if !signed {
294
- fx. bcx . ins ( ) . ushr ( lhs, masked_shift)
295
- } else {
296
- fx. bcx . ins ( ) . sshr ( lhs, masked_shift)
297
- } ;
283
+ let val =
284
+ if !signed { fx. bcx . ins ( ) . ushr ( lhs, rhs) } else { fx. bcx . ins ( ) . sshr ( lhs, rhs) } ;
298
285
let ty = fx. bcx . func . dfg . value_type ( val) ;
299
286
let max_shift = i64:: from ( ty. bits ( ) ) - 1 ;
300
287
let has_overflow = fx. bcx . ins ( ) . icmp_imm ( IntCC :: UnsignedGreaterThan , rhs, max_shift) ;
0 commit comments