@@ -728,20 +728,25 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
728
728
// codegen. Note that this has a semantic difference in that the
729
729
// intrinsic can trap whereas `fptoui` never traps. That difference,
730
730
// however, is handled by `fptosui_may_trap` above.
731
+ //
732
+ // Note that we skip the wasm intrinsics for vector types where `fptoui`
733
+ // must be used instead.
731
734
if self . wasm_and_missing_nontrapping_fptoint ( ) {
732
735
let src_ty = self . cx . val_ty ( val) ;
733
- let float_width = self . cx . float_width ( src_ty) ;
734
- let int_width = self . cx . int_width ( dest_ty) ;
735
- let name = match ( int_width, float_width) {
736
- ( 32 , 32 ) => Some ( "llvm.wasm.trunc.unsigned.i32.f32" ) ,
737
- ( 32 , 64 ) => Some ( "llvm.wasm.trunc.unsigned.i32.f64" ) ,
738
- ( 64 , 32 ) => Some ( "llvm.wasm.trunc.unsigned.i64.f32" ) ,
739
- ( 64 , 64 ) => Some ( "llvm.wasm.trunc.unsigned.i64.f64" ) ,
740
- _ => None ,
741
- } ;
742
- if let Some ( name) = name {
743
- let intrinsic = self . get_intrinsic ( name) ;
744
- return self . call ( intrinsic, & [ val] , None ) ;
736
+ if self . cx . type_kind ( src_ty) != TypeKind :: Vector {
737
+ let float_width = self . cx . float_width ( src_ty) ;
738
+ let int_width = self . cx . int_width ( dest_ty) ;
739
+ let name = match ( int_width, float_width) {
740
+ ( 32 , 32 ) => Some ( "llvm.wasm.trunc.unsigned.i32.f32" ) ,
741
+ ( 32 , 64 ) => Some ( "llvm.wasm.trunc.unsigned.i32.f64" ) ,
742
+ ( 64 , 32 ) => Some ( "llvm.wasm.trunc.unsigned.i64.f32" ) ,
743
+ ( 64 , 64 ) => Some ( "llvm.wasm.trunc.unsigned.i64.f64" ) ,
744
+ _ => None ,
745
+ } ;
746
+ if let Some ( name) = name {
747
+ let intrinsic = self . get_intrinsic ( name) ;
748
+ return self . call ( intrinsic, & [ val] , None ) ;
749
+ }
745
750
}
746
751
}
747
752
unsafe { llvm:: LLVMBuildFPToUI ( self . llbuilder , val, dest_ty, UNNAMED ) }
@@ -750,18 +755,20 @@ impl BuilderMethods<'a, 'tcx> for Builder<'a, 'll, 'tcx> {
750
755
fn fptosi ( & mut self , val : & ' ll Value , dest_ty : & ' ll Type ) -> & ' ll Value {
751
756
if self . wasm_and_missing_nontrapping_fptoint ( ) {
752
757
let src_ty = self . cx . val_ty ( val) ;
753
- let float_width = self . cx . float_width ( src_ty) ;
754
- let int_width = self . cx . int_width ( dest_ty) ;
755
- let name = match ( int_width, float_width) {
756
- ( 32 , 32 ) => Some ( "llvm.wasm.trunc.signed.i32.f32" ) ,
757
- ( 32 , 64 ) => Some ( "llvm.wasm.trunc.signed.i32.f64" ) ,
758
- ( 64 , 32 ) => Some ( "llvm.wasm.trunc.signed.i64.f32" ) ,
759
- ( 64 , 64 ) => Some ( "llvm.wasm.trunc.signed.i64.f64" ) ,
760
- _ => None ,
761
- } ;
762
- if let Some ( name) = name {
763
- let intrinsic = self . get_intrinsic ( name) ;
764
- return self . call ( intrinsic, & [ val] , None ) ;
758
+ if self . cx . type_kind ( src_ty) != TypeKind :: Vector {
759
+ let float_width = self . cx . float_width ( src_ty) ;
760
+ let int_width = self . cx . int_width ( dest_ty) ;
761
+ let name = match ( int_width, float_width) {
762
+ ( 32 , 32 ) => Some ( "llvm.wasm.trunc.signed.i32.f32" ) ,
763
+ ( 32 , 64 ) => Some ( "llvm.wasm.trunc.signed.i32.f64" ) ,
764
+ ( 64 , 32 ) => Some ( "llvm.wasm.trunc.signed.i64.f32" ) ,
765
+ ( 64 , 64 ) => Some ( "llvm.wasm.trunc.signed.i64.f64" ) ,
766
+ _ => None ,
767
+ } ;
768
+ if let Some ( name) = name {
769
+ let intrinsic = self . get_intrinsic ( name) ;
770
+ return self . call ( intrinsic, & [ val] , None ) ;
771
+ }
765
772
}
766
773
}
767
774
unsafe { llvm:: LLVMBuildFPToSI ( self . llbuilder , val, dest_ty, UNNAMED ) }
0 commit comments