Revert unintentional alignment change for Vector256<T> (#36673)
authorAnton Lapounov <antonl@microsoft.com>
Tue, 19 May 2020 17:09:08 +0000 (10:09 -0700)
committerGitHub <noreply@github.com>
Tue, 19 May 2020 17:09:08 +0000 (10:09 -0700)
Addresses https://github.com/dotnet/runtime/pull/35864#issuecomment-629803015.  In an earlier change I also added the `type.Instantiation[0].IsPrimitive` condition to the `IsVectorType` predicate.  Revert that part as well and allow only primitive numeric types for HFA/HVA purpose.  The same list of 10 types is recognized in `MethodTable::GetVectorSize` and `Compiler::getBaseTypeAndSizeOfSIMDType`.

src/coreclr/src/tools/Common/Compiler/VectorFieldLayoutAlgorithm.cs
src/coreclr/src/tools/Common/JitInterface/CorInfoImpl.cs
src/coreclr/src/tools/Common/TypeSystem/Common/TypeDesc.cs

index 4720ea4..12ded51 100644 (file)
@@ -90,7 +90,8 @@ namespace ILCompiler
 
         public override ValueTypeShapeCharacteristics ComputeValueTypeShapeCharacteristics(DefType type)
         {
-            if (type.Context.Target.Architecture == TargetArchitecture.ARM64)
+            if (type.Context.Target.Architecture == TargetArchitecture.ARM64 &&
+                type.Instantiation[0].IsPrimitiveNumeric)
             {
                 return type.InstanceFieldSize.AsInt switch
                 {
@@ -106,8 +107,9 @@ namespace ILCompiler
         {
             return type.IsIntrinsic &&
                 type.Namespace == "System.Runtime.Intrinsics" &&
-                ((type.Name == "Vector64`1") || (type.Name == "Vector128`1")) &&
-                type.Instantiation[0].IsPrimitive;
+                (type.Name == "Vector64`1" ||
+                type.Name == "Vector128`1" ||
+                type.Name == "Vector256`1");
         }
     }
 }
index 175becc..205304c 100644 (file)
@@ -1759,23 +1759,10 @@ namespace Internal.JitInterface
         {
             var type = HandleToObject(cls);
 
-            switch (type.Category)
-            {
-                case TypeFlags.Byte:
-                case TypeFlags.SByte:
-                case TypeFlags.UInt16:
-                case TypeFlags.Int16:
-                case TypeFlags.UInt32:
-                case TypeFlags.Int32:
-                case TypeFlags.UInt64:
-                case TypeFlags.Int64:
-                case TypeFlags.Single:
-                case TypeFlags.Double:
-                    return asCorInfoType(type);
+            if (type.IsPrimitiveNumeric)
+                return asCorInfoType(type);
 
-                default:
-                    return CorInfoType.CORINFO_TYPE_UNDEF;
-            }
+            return CorInfoType.CORINFO_TYPE_UNDEF;
         }
 
         private bool canCast(CORINFO_CLASS_STRUCT_* child, CORINFO_CLASS_STRUCT_* parent)
index d9110d1..cf266f0 100644 (file)
@@ -188,7 +188,7 @@ namespace Internal.TypeSystem
 
         /// <summary>
         /// Gets a value indicating whether this is one of the primitive types (boolean, char, void,
-        /// a floating point, or an integer type).
+        /// a floating-point, or an integer type).
         /// </summary>
         public bool IsPrimitive
         {
@@ -199,6 +199,34 @@ namespace Internal.TypeSystem
         }
 
         /// <summary>
+        /// Gets a value indicating whether this is one of the primitive numeric types
+        /// (a floating-point or an integer type).
+        /// </summary>
+        public bool IsPrimitiveNumeric
+        {
+            get
+            {
+                switch (GetTypeFlags(TypeFlags.CategoryMask))
+                {
+                    case TypeFlags.SByte:
+                    case TypeFlags.Byte:
+                    case TypeFlags.Int16:
+                    case TypeFlags.UInt16:
+                    case TypeFlags.Int32:
+                    case TypeFlags.UInt32:
+                    case TypeFlags.Int64:
+                    case TypeFlags.UInt64:
+                    case TypeFlags.Single:
+                    case TypeFlags.Double:
+                        return true;
+
+                    default:
+                        return false;
+                }
+            }
+        }
+
+        /// <summary>
         /// Gets a value indicating whether this is an enum type.
         /// Access <see cref="UnderlyingType"/> to retrieve the underlying integral type.
         /// </summary>