@@ -336,10 +336,19 @@ unsafe extern "unadjusted" {
336336 #[ link_name = "llvm.s390.vcnf" ] fn vcnf ( a : vector_signed_short , immarg : i32 ) -> vector_signed_short ;
337337 #[ link_name = "llvm.s390.vcrnfs" ] fn vcrnfs ( a : vector_float , b : vector_float , immarg : i32 ) -> vector_signed_short ;
338338
339- #[ link_name = "llvm.s390.vfmaxsb" ] fn vfmaxsb ( a : vector_float , b : vector_float , mode : i32 ) -> vector_float ;
340- #[ link_name = "llvm.s390.vfmaxdb" ] fn vfmaxdb ( a : vector_double , b : vector_double , mode : i32 ) -> vector_double ;
341- #[ link_name = "llvm.s390.vfminsb" ] fn vfminsb ( a : vector_float , b : vector_float , mode : i32 ) -> vector_float ;
342- #[ link_name = "llvm.s390.vfmindb" ] fn vfmindb ( a : vector_double , b : vector_double , mode : i32 ) -> vector_double ;
339+ // These are the intrinsics we'd like to use (with mode 0). However, they require
340+ // "vector-enhancements-1" and don't have a fallback, whereas `vec_min`/`vec_max` should be
341+ // available with just "vector". Therefore, we cannot use them.
342+ // #[link_name = "llvm.s390.vfmaxsb"] fn vfmaxsb(a: vector_float, b: vector_float, mode: i32) -> vector_float;
343+ // #[link_name = "llvm.s390.vfmaxdb"] fn vfmaxdb(a: vector_double, b: vector_double, mode: i32) -> vector_double;
344+ // #[link_name = "llvm.s390.vfminsb"] fn vfminsb(a: vector_float, b: vector_float, mode: i32) -> vector_float;
345+ // #[link_name = "llvm.s390.vfmindb"] fn vfmindb(a: vector_double, b: vector_double, mode: i32) -> vector_double;
346+ // Instead, we use "portable" LLVM intrinsics -- even though those have the wrong semantics
347+ // (https://github.com/rust-lang/stdarch/issues/2060), they usually do the right thing.
348+ #[ link_name = "llvm.minnum.v4f32" ] fn minnum_v4f32 ( a : vector_float , b : vector_float ) -> vector_float ;
349+ #[ link_name = "llvm.minnum.v2f64" ] fn minnum_v2f64 ( a : vector_double , b : vector_double ) -> vector_double ;
350+ #[ link_name = "llvm.maxnum.v4f32" ] fn maxnum_v4f32 ( a : vector_float , b : vector_float ) -> vector_float ;
351+ #[ link_name = "llvm.maxnum.v2f64" ] fn maxnum_v2f64 ( a : vector_double , b : vector_double ) -> vector_double ;
343352}
344353
345354#[ repr( simd) ]
@@ -785,20 +794,8 @@ mod sealed {
785794 impl_max ! ( vec_vmxslg, vector_unsigned_long_long, vmxlg) ;
786795 }
787796
788- #[ inline]
789- #[ target_feature( enable = "vector" ) ]
790- unsafe fn vfmaxsb_m0 ( a : vector_float , b : vector_float ) -> vector_float {
791- // clang uses mode 0 for `vec_max`, so we do the same.
792- vfmaxsb ( a, b, const { 0 } )
793- }
794- #[ inline]
795- #[ target_feature( enable = "vector" ) ]
796- unsafe fn vfmaxdb_m0 ( a : vector_double , b : vector_double ) -> vector_double {
797- vfmaxdb ( a, b, const { 0 } )
798- }
799-
800- test_impl ! { vec_vfmaxsb ( a: vector_float, b: vector_float) -> vector_float [ vfmaxsb_m0, "vector-enhancements-1" vfmaxsb ] }
801- test_impl ! { vec_vfmaxdb ( a: vector_double, b: vector_double) -> vector_double [ vfmaxdb_m0, "vector-enhancements-1" vfmaxdb] }
797+ test_impl ! { vec_vfmaxsb ( a: vector_float, b: vector_float) -> vector_float [ maxnum_v4f32, "vector-enhancements-1" vfmaxsb] }
798+ test_impl ! { vec_vfmaxdb ( a: vector_double, b: vector_double) -> vector_double [ maxnum_v2f64, "vector-enhancements-1" vfmaxdb] }
802799
803800 impl_vec_trait ! ( [ VectorMax vec_max] vec_vfmaxsb ( vector_float, vector_float) -> vector_float) ;
804801 impl_vec_trait ! ( [ VectorMax vec_max] vec_vfmaxdb ( vector_double, vector_double) -> vector_double) ;
@@ -844,20 +841,8 @@ mod sealed {
844841 impl_min ! ( vec_vmnslg, vector_unsigned_long_long, vmnlg) ;
845842 }
846843
847- #[ inline]
848- #[ target_feature( enable = "vector" ) ]
849- unsafe fn vfminsb_m0 ( a : vector_float , b : vector_float ) -> vector_float {
850- // clang uses mode 0 for `vec_min`, so we do the same.
851- vfminsb ( a, b, const { 0 } )
852- }
853- #[ inline]
854- #[ target_feature( enable = "vector" ) ]
855- unsafe fn vfmindb_m0 ( a : vector_double , b : vector_double ) -> vector_double {
856- vfmindb ( a, b, const { 0 } )
857- }
858-
859- test_impl ! { vec_vfminsb ( a: vector_float, b: vector_float) -> vector_float [ vfminsb_m0, "vector-enhancements-1" vfminsb] }
860- test_impl ! { vec_vfmindb ( a: vector_double, b: vector_double) -> vector_double [ vfmindb_m0, "vector-enhancements-1" vfmindb] }
844+ test_impl ! { vec_vfminsb ( a: vector_float, b: vector_float) -> vector_float [ minnum_v4f32, "vector-enhancements-1" vfminsb] }
845+ test_impl ! { vec_vfmindb ( a: vector_double, b: vector_double) -> vector_double [ minnum_v2f64, "vector-enhancements-1" vfmindb] }
861846
862847 impl_vec_trait ! ( [ VectorMin vec_min] vec_vfminsb ( vector_float, vector_float) -> vector_float) ;
863848 impl_vec_trait ! ( [ VectorMin vec_min] vec_vfmindb ( vector_double, vector_double) -> vector_double) ;
0 commit comments