Ensure that fgMorphFieldToSimdGetElement doesn't call gtNewSimdGetElementNode if...
authorTanner Gooding <tagoo@outlook.com>
Wed, 23 Mar 2022 20:35:33 +0000 (13:35 -0700)
committerGitHub <noreply@github.com>
Wed, 23 Mar 2022 20:35:33 +0000 (13:35 -0700)
* Ensure that fgMorphFieldToSimdGetElement doesn't call gtNewSimdGetElementNode if the ISA is unsupported

* Ensure fgMorphFieldToSimdGetElement is correctly checking for AdvSimd support on Arm64

* Ensure impExpandHalfConstEqualsSIMD checks for baseline simd support

src/coreclr/jit/importer_vectorization.cpp
src/coreclr/jit/morph.cpp

index ed8e9c5..9752f3a 100644 (file)
@@ -142,9 +142,9 @@ GenTree* Compiler::impExpandHalfConstEqualsSIMD(
     constexpr int maxPossibleLength = 32;
     assert(len >= 8 && len <= maxPossibleLength);
 
-    if (!compOpportunisticallyDependsOn(InstructionSet_Vector128))
+    if (!IsBaselineSimdIsaSupported())
     {
-        // We need SSE2 or ADVSIMD at least
+        // We need baseline SIMD support at least
         return nullptr;
     }
 
index 9f8b87b..d233393 100644 (file)
@@ -10833,6 +10833,47 @@ GenTree* Compiler::fgMorphFieldToSimdGetElement(GenTree* tree)
         assert(simdSize <= 16);
         assert(simdSize >= ((index + 1) * genTypeSize(simdBaseType)));
 
+#if defined(TARGET_XARCH)
+        switch (simdBaseType)
+        {
+            case TYP_BYTE:
+            case TYP_UBYTE:
+            case TYP_INT:
+            case TYP_UINT:
+            case TYP_LONG:
+            case TYP_ULONG:
+            {
+                if (!compOpportunisticallyDependsOn(InstructionSet_SSE41))
+                {
+                    return tree;
+                }
+                break;
+            }
+
+            case TYP_DOUBLE:
+            case TYP_FLOAT:
+            case TYP_SHORT:
+            case TYP_USHORT:
+            {
+                if (!compOpportunisticallyDependsOn(InstructionSet_SSE2))
+                {
+                    return tree;
+                }
+                break;
+            }
+
+            default:
+            {
+                unreached();
+            }
+        }
+#elif defined(TARGET_ARM64)
+        if (!compOpportunisticallyDependsOn(InstructionSet_AdvSimd))
+        {
+            return tree;
+        }
+#endif // !TARGET_XARCH && !TARGET_ARM64
+
         tree = gtNewSimdGetElementNode(simdBaseType, simdStructNode, op2, simdBaseJitType, simdSize,
                                        /* isSimdAsHWIntrinsic */ true);
     }