@@ -46,9 +46,7 @@ public static Vector512<byte> ShuffleNative(Vector512<byte> vector, Vector512<by
4646 return Avx512BW . Shuffle ( vector , indices ) ;
4747 }
4848
49- return Vector512 . Create (
50- Vector256_ . ShuffleNative ( vector . GetLower ( ) , indices . GetLower ( ) ) ,
51- Vector256_ . ShuffleNative ( vector . GetUpper ( ) , indices . GetUpper ( ) ) ) ;
49+ return Vector512 . Shuffle ( vector , indices ) ;
5250 }
5351
5452 /// <summary>
@@ -59,25 +57,7 @@ public static Vector512<byte> ShuffleNative(Vector512<byte> vector, Vector512<by
5957 /// <returns>The <see cref="Vector128{Int32}"/>.</returns>
6058 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
6159 public static Vector512 < int > ConvertToInt32RoundToEven ( Vector512 < float > vector )
62- {
63- if ( Avx512F . IsSupported )
64- {
65- return Avx512F . ConvertToVector512Int32 ( vector ) ;
66- }
67-
68- if ( Avx . IsSupported )
69- {
70- Vector256 < int > lower = Avx . ConvertToVector256Int32 ( vector . GetLower ( ) ) ;
71- Vector256 < int > upper = Avx . ConvertToVector256Int32 ( vector . GetUpper ( ) ) ;
72- return Vector512 . Create ( lower , upper ) ;
73- }
74-
75- Vector512 < float > sign = vector & Vector512 . Create ( - 0.0f ) ;
76- Vector512 < float > val_2p23_f32 = sign | Vector512 . Create ( 8388608.0f ) ;
77-
78- val_2p23_f32 = ( vector + val_2p23_f32 ) - val_2p23_f32 ;
79- return Vector512 . ConvertToInt32 ( val_2p23_f32 | sign ) ;
80- }
60+ => Avx512F . ConvertToVector512Int32 ( vector ) ;
8161
8262 /// <summary>
8363 /// Rounds all values in <paramref name="vector"/> to the nearest integer
@@ -86,28 +66,11 @@ public static Vector512<int> ConvertToInt32RoundToEven(Vector512<float> vector)
8666 /// <param name="vector">The vector</param>
8767 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
8868 public static Vector512 < float > RoundToNearestInteger ( Vector512 < float > vector )
89- {
90- if ( Avx512F . IsSupported )
91- {
92- // imm8 = 0b1000:
93- // imm8[7:4] = 0b0000 -> preserve 0 fractional bits (round to whole numbers)
94- // imm8[3:0] = 0b1000 -> _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC (round to nearest even, suppress exceptions)
95- return Avx512F . RoundScale ( vector , 0b0000_1000 ) ;
96- }
9769
98- if ( Avx . IsSupported )
99- {
100- Vector256 < float > lower = Avx . RoundToNearestInteger ( vector . GetLower ( ) ) ;
101- Vector256 < float > upper = Avx . RoundToNearestInteger ( vector . GetUpper ( ) ) ;
102- return Vector512 . Create ( lower , upper ) ;
103- }
104-
105- Vector512 < float > sign = vector & Vector512 . Create ( - 0F ) ;
106- Vector512 < float > val_2p23_f32 = sign | Vector512 . Create ( 8388608F ) ;
107-
108- val_2p23_f32 = ( vector + val_2p23_f32 ) - val_2p23_f32 ;
109- return val_2p23_f32 | sign ;
110- }
70+ // imm8 = 0b1000:
71+ // imm8[7:4] = 0b0000 -> preserve 0 fractional bits (round to whole numbers)
72+ // imm8[3:0] = 0b1000 -> _MM_FROUND_TO_NEAREST_INT | _MM_FROUND_NO_EXC (round to nearest even, suppress exceptions)
73+ => Avx512F . RoundScale ( vector , 0b0000_1000 ) ;
11174
11275 /// <summary>
11376 /// Performs a multiplication and an addition of the <see cref="Vector512{Single}"/>.
@@ -122,21 +85,7 @@ public static Vector512<float> MultiplyAdd(
12285 Vector512 < float > va ,
12386 Vector512 < float > vm0 ,
12487 Vector512 < float > vm1 )
125- {
126- if ( Avx512F . IsSupported )
127- {
128- return Avx512F . FusedMultiplyAdd ( vm0 , vm1 , va ) ;
129- }
130-
131- if ( Fma . IsSupported )
132- {
133- Vector256 < float > lower = Fma . MultiplyAdd ( vm0 . GetLower ( ) , vm1 . GetLower ( ) , va . GetLower ( ) ) ;
134- Vector256 < float > upper = Fma . MultiplyAdd ( vm0 . GetUpper ( ) , vm1 . GetUpper ( ) , va . GetUpper ( ) ) ;
135- return Vector512 . Create ( lower , upper ) ;
136- }
137-
138- return va + ( vm0 * vm1 ) ;
139- }
88+ => Avx512F . FusedMultiplyAdd ( vm0 , vm1 , va ) ;
14089
14190 /// <summary>
14291 /// Restricts a vector between a minimum and a maximum value.
0 commit comments