Skip to content

Commit 0b6fd5e

Browse files
committed
Remove MONO ifdef from Vector128 bitcasts
Follow-up to dotnet#104309.
1 parent 8a28b8c commit 0b6fd5e

File tree

1 file changed

+6
-52
lines changed
  • src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics

1 file changed

+6
-52
lines changed

src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs

+6-52
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,7 @@ public static Vector128<TTo> As<TFrom, TTo>(this Vector128<TFrom> vector)
106106
ThrowHelper.ThrowForUnsupportedIntrinsicsVector128BaseType<TFrom>();
107107
ThrowHelper.ThrowForUnsupportedIntrinsicsVector128BaseType<TTo>();
108108

109-
#if MONO
110-
return Unsafe.As<Vector128<TFrom>, Vector128<TTo>>(ref vector);
111-
#else
112109
return Unsafe.BitCast<Vector128<TFrom>, Vector128<TTo>>(vector);
113-
#endif
114110
}
115111

116112
/// <summary>Reinterprets a <see cref="Vector128{T}" /> as a new <see cref="Vector128{Byte}" />.</summary>
@@ -174,27 +170,13 @@ public static Vector128<TTo> As<TFrom, TTo>(this Vector128<TFrom> vector)
174170
/// <param name="value">The vector to reinterpret.</param>
175171
/// <returns><paramref name="value" /> reinterpreted as a new <see cref="Plane" />.</returns>
176172
[Intrinsic]
177-
internal static Plane AsPlane(this Vector128<float> value)
178-
{
179-
#if MONO
180-
return Unsafe.As<Vector128<float>, Plane>(ref value);
181-
#else
182-
return Unsafe.BitCast<Vector128<float>, Plane>(value);
183-
#endif
184-
}
173+
internal static Plane AsPlane(this Vector128<float> value) => Unsafe.BitCast<Vector128<float>, Plane>(value);
185174

186175
/// <summary>Reinterprets a <see cref="Vector128{Single}" /> as a new <see cref="Quaternion" />.</summary>
187176
/// <param name="value">The vector to reinterpret.</param>
188177
/// <returns><paramref name="value" /> reinterpreted as a new <see cref="Quaternion" />.</returns>
189178
[Intrinsic]
190-
internal static Quaternion AsQuaternion(this Vector128<float> value)
191-
{
192-
#if MONO
193-
return Unsafe.As<Vector128<float>, Quaternion>(ref value);
194-
#else
195-
return Unsafe.BitCast<Vector128<float>, Quaternion>(value);
196-
#endif
197-
}
179+
internal static Quaternion AsQuaternion(this Vector128<float> value) => Unsafe.BitCast<Vector128<float>, Quaternion>(value);
198180

199181
/// <summary>Reinterprets a <see cref="Vector128{T}" /> as a new <see cref="Vector128{SByte}" />.</summary>
200182
/// <typeparam name="T">The type of the elements in the vector.</typeparam>
@@ -244,27 +226,13 @@ internal static Quaternion AsQuaternion(this Vector128<float> value)
244226
/// <param name="value">The plane to reinterpret.</param>
245227
/// <returns><paramref name="value" /> reinterpreted as a new <see cref="Vector128{Single}" />.</returns>
246228
[Intrinsic]
247-
internal static Vector128<float> AsVector128(this Plane value)
248-
{
249-
#if MONO
250-
return Unsafe.As<Plane, Vector128<float>>(ref value);
251-
#else
252-
return Unsafe.BitCast<Plane, Vector128<float>>(value);
253-
#endif
254-
}
229+
internal static Vector128<float> AsVector128(this Plane value) => Unsafe.BitCast<Plane, Vector128<float>>(value);
255230

256231
/// <summary>Reinterprets a <see cref="Quaternion" /> as a new <see cref="Vector128{Single}" />.</summary>
257232
/// <param name="value">The quaternion to reinterpret.</param>
258233
/// <returns><paramref name="value" /> reinterpreted as a new <see cref="Vector128{Single}" />.</returns>
259234
[Intrinsic]
260-
internal static Vector128<float> AsVector128(this Quaternion value)
261-
{
262-
#if MONO
263-
return Unsafe.As<Quaternion, Vector128<float>>(ref value);
264-
#else
265-
return Unsafe.BitCast<Quaternion, Vector128<float>>(value);
266-
#endif
267-
}
235+
internal static Vector128<float> AsVector128(this Quaternion value) => Unsafe.BitCast<Quaternion, Vector128<float>>(value);
268236

269237
/// <summary>Reinterprets a <see cref="Vector2" /> as a new <see cref="Vector128{Single}" /> with the new elements zeroed.</summary>
270238
/// <param name="value">The vector to reinterpret.</param>
@@ -282,14 +250,7 @@ internal static Vector128<float> AsVector128(this Quaternion value)
282250
/// <param name="value">The vector to reinterpret.</param>
283251
/// <returns><paramref name="value" /> reinterpreted as a new <see cref="Vector128{Single}" />.</returns>
284252
[Intrinsic]
285-
public static Vector128<float> AsVector128(this Vector4 value)
286-
{
287-
#if MONO
288-
return Unsafe.As<Vector4, Vector128<float>>(ref value);
289-
#else
290-
return Unsafe.BitCast<Vector4, Vector128<float>>(value);
291-
#endif
292-
}
253+
public static Vector128<float> AsVector128(this Vector4 value) => Unsafe.BitCast<Vector4, Vector128<float>>(value);
293254

294255
/// <summary>Reinterprets a <see cref="Vector{T}" /> as a new <see cref="Vector128{T}" />.</summary>
295256
/// <typeparam name="T">The type of the elements in the vector.</typeparam>
@@ -361,14 +322,7 @@ public static Vector3 AsVector3(this Vector128<float> value)
361322
/// <param name="value">The vector to reinterpret.</param>
362323
/// <returns><paramref name="value" /> reinterpreted as a new <see cref="Vector4" />.</returns>
363324
[Intrinsic]
364-
public static Vector4 AsVector4(this Vector128<float> value)
365-
{
366-
#if MONO
367-
return Unsafe.As<Vector128<float>, Vector4>(ref value);
368-
#else
369-
return Unsafe.BitCast<Vector128<float>, Vector4>(value);
370-
#endif
371-
}
325+
public static Vector4 AsVector4(this Vector128<float> value) => Unsafe.BitCast<Vector128<float>, Vector4>(value);
372326

373327
/// <summary>Reinterprets a <see cref="Vector128{T}" /> as a new <see cref="Vector{T}" />.</summary>
374328
/// <typeparam name="T">The type of the elements in the vector.</typeparam>

0 commit comments

Comments
 (0)