@@ -739,11 +739,12 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
739
739
return Err ( ( ) ) ;
740
740
} } ;
741
741
}
742
- let ( elem_ty_str, elem_ty) = if let ty:: Float ( ref f) = * in_elem. kind ( ) {
742
+ let ( elem_ty_str, elem_ty, cast_type ) = if let ty:: Float ( ref f) = * in_elem. kind ( ) {
743
743
let elem_ty = bx. cx . type_float_from_ty ( * f) ;
744
744
match f. bit_width ( ) {
745
- 32 => ( "f" , elem_ty) ,
746
- 64 => ( "" , elem_ty) ,
745
+ 16 => ( "" , elem_ty, Some ( bx. cx . double_type ) ) ,
746
+ 32 => ( "f" , elem_ty, None ) ,
747
+ 64 => ( "" , elem_ty, None ) ,
747
748
_ => {
748
749
return_error ! ( InvalidMonomorphization :: FloatingPointVector {
749
750
span,
@@ -787,17 +788,28 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
787
788
for i in 0 ..in_len {
788
789
let index = bx. context . new_rvalue_from_long ( bx. ulong_type , i as i64 ) ;
789
790
// we have to treat fpowi specially, since fpowi's second argument is always an i32
790
- let arguments = if name == sym:: simd_fpowi {
791
- vec ! [
791
+ let mut arguments = vec ! [ ] ;
792
+ if name == sym:: simd_fpowi {
793
+ arguments = vec ! [
792
794
bx. extract_element( args[ 0 ] . immediate( ) , index) . to_rvalue( ) ,
793
795
args[ 1 ] . immediate( ) ,
794
- ]
796
+ ] ;
795
797
} else {
796
- args. iter ( )
797
- . map ( |arg| bx. extract_element ( arg. immediate ( ) , index) . to_rvalue ( ) )
798
- . collect ( )
798
+ for arg in args {
799
+ let mut element = bx. extract_element ( arg. immediate ( ) , index) . to_rvalue ( ) ;
800
+ // FIXME: it would probably be better to not have casts here and use the proper
801
+ // instructions.
802
+ if let Some ( typ) = cast_type {
803
+ element = bx. context . new_cast ( None , element, typ) ;
804
+ }
805
+ arguments. push ( element) ;
806
+ }
799
807
} ;
800
- vector_elements. push ( bx. context . new_call ( None , function, & arguments) ) ;
808
+ let mut result = bx. context . new_call ( None , function, & arguments) ;
809
+ if cast_type. is_some ( ) {
810
+ result = bx. context . new_cast ( None , result, elem_ty) ;
811
+ }
812
+ vector_elements. push ( result) ;
801
813
}
802
814
let c = bx. context . new_rvalue_from_vector ( None , vec_ty, & vector_elements) ;
803
815
Ok ( c)
0 commit comments