@@ -659,8 +659,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
659
659
intrinsic_args ! ( fx, args => ( x, y, z) ; intrinsic) ;
660
660
let layout = x. layout ( ) ;
661
661
662
- let width_bits = layout. size . bits ( ) as u64 ;
663
- let width_bits = fx. bcx . ins ( ) . iconst ( types:: I32 , width_bits as i64 ) ;
662
+ let width_bits = layout. size . bits ( ) as i64 ;
664
663
665
664
let lhs_bits = x. load_scalar ( fx) ;
666
665
let rhs_bits = y. load_scalar ( fx) ;
@@ -669,17 +668,17 @@ fn codegen_regular_intrinsic_call<'tcx>(
669
668
let ty = fx. bcx . func . dfg . value_type ( lhs_bits) ;
670
669
let zero = fx. bcx . ins ( ) . iconst ( ty, 0 ) ;
671
670
672
- let shift_bits = fx. bcx . ins ( ) . urem ( raw_shift_bits, width_bits) ;
671
+ let shift_bits = fx. bcx . ins ( ) . band_imm ( raw_shift_bits, width_bits - 1 ) ;
673
672
674
673
// lhs_bits << shift_bits
675
674
let shl = fx. bcx . ins ( ) . ishl ( lhs_bits, shift_bits) ;
676
675
677
- let inv_shift_bits = fx. bcx . ins ( ) . isub ( width_bits , shift_bits ) ;
676
+ let inv_shift_bits = fx. bcx . ins ( ) . irsub_imm ( shift_bits , width_bits ) ;
678
677
679
- // rhs_bits.bounded_shr (inv_shift_bits)
680
- let inv_shift_bits_mod = fx. bcx . ins ( ) . urem ( inv_shift_bits, width_bits) ;
678
+ // rhs_bits.unbounded_shr (inv_shift_bits)
679
+ let inv_shift_bits_mod = fx. bcx . ins ( ) . band_imm ( inv_shift_bits, width_bits - 1 ) ;
681
680
let shr = fx. bcx . ins ( ) . ushr ( rhs_bits, inv_shift_bits_mod) ;
682
- let is_zero = fx. bcx . ins ( ) . icmp ( IntCC :: Equal , inv_shift_bits_mod , zero ) ;
681
+ let is_zero = fx. bcx . ins ( ) . icmp_imm ( IntCC :: Equal , shift_bits , 0 ) ;
683
682
let shr = fx. bcx . ins ( ) . select ( is_zero, zero, shr) ;
684
683
685
684
let res = fx. bcx . ins ( ) . bor ( shr, shl) ;
@@ -689,8 +688,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
689
688
intrinsic_args ! ( fx, args => ( x, y, z) ; intrinsic) ;
690
689
let layout = x. layout ( ) ;
691
690
692
- let width_bits = layout. size . bits ( ) as u64 ;
693
- let width_bits = fx. bcx . ins ( ) . iconst ( types:: I32 , width_bits as i64 ) ;
691
+ let width_bits = layout. size . bits ( ) as i64 ;
694
692
695
693
let lhs_bits = x. load_scalar ( fx) ;
696
694
let rhs_bits = y. load_scalar ( fx) ;
@@ -699,17 +697,17 @@ fn codegen_regular_intrinsic_call<'tcx>(
699
697
let ty = fx. bcx . func . dfg . value_type ( lhs_bits) ;
700
698
let zero = fx. bcx . ins ( ) . iconst ( ty, 0 ) ;
701
699
702
- let shift_bits = fx. bcx . ins ( ) . urem ( raw_shift_bits, width_bits) ;
700
+ let shift_bits = fx. bcx . ins ( ) . band_imm ( raw_shift_bits, width_bits - 1 ) ;
703
701
704
702
// rhs_bits >> shift_bits
705
703
let shr = fx. bcx . ins ( ) . ushr ( rhs_bits, shift_bits) ;
706
704
707
- let inv_shift_bits = fx. bcx . ins ( ) . isub ( width_bits , shift_bits ) ;
705
+ let inv_shift_bits = fx. bcx . ins ( ) . irsub_imm ( shift_bits , width_bits ) ;
708
706
709
- // lhs_bits.bounded_shl (inv_shift_bits)
710
- let inv_shift_bits_mod = fx. bcx . ins ( ) . urem ( inv_shift_bits, width_bits) ;
707
+ // lhs_bits.unbounded_shl (inv_shift_bits)
708
+ let inv_shift_bits_mod = fx. bcx . ins ( ) . band_imm ( inv_shift_bits, width_bits - 1 ) ;
711
709
let shl = fx. bcx . ins ( ) . ishl ( lhs_bits, inv_shift_bits_mod) ;
712
- let is_zero = fx. bcx . ins ( ) . icmp ( IntCC :: Equal , inv_shift_bits_mod , zero ) ;
710
+ let is_zero = fx. bcx . ins ( ) . icmp_imm ( IntCC :: Equal , shift_bits , 0 ) ;
713
711
let shl = fx. bcx . ins ( ) . select ( is_zero, zero, shl) ;
714
712
715
713
let res = fx. bcx . ins ( ) . bor ( shr, shl) ;
0 commit comments