Ensure the size of Vector<T> takes COMPlus_EnableHWIntrinsic into account (#39368)
authorTanner Gooding <tagoo@outlook.com>
Thu, 23 Jul 2020 18:41:38 +0000 (11:41 -0700)
committerGitHub <noreply@github.com>
Thu, 23 Jul 2020 18:41:38 +0000 (11:41 -0700)
* Ensure the size of Vector<T> takes COMPlus_EnableHWIntrinsic into account

* Add basic logging to Runtime_34587

* Exclude InstructionSet_POPCNT and InstructionSet_POPCNT_X64 if featureSIMD is disabled

src/coreclr/src/jit/compiler.h
src/coreclr/src/jit/ee_il_dll.cpp
src/coreclr/src/jit/hwintrinsicxarch.cpp
src/tests/JIT/Regression/JitBlue/Runtime_34587/Runtime_34587.cs
src/tests/JIT/Regression/JitBlue/Runtime_34587/Runtime_34587.csproj

index c5f5718..28521b8 100644 (file)
@@ -8190,7 +8190,7 @@ private:
 #if defined(TARGET_XARCH)
         if (getSIMDSupportLevel() == SIMD_AVX2_Supported)
         {
-            return TYP_SIMD32;
+            return JitConfig.EnableHWIntrinsic() ? TYP_SIMD32 : TYP_SIMD16;
         }
         else
         {
@@ -8231,7 +8231,7 @@ private:
 #if defined(TARGET_XARCH)
         if (getSIMDSupportLevel() == SIMD_AVX2_Supported)
         {
-            return YMM_REGSIZE_BYTES;
+            return JitConfig.EnableHWIntrinsic() ? YMM_REGSIZE_BYTES : XMM_REGSIZE_BYTES;
         }
         else
         {
@@ -8261,7 +8261,7 @@ private:
 #if defined(FEATURE_HW_INTRINSICS) && defined(TARGET_XARCH)
         if (compOpportunisticallyDependsOn(InstructionSet_AVX))
         {
-            return YMM_REGSIZE_BYTES;
+            return JitConfig.EnableHWIntrinsic() ? YMM_REGSIZE_BYTES : XMM_REGSIZE_BYTES;
         }
         else
         {
index 150efed..bfd80ff 100644 (file)
@@ -316,7 +316,8 @@ unsigned CILJit::getMaxIntrinsicSIMDVectorLength(CORJIT_FLAGS cpuCompileFlags)
         // ensure that AVX2 is actually supported. Otherwise, we will end up getting asserts downstream.
         if ((JitConfig.EnableAVX2() != 0) && (JitConfig.EnableAVX() != 0) && (JitConfig.EnableSSE42() != 0) &&
             (JitConfig.EnableSSE41() != 0) && (JitConfig.EnableSSSE3() != 0) && (JitConfig.EnableSSE3_4() != 0) &&
-            (JitConfig.EnableSSE3() != 0) && (JitConfig.EnableSSE2() != 0) && (JitConfig.EnableSSE() != 0))
+            (JitConfig.EnableSSE3() != 0) && (JitConfig.EnableSSE2() != 0) && (JitConfig.EnableSSE() != 0) &&
+            (JitConfig.EnableHWIntrinsic() != 0))
         {
             if (GetJitTls() != nullptr && JitTls::GetCompiler() != nullptr)
             {
index 8d7824e..e624f18 100644 (file)
@@ -405,11 +405,12 @@ bool HWIntrinsicInfo::isScalarIsa(CORINFO_InstructionSet isa)
         case InstructionSet_BMI2_X64:
         case InstructionSet_LZCNT:
         case InstructionSet_LZCNT_X64:
-        case InstructionSet_POPCNT:
-        case InstructionSet_POPCNT_X64:
         case InstructionSet_X86Base:
         case InstructionSet_X86Base_X64:
         {
+            // InstructionSet_POPCNT and InstructionSet_POPCNT_X64 are excluded
+            // even though they are "scalar" ISA because they depend on SSE4.2
+            // and Popcnt.IsSupported implies Sse42.IsSupported
             return true;
         }
 
index 3b4898b..7cea12d 100644 (file)
@@ -14,6 +14,60 @@ class Runtime_34587
 {
     public static int Main()
     {
+        TestLibrary.TestFramework.LogInformation("Supported x86 ISAs:");
+        TestLibrary.TestFramework.LogInformation($"  AES:           {X86Aes.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  AVX:           {Avx.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  AVX2:          {Avx2.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  BMI1:          {Bmi1.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  BMI2:          {Bmi2.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  FMA:           {Fma.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  LZCNT:         {Lzcnt.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  PCLMULQDQ:     {Pclmulqdq.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  POPCNT:        {Popcnt.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  SSE:           {Sse.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  SSE2:          {Sse2.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  SSE3:          {Sse3.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  SSE4.1:        {Sse41.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  SSE4.2:        {Sse42.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  SSSE3:         {Ssse3.IsSupported}");
+
+        TestLibrary.TestFramework.LogInformation("Supported x64 ISAs:");
+        TestLibrary.TestFramework.LogInformation($"  AES.X64:       {X86Aes.X64.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  AVX.X64:       {Avx.X64.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  AVX2.X64:      {Avx2.X64.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  BMI1.X64:      {Bmi1.X64.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  BMI2.X64:      {Bmi2.X64.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  FMA.X64:       {Fma.X64.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  LZCNT.X64:     {Lzcnt.X64.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  PCLMULQDQ.X64: {Pclmulqdq.X64.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  POPCNT.X64:    {Popcnt.X64.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  SSE.X64:       {Sse.X64.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  SSE2.X64:      {Sse2.X64.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  SSE3.X64:      {Sse3.X64.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  SSE4.1.X64:    {Sse41.X64.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  SSE4.2.X64:    {Sse42.X64.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  SSSE3.X64:     {Ssse3.X64.IsSupported}");
+
+        TestLibrary.TestFramework.LogInformation("Supported Arm ISAs:");
+        TestLibrary.TestFramework.LogInformation($"  AdvSimd:       {AdvSimd.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  Aes:           {ArmAes.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  ArmBase:       {ArmBase.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  Crc32:         {Crc32.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  Dp:            {Dp.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  Rdm:           {Rdm.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  Sha1:          {Sha1.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  Sha256:        {Sha256.IsSupported}");
+
+        TestLibrary.TestFramework.LogInformation("Supported Arm64 ISAs:");
+        TestLibrary.TestFramework.LogInformation($"  AdvSimd.Arm64: {AdvSimd.Arm64.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  Aes.Arm64:     {ArmAes.Arm64.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  ArmBase.Arm64: {ArmBase.Arm64.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  Crc32.Arm64:   {Crc32.Arm64.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  Dp.Arm64:      {Dp.Arm64.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  Rdm.Arm64:     {Rdm.Arm64.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  Sha1.Arm64:    {Sha1.Arm64.IsSupported}");
+        TestLibrary.TestFramework.LogInformation($"  Sha256.Arm64:  {Sha256.Arm64.IsSupported}");
+
         bool succeeded = true;
 
         succeeded &= ValidateArm();
index 5d49e8d..17923c1 100644 (file)
@@ -10,4 +10,7 @@
   <ItemGroup>
     <Compile Include="$(MSBuildProjectName).cs" />
   </ItemGroup>
+  <ItemGroup>
+    <ProjectReference Include="$(TestSourceDir)Common/CoreCLRTestLibrary/CoreCLRTestLibrary.csproj" />
+  </ItemGroup>
 </Project>