@@ -46,9 +46,7 @@ public static Vector512<byte> ShuffleNative(Vector512<byte> vector, Vector512<by
46
46
return Avx512BW . Shuffle ( vector , indices ) ;
47
47
}
48
48
49
- return Vector512 . Create (
50
- Vector256_ . ShuffleNative ( vector . GetLower ( ) , indices . GetLower ( ) ) ,
51
- Vector256_ . ShuffleNative ( vector . GetUpper ( ) , indices . GetUpper ( ) ) ) ;
49
+ return Vector512 . Shuffle ( vector , indices ) ;
52
50
}
53
51
54
52
/// <summary>
@@ -59,25 +57,7 @@ public static Vector512<byte> ShuffleNative(Vector512<byte> vector, Vector512<by
59
57
/// <returns>The <see cref="Vector128{Int32}"/>.</returns>
60
58
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
61
59
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 ) ;
81
61
82
62
/// <summary>
83
63
/// Rounds all values in <paramref name="vector"/> to the nearest integer
@@ -86,28 +66,11 @@ public static Vector512<int> ConvertToInt32RoundToEven(Vector512<float> vector)
86
66
/// <param name="vector">The vector</param>
87
67
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
88
68
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
- }
97
69
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 ) ;
111
74
112
75
/// <summary>
113
76
/// Performs a multiplication and an addition of the <see cref="Vector512{Single}"/>.
@@ -122,21 +85,7 @@ public static Vector512<float> MultiplyAdd(
122
85
Vector512 < float > va ,
123
86
Vector512 < float > vm0 ,
124
87
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 ) ;
140
89
141
90
/// <summary>
142
91
/// Restricts a vector between a minimum and a maximum value.
0 commit comments