From 3d2639379d46c26a612b9b4d8fde9f432abedadb Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Wed, 31 Jan 2018 08:57:17 -0800 Subject: [PATCH] Replace JitIntrinsicAttribute with IntrinsicAttribute (#26700) * Replace JitIntrinsicAttribute with IntrinsicAttribute * Use s_ prefix for statics Signed-off-by: dotnet-bot-corefx-mirror Signed-off-by: dotnet-bot --- .../System/Numerics/JitIntrinsicAttribute.cs | 14 -- .../shared/System/Numerics/Vector.cs | 197 +++++++----------- .../shared/System/Numerics/Vector.tt | 100 ++++----- .../System/Numerics/Vector_Operations.cs | 2 +- 4 files changed, 122 insertions(+), 191 deletions(-) delete mode 100644 src/System.Private.CoreLib/shared/System/Numerics/JitIntrinsicAttribute.cs diff --git a/src/System.Private.CoreLib/shared/System/Numerics/JitIntrinsicAttribute.cs b/src/System.Private.CoreLib/shared/System/Numerics/JitIntrinsicAttribute.cs deleted file mode 100644 index 741041222f8..00000000000 --- a/src/System.Private.CoreLib/shared/System/Numerics/JitIntrinsicAttribute.cs +++ /dev/null @@ -1,14 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. -// See the LICENSE file in the project root for more information. - -namespace System.Numerics -{ - /// - /// An attribute that can be attached to JIT Intrinsic methods/properties - /// - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Property)] - internal class JitIntrinsicAttribute : Attribute - { - } -} diff --git a/src/System.Private.CoreLib/shared/System/Numerics/Vector.cs b/src/System.Private.CoreLib/shared/System/Numerics/Vector.cs index 9e4eb703aac..984f82fb26d 100644 --- a/src/System.Private.CoreLib/shared/System/Numerics/Vector.cs +++ b/src/System.Private.CoreLib/shared/System/Numerics/Vector.cs @@ -48,9 +48,9 @@ public struct Vector : IEquatable>, IFormattable where T : struct /// /// Returns the number of elements stored in the vector. This value is hardware dependent. /// - [JitIntrinsic] public static int Count { + [Intrinsic] get { return s_count; @@ -61,19 +61,31 @@ public static int Count /// /// Returns a vector containing all zeroes. /// - [JitIntrinsic] - public static Vector Zero { get { return zero; } } - private static readonly Vector zero = new Vector(GetZeroValue()); + public static Vector Zero + { + [Intrinsic] + get + { + return s_zero; + } + } + private static readonly Vector s_zero = new Vector(); /// /// Returns a vector containing all ones. /// - [JitIntrinsic] - public static Vector One { get { return one; } } - private static readonly Vector one = new Vector(GetOneValue()); + public static Vector One + { + [Intrinsic] + get + { + return s_one; + } + } + private static readonly Vector s_one = new Vector(GetOneValue()); - internal static Vector AllOnes { get { return allOnes; } } - private static readonly Vector allOnes = new Vector(GetAllBitsSetValue()); + internal static Vector AllOnes { get { return s_allOnes; } } + private static readonly Vector s_allOnes = new Vector(GetAllBitsSetValue()); #endregion Static Members #region Static Initialization @@ -145,7 +157,7 @@ private static unsafe int InitializeCount() /// /// Constructs a vector whose components are all value /// - [JitIntrinsic] + [Intrinsic] public unsafe Vector(T value) : this() { @@ -356,7 +368,7 @@ public unsafe Vector(T value) /// /// Constructs a vector from the given array. The size of the given array must be at least Vector'T.Count. /// - [JitIntrinsic] + [Intrinsic] public unsafe Vector(T[] values) : this(values, 0) { } /// @@ -759,7 +771,7 @@ private Vector(ref Register existingRegister) /// The destination array which the values are copied into /// If the destination array is null /// If number of elements in source vector is greater than those available in destination array - [JitIntrinsic] + [Intrinsic] public unsafe void CopyTo(T[] destination) { CopyTo(destination, 0); @@ -773,7 +785,7 @@ public unsafe void CopyTo(T[] destination) /// If the destination array is null /// If index is greater than end of the array or index is less than zero /// If number of elements in source vector is greater than those available in destination array - [JitIntrinsic] + [Intrinsic] public unsafe void CopyTo(T[] destination, int startIndex) { if (destination == null) @@ -1047,9 +1059,9 @@ public unsafe void CopyTo(T[] destination, int startIndex) /// /// Returns the element at the given index. /// - [JitIntrinsic] public unsafe T this[int index] { + [Intrinsic] get { if (index >= Count || index < 0) @@ -1153,7 +1165,7 @@ public override bool Equals(object obj) /// /// The vector to compare this instance to. /// True if the other vector is equal to this instance; False otherwise. - [JitIntrinsic] + [Intrinsic] public bool Equals(Vector other) { if (Vector.IsHardwareAccelerated) @@ -2639,7 +2651,7 @@ public string ToString(string format, IFormatProvider formatProvider) /// The first source vector. /// The second source vector. /// The resultant vector. - [JitIntrinsic] + [Intrinsic] public static unsafe Vector operator &(Vector left, Vector right) { Vector result = new Vector(); @@ -2670,7 +2682,7 @@ public string ToString(string format, IFormatProvider formatProvider) /// The first source vector. /// The second source vector. /// The resultant vector. - [JitIntrinsic] + [Intrinsic] public static unsafe Vector operator |(Vector left, Vector right) { Vector result = new Vector(); @@ -2701,7 +2713,7 @@ public string ToString(string format, IFormatProvider formatProvider) /// The first source vector. /// The second source vector. /// The resultant vector. - [JitIntrinsic] + [Intrinsic] public static unsafe Vector operator ^(Vector left, Vector right) { Vector result = new Vector(); @@ -2734,7 +2746,7 @@ public string ToString(string format, IFormatProvider formatProvider) [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] public static Vector operator ~(Vector value) { - return allOnes ^ value; + return s_allOnes ^ value; } #endregion Bitwise Operators @@ -2770,7 +2782,7 @@ public string ToString(string format, IFormatProvider formatProvider) /// /// The source vector /// The reinterpreted vector. - [JitIntrinsic] + [Intrinsic] public static explicit operator Vector(Vector value) { return new Vector(ref value.register); @@ -2782,7 +2794,7 @@ public static explicit operator Vector(Vector value) /// The source vector /// The reinterpreted vector. [CLSCompliant(false)] - [JitIntrinsic] + [Intrinsic] public static explicit operator Vector(Vector value) { return new Vector(ref value.register); @@ -2794,7 +2806,7 @@ public static explicit operator Vector(Vector value) /// The source vector /// The reinterpreted vector. [CLSCompliant(false)] - [JitIntrinsic] + [Intrinsic] public static explicit operator Vector(Vector value) { return new Vector(ref value.register); @@ -2805,7 +2817,7 @@ public static explicit operator Vector(Vector value) /// /// The source vector /// The reinterpreted vector. - [JitIntrinsic] + [Intrinsic] public static explicit operator Vector(Vector value) { return new Vector(ref value.register); @@ -2817,7 +2829,7 @@ public static explicit operator Vector(Vector value) /// The source vector /// The reinterpreted vector. [CLSCompliant(false)] - [JitIntrinsic] + [Intrinsic] public static explicit operator Vector(Vector value) { return new Vector(ref value.register); @@ -2828,7 +2840,7 @@ public static explicit operator Vector(Vector value) /// /// The source vector /// The reinterpreted vector. - [JitIntrinsic] + [Intrinsic] public static explicit operator Vector(Vector value) { return new Vector(ref value.register); @@ -2840,7 +2852,7 @@ public static explicit operator Vector(Vector value) /// The source vector /// The reinterpreted vector. [CLSCompliant(false)] - [JitIntrinsic] + [Intrinsic] public static explicit operator Vector(Vector value) { return new Vector(ref value.register); @@ -2851,7 +2863,7 @@ public static explicit operator Vector(Vector value) /// /// The source vector /// The reinterpreted vector. - [JitIntrinsic] + [Intrinsic] public static explicit operator Vector(Vector value) { return new Vector(ref value.register); @@ -2862,7 +2874,7 @@ public static explicit operator Vector(Vector value) /// /// The source vector /// The reinterpreted vector. - [JitIntrinsic] + [Intrinsic] public static explicit operator Vector(Vector value) { return new Vector(ref value.register); @@ -2873,7 +2885,7 @@ public static explicit operator Vector(Vector value) /// /// The source vector /// The reinterpreted vector. - [JitIntrinsic] + [Intrinsic] public static explicit operator Vector(Vector value) { return new Vector(ref value.register); @@ -2882,7 +2894,7 @@ public static explicit operator Vector(Vector value) #endregion Conversions #region Internal Comparison Methods - [JitIntrinsic] + [Intrinsic] [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] internal static unsafe Vector Equals(Vector left, Vector right) { @@ -3099,7 +3111,7 @@ internal static unsafe Vector Equals(Vector left, Vector right) } } - [JitIntrinsic] + [Intrinsic] [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] internal static unsafe Vector LessThan(Vector left, Vector right) { @@ -3316,7 +3328,7 @@ internal static unsafe Vector LessThan(Vector left, Vector right) } } - [JitIntrinsic] + [Intrinsic] [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] internal static unsafe Vector GreaterThan(Vector left, Vector right) { @@ -3533,19 +3545,19 @@ internal static unsafe Vector GreaterThan(Vector left, Vector right) } } - [JitIntrinsic] + [Intrinsic] internal static Vector GreaterThanOrEqual(Vector left, Vector right) { return Equals(left, right) | GreaterThan(left, right); } - [JitIntrinsic] + [Intrinsic] internal static Vector LessThanOrEqual(Vector left, Vector right) { return Equals(left, right) | LessThan(left, right); } - [JitIntrinsic] + [Intrinsic] internal static Vector ConditionalSelect(Vector condition, Vector left, Vector right) { return (left & condition) | (Vector.AndNot(right, condition)); @@ -3553,7 +3565,7 @@ internal static Vector ConditionalSelect(Vector condition, Vector left, #endregion Comparison Methods #region Internal Math Methods - [JitIntrinsic] + [Intrinsic] internal static unsafe Vector Abs(Vector value) { if (typeof(T) == typeof(Byte)) @@ -3702,7 +3714,7 @@ internal static unsafe Vector Abs(Vector value) } } - [JitIntrinsic] + [Intrinsic] internal static unsafe Vector Min(Vector left, Vector right) { if (Vector.IsHardwareAccelerated) @@ -3918,7 +3930,7 @@ internal static unsafe Vector Min(Vector left, Vector right) } } - [JitIntrinsic] + [Intrinsic] internal static unsafe Vector Max(Vector left, Vector right) { if (Vector.IsHardwareAccelerated) @@ -4134,12 +4146,12 @@ internal static unsafe Vector Max(Vector left, Vector right) } } - [JitIntrinsic] + [Intrinsic] internal static T DotProduct(Vector left, Vector right) { if (Vector.IsHardwareAccelerated) { - T product = GetZeroValue(); + T product = default; for (int g = 0; g < Count; g++) { product = ScalarAdd(product, ScalarMultiply(left[g], right[g])); @@ -4271,7 +4283,7 @@ internal static T DotProduct(Vector left, Vector right) } } - [JitIntrinsic] + [Intrinsic] internal static unsafe Vector SquareRoot(Vector value) { if (Vector.IsHardwareAccelerated) @@ -4831,65 +4843,6 @@ private static T ScalarDivide(T left, T right) } } - [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - private static T GetZeroValue() - { - if (typeof(T) == typeof(Byte)) - { - Byte value = 0; - return (T)(object)value; - } - else if (typeof(T) == typeof(SByte)) - { - SByte value = 0; - return (T)(object)value; - } - else if (typeof(T) == typeof(UInt16)) - { - UInt16 value = 0; - return (T)(object)value; - } - else if (typeof(T) == typeof(Int16)) - { - Int16 value = 0; - return (T)(object)value; - } - else if (typeof(T) == typeof(UInt32)) - { - UInt32 value = 0; - return (T)(object)value; - } - else if (typeof(T) == typeof(Int32)) - { - Int32 value = 0; - return (T)(object)value; - } - else if (typeof(T) == typeof(UInt64)) - { - UInt64 value = 0; - return (T)(object)value; - } - else if (typeof(T) == typeof(Int64)) - { - Int64 value = 0; - return (T)(object)value; - } - else if (typeof(T) == typeof(Single)) - { - Single value = 0; - return (T)(object)value; - } - else if (typeof(T) == typeof(Double)) - { - Double value = 0; - return (T)(object)value; - } - else - { - throw new NotSupportedException(SR.Arg_TypeNotSupported); - } - } - [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] private static T GetOneValue() { @@ -5010,7 +4963,7 @@ public static partial class Vector /// The second output vector, whose elements will contain the widened elements from higher indices in the source vector. /// [CLSCompliant(false)] - [JitIntrinsic] + [Intrinsic] public static unsafe void Widen(Vector source, out Vector low, out Vector high) { int elements = Vector.Count; @@ -5036,7 +4989,7 @@ public static unsafe void Widen(Vector source, out Vector low, out /// The second output vector, whose elements will contain the widened elements from higher indices in the source vector. /// [CLSCompliant(false)] - [JitIntrinsic] + [Intrinsic] public static unsafe void Widen(Vector source, out Vector low, out Vector high) { int elements = Vector.Count; @@ -5062,7 +5015,7 @@ public static unsafe void Widen(Vector source, out Vector low, o /// The second output vector, whose elements will contain the widened elements from higher indices in the source vector. /// [CLSCompliant(false)] - [JitIntrinsic] + [Intrinsic] public static unsafe void Widen(Vector source, out Vector low, out Vector high) { int elements = Vector.Count; @@ -5088,7 +5041,7 @@ public static unsafe void Widen(Vector source, out Vector low, o /// The second output vector, whose elements will contain the widened elements from higher indices in the source vector. /// [CLSCompliant(false)] - [JitIntrinsic] + [Intrinsic] public static unsafe void Widen(Vector source, out Vector low, out Vector high) { int elements = Vector.Count; @@ -5113,7 +5066,7 @@ public static unsafe void Widen(Vector source, out Vector low, out /// The first output vector, whose elements will contain the widened elements from lower indices in the source vector. /// The second output vector, whose elements will contain the widened elements from higher indices in the source vector. /// - [JitIntrinsic] + [Intrinsic] public static unsafe void Widen(Vector source, out Vector low, out Vector high) { int elements = Vector.Count; @@ -5138,7 +5091,7 @@ public static unsafe void Widen(Vector source, out Vector low, out /// The first output vector, whose elements will contain the widened elements from lower indices in the source vector. /// The second output vector, whose elements will contain the widened elements from higher indices in the source vector. /// - [JitIntrinsic] + [Intrinsic] public static unsafe void Widen(Vector source, out Vector low, out Vector high) { int elements = Vector.Count; @@ -5163,7 +5116,7 @@ public static unsafe void Widen(Vector source, out Vector low, out /// The first output vector, whose elements will contain the widened elements from lower indices in the source vector. /// The second output vector, whose elements will contain the widened elements from higher indices in the source vector. /// - [JitIntrinsic] + [Intrinsic] public static unsafe void Widen(Vector source, out Vector low, out Vector high) { int elements = Vector.Count; @@ -5189,7 +5142,7 @@ public static unsafe void Widen(Vector source, out Vector low, o /// A Vector{Byte} containing elements narrowed from the source vectors. /// [CLSCompliant(false)] - [JitIntrinsic] + [Intrinsic] public static unsafe Vector Narrow(Vector low, Vector high) { unchecked @@ -5216,7 +5169,7 @@ public static unsafe Vector Narrow(Vector low, Vector high /// A Vector{UInt16} containing elements narrowed from the source vectors. /// [CLSCompliant(false)] - [JitIntrinsic] + [Intrinsic] public static unsafe Vector Narrow(Vector low, Vector high) { unchecked @@ -5243,7 +5196,7 @@ public static unsafe Vector Narrow(Vector low, Vector hi /// A Vector{UInt32} containing elements narrowed from the source vectors. /// [CLSCompliant(false)] - [JitIntrinsic] + [Intrinsic] public static unsafe Vector Narrow(Vector low, Vector high) { unchecked @@ -5270,7 +5223,7 @@ public static unsafe Vector Narrow(Vector low, Vector hi /// A Vector{SByte} containing elements narrowed from the source vectors. /// [CLSCompliant(false)] - [JitIntrinsic] + [Intrinsic] public static unsafe Vector Narrow(Vector low, Vector high) { unchecked @@ -5296,7 +5249,7 @@ public static unsafe Vector Narrow(Vector low, Vector high) /// The second source vector, whose elements become the higher-index elements of the return value. /// A Vector{Int16} containing elements narrowed from the source vectors. /// - [JitIntrinsic] + [Intrinsic] public static unsafe Vector Narrow(Vector low, Vector high) { unchecked @@ -5322,7 +5275,7 @@ public static unsafe Vector Narrow(Vector low, Vector high) /// The second source vector, whose elements become the higher-index elements of the return value. /// A Vector{Int32} containing elements narrowed from the source vectors. /// - [JitIntrinsic] + [Intrinsic] public static unsafe Vector Narrow(Vector low, Vector high) { unchecked @@ -5348,7 +5301,7 @@ public static unsafe Vector Narrow(Vector low, Vector high) /// The second source vector, whose elements become the higher-index elements of the return value. /// A Vector{Single} containing elements narrowed from the source vectors. /// - [JitIntrinsic] + [Intrinsic] public static unsafe Vector Narrow(Vector low, Vector high) { unchecked @@ -5376,7 +5329,7 @@ public static unsafe Vector Narrow(Vector low, Vector hi /// /// The source vector. /// The converted vector. - [JitIntrinsic] + [Intrinsic] public static unsafe Vector ConvertToSingle(Vector value) { unchecked @@ -5398,7 +5351,7 @@ public static unsafe Vector ConvertToSingle(Vector value) /// The source vector. /// The converted vector. [CLSCompliant(false)] - [JitIntrinsic] + [Intrinsic] public static unsafe Vector ConvertToSingle(Vector value) { unchecked @@ -5419,7 +5372,7 @@ public static unsafe Vector ConvertToSingle(Vector value) /// /// The source vector. /// The converted vector. - [JitIntrinsic] + [Intrinsic] public static unsafe Vector ConvertToDouble(Vector value) { unchecked @@ -5441,7 +5394,7 @@ public static unsafe Vector ConvertToDouble(Vector value) /// The source vector. /// The converted vector. [CLSCompliant(false)] - [JitIntrinsic] + [Intrinsic] public static unsafe Vector ConvertToDouble(Vector value) { unchecked @@ -5462,7 +5415,7 @@ public static unsafe Vector ConvertToDouble(Vector value) /// /// The source vector. /// The converted vector. - [JitIntrinsic] + [Intrinsic] public static unsafe Vector ConvertToInt32(Vector value) { unchecked @@ -5484,7 +5437,7 @@ public static unsafe Vector ConvertToInt32(Vector value) /// The source vector. /// The converted vector. [CLSCompliant(false)] - [JitIntrinsic] + [Intrinsic] public static unsafe Vector ConvertToUInt32(Vector value) { unchecked @@ -5505,7 +5458,7 @@ public static unsafe Vector ConvertToUInt32(Vector value) /// /// The source vector. /// The converted vector. - [JitIntrinsic] + [Intrinsic] public static unsafe Vector ConvertToInt64(Vector value) { unchecked @@ -5527,7 +5480,7 @@ public static unsafe Vector ConvertToInt64(Vector value) /// The source vector. /// The converted vector. [CLSCompliant(false)] - [JitIntrinsic] + [Intrinsic] public static unsafe Vector ConvertToUInt64(Vector value) { unchecked diff --git a/src/System.Private.CoreLib/shared/System/Numerics/Vector.tt b/src/System.Private.CoreLib/shared/System/Numerics/Vector.tt index 1bb47f5c1ae..84e57b02fc3 100644 --- a/src/System.Private.CoreLib/shared/System/Numerics/Vector.tt +++ b/src/System.Private.CoreLib/shared/System/Numerics/Vector.tt @@ -53,9 +53,9 @@ namespace System.Numerics /// /// Returns the number of elements stored in the vector. This value is hardware dependent. /// - [JitIntrinsic] public static int Count { + [Intrinsic] get { return s_count; @@ -66,19 +66,31 @@ namespace System.Numerics /// /// Returns a vector containing all zeroes. /// - [JitIntrinsic] - public static Vector Zero { get { return zero; } } - private static readonly Vector zero = new Vector(GetZeroValue()); + public static Vector Zero + { + [Intrinsic] + get + { + return s_zero; + } + } + private static readonly Vector s_zero = new Vector(); /// /// Returns a vector containing all ones. /// - [JitIntrinsic] - public static Vector One { get { return one; } } - private static readonly Vector one = new Vector(GetOneValue()); + public static Vector One + { + [Intrinsic] + get + { + return s_one; + } + } + private static readonly Vector s_one = new Vector(GetOneValue()); - internal static Vector AllOnes { get { return allOnes; } } - private static readonly Vector allOnes = new Vector(GetAllBitsSetValue()); + internal static Vector AllOnes { get { return s_allOnes; } } + private static readonly Vector s_allOnes = new Vector(GetAllBitsSetValue()); #endregion Static Members #region Static Initialization @@ -120,7 +132,7 @@ namespace System.Numerics /// /// Constructs a vector whose components are all value /// - [JitIntrinsic] + [Intrinsic] public unsafe Vector(T value) : this() { @@ -168,7 +180,7 @@ namespace System.Numerics /// /// Constructs a vector from the given array. The size of the given array must be at least Vector'T.Count. /// - [JitIntrinsic] + [Intrinsic] public unsafe Vector(T[] values) : this(values, 0) { } /// @@ -279,7 +291,7 @@ namespace System.Numerics /// The destination array which the values are copied into /// If the destination array is null /// If number of elements in source vector is greater than those available in destination array - [JitIntrinsic] + [Intrinsic] public unsafe void CopyTo(T[] destination) { CopyTo(destination, 0); @@ -293,7 +305,7 @@ namespace System.Numerics /// If the destination array is null /// If index is greater than end of the array or index is less than zero /// If number of elements in source vector is greater than those available in destination array - [JitIntrinsic] + [Intrinsic] public unsafe void CopyTo(T[] destination, int startIndex) { if (destination == null) @@ -359,9 +371,9 @@ namespace System.Numerics /// /// Returns the element at the given index. /// - [JitIntrinsic] public unsafe T this[int index] { + [Intrinsic] get { if (index >= Count || index < 0) @@ -408,7 +420,7 @@ namespace System.Numerics /// /// The vector to compare this instance to. /// True if the other vector is equal to this instance; False otherwise. - [JitIntrinsic] + [Intrinsic] public bool Equals(Vector other) { if (Vector.IsHardwareAccelerated) @@ -891,7 +903,7 @@ namespace System.Numerics /// The first source vector. /// The second source vector. /// The resultant vector. - [JitIntrinsic] + [Intrinsic] public static unsafe Vector operator &(Vector left, Vector right) { Vector result = new Vector(); @@ -922,7 +934,7 @@ namespace System.Numerics /// The first source vector. /// The second source vector. /// The resultant vector. - [JitIntrinsic] + [Intrinsic] public static unsafe Vector operator |(Vector left, Vector right) { Vector result = new Vector(); @@ -953,7 +965,7 @@ namespace System.Numerics /// The first source vector. /// The second source vector. /// The resultant vector. - [JitIntrinsic] + [Intrinsic] public static unsafe Vector operator ^(Vector left, Vector right) { Vector result = new Vector(); @@ -1033,7 +1045,7 @@ namespace System.Numerics <# } #> - [JitIntrinsic] + [Intrinsic] public static explicit operator Vector<<#=type.Name#>>(Vector value) { return new Vector<<#=type.Name#>>(ref value.register); @@ -1045,7 +1057,7 @@ namespace System.Numerics #endregion Conversions #region Internal Comparison Methods - [JitIntrinsic] + [Intrinsic] [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] internal static unsafe Vector Equals(Vector left, Vector right) { @@ -1099,7 +1111,7 @@ namespace System.Numerics } } - [JitIntrinsic] + [Intrinsic] [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] internal static unsafe Vector LessThan(Vector left, Vector right) { @@ -1153,7 +1165,7 @@ namespace System.Numerics } } - [JitIntrinsic] + [Intrinsic] [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] internal static unsafe Vector GreaterThan(Vector left, Vector right) { @@ -1207,19 +1219,19 @@ namespace System.Numerics } } - [JitIntrinsic] + [Intrinsic] internal static Vector GreaterThanOrEqual(Vector left, Vector right) { return Equals(left, right) | GreaterThan(left, right); } - [JitIntrinsic] + [Intrinsic] internal static Vector LessThanOrEqual(Vector left, Vector right) { return Equals(left, right) | LessThan(left, right); } - [JitIntrinsic] + [Intrinsic] internal static Vector ConditionalSelect(Vector condition, Vector left, Vector right) { return (left & condition) | (Vector.AndNot(right, condition)); @@ -1227,7 +1239,7 @@ namespace System.Numerics #endregion Comparison Methods #region Internal Math Methods - [JitIntrinsic] + [Intrinsic] internal static unsafe Vector Abs(Vector value) { <# @@ -1295,7 +1307,7 @@ namespace System.Numerics } } - [JitIntrinsic] + [Intrinsic] internal static unsafe Vector Min(Vector left, Vector right) { if (Vector.IsHardwareAccelerated) @@ -1348,7 +1360,7 @@ namespace System.Numerics } } - [JitIntrinsic] + [Intrinsic] internal static unsafe Vector Max(Vector left, Vector right) { if (Vector.IsHardwareAccelerated) @@ -1401,12 +1413,12 @@ namespace System.Numerics } } - [JitIntrinsic] + [Intrinsic] internal static T DotProduct(Vector left, Vector right) { if (Vector.IsHardwareAccelerated) { - T product = GetZeroValue(); + T product = default; for (int g = 0; g < Count; g++) { product = ScalarAdd(product, ScalarMultiply(left[g], right[g])); @@ -1441,7 +1453,7 @@ namespace System.Numerics } } - [JitIntrinsic] + [Intrinsic] internal static unsafe Vector SquareRoot(Vector value) { if (Vector.IsHardwareAccelerated) @@ -1628,26 +1640,6 @@ namespace System.Numerics } } - [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] - private static T GetZeroValue() - { -<# foreach (Type type in supportedTypes) - { -#> - <#=GenerateIfStatementHeader(type)#> - { - <#=type.Name#> value = 0; - return (T)(object)value; - } -<# - } -#> - else - { - throw new NotSupportedException(SR.Arg_TypeNotSupported); - } - } - [MethodImplAttribute(MethodImplOptions.AggressiveInlining)] private static T GetOneValue() { @@ -1710,7 +1702,7 @@ namespace System.Numerics <# } #> - [JitIntrinsic] + [Intrinsic] public static unsafe void Widen(Vector<<#=type.Name#>> source, out Vector<<#=widenTarget.Name#>> low, out Vector<<#=widenTarget.Name#>> high) { int elements = Vector<<#=type.Name#>>.Count; @@ -1750,7 +1742,7 @@ namespace System.Numerics <# } #> - [JitIntrinsic] + [Intrinsic] public static unsafe Vector<<#=narrowTarget.Name#>> Narrow(Vector<<#=narrowSource.Name#>> low, Vector<<#=narrowSource.Name#>> high) { unchecked @@ -1792,7 +1784,7 @@ namespace System.Numerics <# } #> - [JitIntrinsic] + [Intrinsic] public static unsafe Vector<<#=pair.Value.Name#>> ConvertTo<#=pair.Value.Name#>(Vector<<#=pair.Key.Name#>> value) { unchecked diff --git a/src/System.Private.CoreLib/shared/System/Numerics/Vector_Operations.cs b/src/System.Private.CoreLib/shared/System/Numerics/Vector_Operations.cs index 4fbcb1670f6..b69b058be94 100644 --- a/src/System.Private.CoreLib/shared/System/Numerics/Vector_Operations.cs +++ b/src/System.Private.CoreLib/shared/System/Numerics/Vector_Operations.cs @@ -524,9 +524,9 @@ public static bool GreaterThanOrEqualAny(Vector left, Vector right) whe /// /// Returns whether or not vector operations are subject to hardware acceleration through JIT intrinsic support. /// - [JitIntrinsic] public static bool IsHardwareAccelerated { + [Intrinsic] get { return false;