@@ -26,6 +26,7 @@ use rustc_span::source_map::Spanned;
26
26
use rustc_span:: symbol:: { sym, Symbol } ;
27
27
28
28
pub ( crate ) use self :: llvm:: codegen_llvm_intrinsic_call;
29
+ use crate :: cast:: clif_intcast;
29
30
use crate :: prelude:: * ;
30
31
31
32
fn bug_on_incorrect_arg_count ( intrinsic : impl std:: fmt:: Display ) -> ! {
@@ -627,7 +628,8 @@ fn codegen_regular_intrinsic_call<'tcx>(
627
628
628
629
// FIXME trap on `ctlz_nonzero` with zero arg.
629
630
let res = fx. bcx . ins ( ) . clz ( val) ;
630
- let res = CValue :: by_val ( res, arg. layout ( ) ) ;
631
+ let res = clif_intcast ( fx, res, types:: I32 , false ) ;
632
+ let res = CValue :: by_val ( res, ret. layout ( ) ) ;
631
633
ret. write_cvalue ( fx, res) ;
632
634
}
633
635
sym:: cttz | sym:: cttz_nonzero => {
@@ -636,15 +638,17 @@ fn codegen_regular_intrinsic_call<'tcx>(
636
638
637
639
// FIXME trap on `cttz_nonzero` with zero arg.
638
640
let res = fx. bcx . ins ( ) . ctz ( val) ;
639
- let res = CValue :: by_val ( res, arg. layout ( ) ) ;
641
+ let res = clif_intcast ( fx, res, types:: I32 , false ) ;
642
+ let res = CValue :: by_val ( res, ret. layout ( ) ) ;
640
643
ret. write_cvalue ( fx, res) ;
641
644
}
642
645
sym:: ctpop => {
643
646
intrinsic_args ! ( fx, args => ( arg) ; intrinsic) ;
644
647
let val = arg. load_scalar ( fx) ;
645
648
646
649
let res = fx. bcx . ins ( ) . popcnt ( val) ;
647
- let res = CValue :: by_val ( res, arg. layout ( ) ) ;
650
+ let res = clif_intcast ( fx, res, types:: I32 , false ) ;
651
+ let res = CValue :: by_val ( res, ret. layout ( ) ) ;
648
652
ret. write_cvalue ( fx, res) ;
649
653
}
650
654
sym:: bitreverse => {
0 commit comments