@@ -722,9 +722,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
722722 this. write_scalar ( Scalar :: from_i32 ( 0 ) , & dest) ?;
723723 }
724724 }
725- // Use to implement the _mm_cvtsd_si32 and _mm_cvttsd_si32 functions.
726- // Converts the first component of `op` from f64 to i32.
727- "cvtsd2si" | "cvttsd2si" => {
725+ // Use to implement the _mm_cvtsd_si32, _mm_cvttsd_si32,
726+ // _mm_cvtsd_si64 and _mm_cvttsd_si64 functions.
727+ // Converts the first component of `op` from f64 to i32/i64.
728+ "cvtsd2si" | "cvttsd2si" | "cvtsd2si64" | "cvttsd2si64" => {
728729 let [ op] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
729730 let ( op, _) = this. operand_to_simd ( op) ?;
730731
@@ -733,41 +734,16 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
733734 let rnd = match unprefixed_name {
734735 // "current SSE rounding mode", assume nearest
735736 // https://www.felixcloutier.com/x86/cvtsd2si
736- "cvtsd2si" => rustc_apfloat:: Round :: NearestTiesToEven ,
737+ "cvtsd2si" | "cvtsd2si64" => rustc_apfloat:: Round :: NearestTiesToEven ,
737738 // always truncate
738739 // https://www.felixcloutier.com/x86/cvttsd2si
739- "cvttsd2si" => rustc_apfloat:: Round :: TowardZero ,
740+ "cvttsd2si" | "cvttsd2si64" => rustc_apfloat:: Round :: TowardZero ,
740741 _ => unreachable ! ( ) ,
741742 } ;
742743
743744 let res = this. float_to_int_checked ( op, dest. layout . ty , rnd) . unwrap_or_else ( || {
744745 // Fallback to minimum acording to SSE semantics.
745- Scalar :: from_i32 ( i32:: MIN )
746- } ) ;
747-
748- this. write_scalar ( res, dest) ?;
749- }
750- // Use to implement the _mm_cvtsd_si64 and _mm_cvttsd_si64 functions.
751- // Converts the first component of `op` from f64 to i64.
752- "cvtsd2si64" | "cvttsd2si64" => {
753- let [ op] = this. check_shim ( abi, Abi :: C { unwind : false } , link_name, args) ?;
754- let ( op, _) = this. operand_to_simd ( op) ?;
755-
756- let op = this. read_scalar ( & this. project_index ( & op, 0 ) ?) ?. to_f64 ( ) ?;
757-
758- let rnd = match unprefixed_name {
759- // "current SSE rounding mode", assume nearest
760- // https://www.felixcloutier.com/x86/cvtsd2si
761- "cvtsd2si64" => rustc_apfloat:: Round :: NearestTiesToEven ,
762- // always truncate
763- // https://www.felixcloutier.com/x86/cvttsd2si
764- "cvttsd2si64" => rustc_apfloat:: Round :: TowardZero ,
765- _ => unreachable ! ( ) ,
766- } ;
767-
768- let res = this. float_to_int_checked ( op, dest. layout . ty , rnd) . unwrap_or_else ( || {
769- // Fallback to minimum acording to SSE semantics.
770- Scalar :: from_i64 ( i64:: MIN )
746+ Scalar :: from_int ( dest. layout . size . signed_int_min ( ) , dest. layout . size )
771747 } ) ;
772748
773749 this. write_scalar ( res, dest) ?;
0 commit comments