Implement simple Sse2 hardware intrinsics
authorJacek Blaszczynski <biosciencenow@outlook.com>
Fri, 26 Jan 2018 15:59:54 +0000 (16:59 +0100)
committerJacek Blaszczynski <biosciencenow@outlook.com>
Wed, 31 Jan 2018 12:22:01 +0000 (13:22 +0100)
130 files changed:
src/jit/compiler.h
src/jit/emitxarch.cpp
src/jit/gentree.cpp
src/jit/hwintrinsiccodegenxarch.cpp
src/jit/hwintrinsiclistxarch.h
src/jit/hwintrinsicxarch.cpp
src/jit/instrsxarch.h
src/jit/lower.cpp
src/jit/namedintrinsiclist.h
tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse/Max_r.csproj
tests/src/JIT/HardwareIntrinsics/X86/Sse/Max_ro.csproj
tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/And_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/And_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Average.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Average_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Average_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThanOrEqual.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThanOrEqual_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThanOrEqual_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThanOrEqual.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThanOrEqual_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThanOrEqual_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotEqual.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotEqual_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotEqual_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThan.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThanOrEqual.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThanOrEqual_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThanOrEqual_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThan_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThan_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThan.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThanOrEqual.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThanOrEqual_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThanOrEqual_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThan_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThan_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareOrdered.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareOrdered_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareOrdered_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareUnordered.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareUnordered_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareUnordered_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Double.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Double_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Double_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Int32.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Int32WithTruncation.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Int32WithTruncation_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Int32WithTruncation_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Int32_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Int32_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Single.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Single_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Single_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Divide.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Divide_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Divide_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Multiply.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyHigh.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyHigh_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyHigh_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyHorizontalAdd.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyHorizontalAdd_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyHorizontalAdd_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyLow.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyLow_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyLow_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Multiply_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Multiply_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/PackSignedSaturate.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/PackSignedSaturate_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/PackSignedSaturate_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/PackUnsignedSaturate.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/PackUnsignedSaturate_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/PackUnsignedSaturate_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetZeroVector128.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetZeroVector128_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetZeroVector128_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sqrt.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sqrt_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sqrt_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/SumAbsoluteDifferences.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/SumAbsoluteDifferences_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/SumAbsoluteDifferences_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/TestTableSse2.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/UnpackHigh.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/UnpackHigh_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/UnpackHigh_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/UnpackLow.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/UnpackLow_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/UnpackLow_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Sse2/dir.props [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/dir.props [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/dir.props [new file with mode: 0644]

index aadd7fc..b7b0626 100644 (file)
@@ -7975,7 +7975,7 @@ private:
 #endif
     }
 
-    // Whether SSE3, SSE3, SSE4.1 and SSE4.2 is available
+    // Whether SSE3, SSSE3, SSE4.1 and SSE4.2 is available
     bool CanUseSSE4() const
     {
 #ifdef _TARGET_XARCH_
index 941009d..c42f926 100644 (file)
@@ -122,9 +122,15 @@ bool emitter::IsDstDstSrcAVXInstruction(instruction ins)
         case INS_paddb:
         case INS_paddd:
         case INS_paddq:
+        case INS_paddsb:
+        case INS_paddsw:
+        case INS_paddusb:
+        case INS_paddusw:
         case INS_paddw:
         case INS_pand:
         case INS_pandn:
+        case INS_pavgb:
+        case INS_pavgw:
         case INS_pcmpeqb:
         case INS_pcmpeqd:
         case INS_pcmpeqq:
@@ -135,6 +141,7 @@ bool emitter::IsDstDstSrcAVXInstruction(instruction ins)
         case INS_pcmpgtw:
         case INS_phaddd:
         case INS_pinsrw:
+        case INS_pmaddwd:
         case INS_pmaxsb:
         case INS_pmaxsd:
         case INS_pmaxsw:
@@ -148,13 +155,20 @@ bool emitter::IsDstDstSrcAVXInstruction(instruction ins)
         case INS_pminud:
         case INS_pminuw:
         case INS_pmuldq:
+        case INS_pmulhuw:
+        case INS_pmulhw:
         case INS_pmulld:
         case INS_pmullw:
         case INS_pmuludq:
         case INS_por:
+        case INS_psadbw:
         case INS_psubb:
         case INS_psubd:
         case INS_psubq:
+        case INS_psubsb:
+        case INS_psubsw:
+        case INS_psubusb:
+        case INS_psubusw:
         case INS_psubw:
         case INS_punpckhbw:
         case INS_punpckhdq:
@@ -173,6 +187,8 @@ bool emitter::IsDstDstSrcAVXInstruction(instruction ins)
         case INS_subss:
         case INS_unpckhps:
         case INS_unpcklps:
+        case INS_unpckhpd:
+        case INS_unpcklpd:
         case INS_vinsertf128:
         case INS_vinserti128:
         case INS_vperm2i128:
@@ -5432,7 +5448,7 @@ void emitter::emitIns_SIMD_R_R_S_I(
         emitIns_R_S_I(ins, attr, reg, varx, offs, ival);
     }
 }
-#endif
+#endif // FEATURE_HW_INTRINSICS
 
 /*****************************************************************************
  *
index 2676743..1bf923b 100644 (file)
@@ -404,6 +404,10 @@ void GenTree::InitNodeSize()
 #ifdef FEATURE_SIMD
     static_assert_no_msg(sizeof(GenTreeSIMD)         <= TREE_NODE_SZ_SMALL);
 #endif // FEATURE_SIMD
+
+#ifdef FEATURE_HW_INTRINSICS
+    static_assert_no_msg(sizeof(GenTreeHWIntrinsic)  <= TREE_NODE_SZ_SMALL);
+#endif // FEATURE_HW_INTRINSICS
     // clang-format on
 }
 
@@ -8838,6 +8842,16 @@ unsigned GenTree::NumChildren()
             }
             return childCount;
         }
+#ifdef FEATURE_HW_INTRINSICS
+        // GT_HWIntrinsic require special handling
+        if (OperGet() == GT_HWIntrinsic)
+        {
+            if (gtOp.gtOp1 == nullptr)
+            {
+                return 0;
+            }
+        }
+#endif
         // Special case for assignment of dynamic block.
         // This is here to duplicate the former case where the size may be evaluated prior to the
         // source and destination addresses. In order to do this, we treat the size as a child of the
index e691957..e2b9962 100644 (file)
@@ -87,7 +87,6 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node)
                 }
                 else
                 {
-
                     emit->emitIns_R_R(ins, simdSize, targetReg, op1Reg);
                 }
                 break;
@@ -98,7 +97,7 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node)
                 {
                     emit->emitIns_AR_R(ins, emitTypeSize(TYP_SIMD16), op2->gtRegNum, op1->gtRegNum, 0);
                 }
-                else if (ival != -1)
+                else if ((ival != -1) && varTypeIsFloating(baseType))
                 {
                     genHWIntrinsic_R_R_RM_I(node, ins);
                 }
@@ -677,13 +676,59 @@ void CodeGen::genSSEIntrinsic(GenTreeHWIntrinsic* node)
 void CodeGen::genSSE2Intrinsic(GenTreeHWIntrinsic* node)
 {
     NamedIntrinsic intrinsicID = node->gtHWIntrinsicId;
+    GenTree*       op1         = node->gtGetOp1();
+    GenTree*       op2         = node->gtGetOp2();
+    regNumber      targetReg   = node->gtRegNum;
+    var_types      targetType  = node->TypeGet();
     var_types      baseType    = node->gtSIMDBaseType;
-    instruction    ins         = INS_invalid;
+    instruction    ins         = Compiler::insOfHWIntrinsic(intrinsicID, baseType);
+    regNumber      op1Reg      = REG_NA;
+    regNumber      op2Reg      = REG_NA;
+    emitter*       emit        = getEmitter();
+    int            ival        = -1;
 
-    genConsumeOperands(node);
+    if ((op1 != nullptr) && !op1->OperIsList())
+    {
+        op1Reg = op1->gtRegNum;
+        genConsumeOperands(node);
+    }
 
     switch (intrinsicID)
     {
+        // All integer overloads are handled by table codegen
+        case NI_SSE2_CompareLessThan:
+        {
+            assert(op1 != nullptr);
+            assert(op2 != nullptr);
+            assert(baseType == TYP_DOUBLE);
+
+            op2Reg = op2->gtRegNum;
+            ival   = Compiler::ivalOfHWIntrinsic(intrinsicID);
+            emit->emitIns_SIMD_R_R_R_I(ins, emitTypeSize(TYP_SIMD16), targetReg, op1Reg, op2Reg, ival);
+
+            break;
+        }
+
+        case NI_SSE2_MoveMask:
+        {
+            assert(op2 == nullptr);
+            assert(baseType == TYP_BYTE || baseType == TYP_UBYTE || baseType == TYP_DOUBLE);
+
+            emit->emitIns_R_R(ins, emitTypeSize(TYP_INT), targetReg, op1Reg);
+            break;
+        }
+
+        case NI_SSE2_SetZeroVector128:
+        {
+            assert(baseType != TYP_FLOAT);
+            assert(baseType >= TYP_BYTE && baseType <= TYP_DOUBLE);
+            assert(op1 == nullptr);
+            assert(op2 == nullptr);
+
+            emit->emitIns_SIMD_R_R_R(ins, emitTypeSize(TYP_SIMD16), targetReg, targetReg, targetReg);
+            break;
+        }
+
         default:
             unreached();
             break;
index cb5edc0..3ce448c 100644 (file)
@@ -26,9 +26,9 @@
 //                  Intrinsic ID                                      Function name                                      ISA        ival       SIMD size       NumArg                                                                   instructions                                                                                              Category                                         Flags
 //                                                                                                                                                                            {TYP_BYTE,      TYP_UBYTE,     TYP_SHORT,     TYP_USHORT,    TYP_INT,       TYP_UINT,      TYP_LONG,      TYP_ULONG,     TYP_FLOAT,     TYP_DOUBLE}
 // ************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
-//  SSE Intrinsics          
-HARDWARE_INTRINSIC(SSE_IsSupported,                                  "get_IsSupported",                                  SSE,        -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)                 
-HARDWARE_INTRINSIC(SSE_Add,                                          "Add",                                              SSE,        -1,           16,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_addps,     INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_Commutative)                 
+//  SSE Intrinsics
+HARDWARE_INTRINSIC(SSE_IsSupported,                                  "get_IsSupported",                                  SSE,        -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(SSE_Add,                                          "Add",                                              SSE,        -1,           16,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_addps,     INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_Commutative)
 HARDWARE_INTRINSIC(SSE_AddScalar,                                    "AddScalar",                                        SSE,        -1,           16,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_addss,     INS_invalid},           HW_Category_SIMDScalar,                        HW_Flag_Commutative)
 HARDWARE_INTRINSIC(SSE_And,                                          "And",                                              SSE,        -1,           16,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_andps,     INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_Commutative)
 HARDWARE_INTRINSIC(SSE_AndNot,                                       "AndNot",                                           SSE,        -1,           16,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_andnps,    INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
@@ -74,8 +74,8 @@ HARDWARE_INTRINSIC(SSE_ConvertToSingle,                              "ConvertToS
 HARDWARE_INTRINSIC(SSE_ConvertToVector128SingleScalar,               "ConvertToVector128SingleScalar",                   SSE,        -1,           16,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_cvtsi2ss,  INS_invalid},           HW_Category_Special,                           HW_Flag_NoFlag)
 HARDWARE_INTRINSIC(SSE_ConvertToInt32WithTruncation,                 "ConvertToInt32WithTruncation",                     SSE,        -1,           16,           1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_cvttss2si, INS_invalid},           HW_Category_SIMDScalar,                        HW_Flag_NoContainment)
 HARDWARE_INTRINSIC(SSE_ConvertToInt64WithTruncation,                 "ConvertToInt64WithTruncation",                     SSE,        -1,           16,           1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_cvttss2si, INS_invalid},           HW_Category_SIMDScalar,                        HW_Flag_NoContainment)
-HARDWARE_INTRINSIC(SSE_Divide,                                       "Divide",                                           SSE,        -1,           16,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_divps,     INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_NoContainment)
-HARDWARE_INTRINSIC(SSE_DivideScalar,                                 "DivideScalar",                                     SSE,        -1,           16,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_divss,     INS_invalid},           HW_Category_SIMDScalar,                        HW_Flag_NoContainment)
+HARDWARE_INTRINSIC(SSE_Divide,                                       "Divide",                                           SSE,        -1,           16,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_divps,     INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(SSE_DivideScalar,                                 "DivideScalar",                                     SSE,        -1,           16,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_divss,     INS_invalid},           HW_Category_SIMDScalar,                        HW_Flag_NoFlag)
 HARDWARE_INTRINSIC(SSE_LoadAlignedVector128,                         "LoadAlignedVector128",                             SSE,        -1,           16,           1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_movaps,    INS_invalid},           HW_Category_MemoryLoad,                        HW_Flag_NoFlag)
 HARDWARE_INTRINSIC(SSE_LoadHigh,                                     "LoadHigh",                                         SSE,        -1,           16,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_movhps,    INS_invalid},           HW_Category_MemoryLoad,                        HW_Flag_NoFlag)
 HARDWARE_INTRINSIC(SSE_LoadLow,                                      "LoadLow",                                          SSE,        -1,           16,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_movlps,    INS_invalid},           HW_Category_MemoryLoad,                        HW_Flag_NoFlag)
@@ -91,8 +91,8 @@ HARDWARE_INTRINSIC(SSE_MoveMask,                                     "MoveMask",
 HARDWARE_INTRINSIC(SSE_MoveScalar,                                   "MoveScalar",                                       SSE,        -1,           16,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_movss,     INS_invalid},           HW_Category_SIMDScalar,                        HW_Flag_NoContainment)
 HARDWARE_INTRINSIC(SSE_Multiply,                                     "Multiply",                                         SSE,        -1,           16,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_mulps,     INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_Commutative)
 HARDWARE_INTRINSIC(SSE_MultiplyScalar,                               "MultiplyScalar",                                   SSE,        -1,           16,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_mulss,     INS_invalid},           HW_Category_SIMDScalar,                        HW_Flag_Commutative)
-HARDWARE_INTRINSIC(SSE_Or,                                           "Or",                                               SSE,        -1,           16,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_orps,      INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
-HARDWARE_INTRINSIC(SSE_Reciprocal,                                   "Reciprocal",                                       SSE,        -1,           16,           1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_rcpps,     INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)                 
+HARDWARE_INTRINSIC(SSE_Or,                                           "Or",                                               SSE,        -1,           16,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_orps,      INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_Commutative)
+HARDWARE_INTRINSIC(SSE_Reciprocal,                                   "Reciprocal",                                       SSE,        -1,           16,           1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_rcpps,     INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
 HARDWARE_INTRINSIC(SSE_ReciprocalScalar,                             "ReciprocalScalar",                                 SSE,        -1,           16,           1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_rcpss,     INS_invalid},           HW_Category_SIMDScalar,                        HW_Flag_CopyUpperBits)
 HARDWARE_INTRINSIC(SSE_ReciprocalSqrt,                               "ReciprocalSqrt",                                   SSE,        -1,           16,           1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_rsqrtps,   INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
 HARDWARE_INTRINSIC(SSE_ReciprocalSqrtScalar,                         "ReciprocalSqrtScalar",                             SSE,        -1,           16,           1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_rsqrtss,   INS_invalid},           HW_Category_SIMDScalar,                        HW_Flag_CopyUpperBits)
@@ -116,60 +116,105 @@ HARDWARE_INTRINSIC(SSE_UnpackHigh,                                   "UnpackHigh
 HARDWARE_INTRINSIC(SSE_UnpackLow,                                    "UnpackLow",                                        SSE,        -1,           16,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_unpcklps,  INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
 HARDWARE_INTRINSIC(SSE_Xor,                                          "Xor",                                              SSE,        -1,           16,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_xorps,     INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_Commutative)
 
-//  SSE2 Intrinsics 
-HARDWARE_INTRINSIC(SSE2_IsSupported,                                 "get_IsSupported",                                  SSE2,       -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)                 
-HARDWARE_INTRINSIC(SSE2_Add,                                         "Add",                                              SSE2,       -1,           16,           2,           {INS_paddb,     INS_paddb,     INS_paddw,     INS_paddw,     INS_paddd,     INS_paddd,     INS_paddq,     INS_paddq,     INS_invalid,   INS_addpd},             HW_Category_SimpleSIMD,                        HW_Flag_Commutative)                 
-
-//  SSE3 Intrinsics 
-HARDWARE_INTRINSIC(SSE3_IsSupported,                                 "get_IsSupported",                                  SSE3,       -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)                 
-
-//  SSSE3 Intrinsics 
-HARDWARE_INTRINSIC(SSSE3_IsSupported,                                "get_IsSupported",                                  SSSE3,      -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)                 
-
-//  SSE41 Intrinsics 
-HARDWARE_INTRINSIC(SSE41_IsSupported,                                "get_IsSupported",                                  SSE41,      -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)                 
-HARDWARE_INTRINSIC(SSE41_Multiply,                                   "Multiply",                                         SSE41,      -1,           16,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_pmuldq,    INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_Commutative)                 
-HARDWARE_INTRINSIC(SSE41_BlendVariable,                              "BlendVariable",                                    SSE41,      -1,           16,           3,           {INS_pblendvb,  INS_pblendvb,  INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_blendvps,  INS_blendvpd},          HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)                 
-
-//  SSE42 Intrinsics 
-HARDWARE_INTRINSIC(SSE42_IsSupported,                                "get_IsSupported",                                  SSE42,      -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)                 
-HARDWARE_INTRINSIC(SSE42_Crc32,                                      "Crc32",                                            SSE42,      -1,           0,            2,           {INS_invalid,   INS_crc32,     INS_invalid,   INS_crc32,     INS_invalid,   INS_crc32,     INS_invalid,   INS_crc32,     INS_invalid,   INS_invalid},           HW_Category_Scalar,                            HW_Flag_NoFlag)                 
-
-//  AVX Intrinsics 
-HARDWARE_INTRINSIC(AVX_IsSupported,                                  "get_IsSupported",                                  AVX,        -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)                 
-HARDWARE_INTRINSIC(AVX_Add,                                          "Add",                                              AVX,        -1,           32,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_addps,     INS_addpd},             HW_Category_SimpleSIMD,                        HW_Flag_Commutative)                 
-HARDWARE_INTRINSIC(AVX_Multiply,                                     "Multiply",                                         AVX,        -1,           32,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_mulps,     INS_mulpd},             HW_Category_SimpleSIMD,                        HW_Flag_Commutative)                 
-HARDWARE_INTRINSIC(AVX_Reciprocal,                                   "Reciprocal",                                       AVX,        -1,           32,           1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_rcpps,     INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)                 
-HARDWARE_INTRINSIC(AVX_BlendVariable,                                "BlendVariable",                                    AVX,        -1,           32,           3,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_vblendvps, INS_vblendvpd},         HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)                 
-
-//  AVX2 Intrinsics 
-HARDWARE_INTRINSIC(AVX2_IsSupported,                                 "get_IsSupported",                                  AVX2,       -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)                 
-HARDWARE_INTRINSIC(AVX2_Add,                                         "Add",                                              AVX2,       -1,           32,           2,           {INS_paddb,     INS_paddb,     INS_paddw,     INS_paddw,     INS_paddd,     INS_paddd,     INS_paddq,     INS_paddq,     INS_invalid,   INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_Commutative)                 
-HARDWARE_INTRINSIC(AVX2_Multiply,                                    "Multiply",                                         AVX2,       -1,           32,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_pmuldq,    INS_pmuludq,   INS_invalid,   INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_Commutative)                 
-HARDWARE_INTRINSIC(AVX2_BlendVariable,                               "BlendVariable",                                    AVX2,       -1,           32,           3,           {INS_vpblendvb, INS_vpblendvb, INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)                 
-
-//  AES Intrinsics 
-HARDWARE_INTRINSIC(AES_IsSupported,                                  "get_IsSupported",                                  AES,        -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)                 
-
-//  BMI1 Intrinsics 
-HARDWARE_INTRINSIC(BMI1_IsSupported,                                 "get_IsSupported",                                  BMI1,       -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)                 
-
-//  BMI2 Intrinsics 
-HARDWARE_INTRINSIC(BMI2_IsSupported,                                 "get_IsSupported",                                  BMI2,       -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)                 
-
-//  FMA Intrinsics 
-HARDWARE_INTRINSIC(FMA_IsSupported,                                  "get_IsSupported",                                  FMA,        -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)                 
-
-//  LZCNT Intrinsics 
-HARDWARE_INTRINSIC(LZCNT_IsSupported,                                "get_IsSupported",                                  LZCNT,      -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)                 
-HARDWARE_INTRINSIC(LZCNT_LeadingZeroCount,                           "LeadingZeroCount",                                 LZCNT,      -1,           0,            1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_lzcnt,     INS_invalid,   INS_lzcnt,     INS_invalid,   INS_invalid},           HW_Category_Scalar,                            HW_Flag_NoFlag)                 
+// ************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
+//                  Intrinsic ID                                      Function name                                      ISA        ival       SIMD size       NumArg                                                                   instructions                                                                                              Category                                         Flags
+//                                                                                                                                                                            {TYP_BYTE,      TYP_UBYTE,     TYP_SHORT,     TYP_USHORT,    TYP_INT,       TYP_UINT,      TYP_LONG,      TYP_ULONG,     TYP_FLOAT,     TYP_DOUBLE}
+// ************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
+//  SSE2 Intrinsics
+HARDWARE_INTRINSIC(SSE2_IsSupported,                                 "get_IsSupported",                                  SSE2,       -1,           0,           0,            {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(SSE2_Add,                                         "Add",                                              SSE2,       -1,           16,          2,            {INS_paddb,     INS_paddb,     INS_paddw,     INS_paddw,     INS_paddd,     INS_paddd,     INS_paddq,     INS_paddq,     INS_invalid,   INS_addpd},             HW_Category_SimpleSIMD,                        HW_Flag_Commutative)
+HARDWARE_INTRINSIC(SSE2_AddSaturate,                                 "AddSaturate",                                      SSE2,       -1,           16,          2,            {INS_paddsb,    INS_paddusb,   INS_paddsw,    INS_paddusw,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_Commutative)
+HARDWARE_INTRINSIC(SSE2_And,                                         "And",                                              SSE2,       -1,           16,          2,            {INS_pand,      INS_pand,      INS_pand,      INS_pand,      INS_pand,      INS_pand,      INS_pand,      INS_pand,      INS_invalid,   INS_andpd},             HW_Category_SimpleSIMD,                        HW_Flag_Commutative)
+HARDWARE_INTRINSIC(SSE2_AndNot,                                      "AndNot",                                           SSE2,       -1,           16,          2,            {INS_pandn,     INS_pandn,     INS_pandn,     INS_pandn,     INS_pandn,     INS_pandn,     INS_pandn,     INS_pandn,     INS_invalid,   INS_andnpd},            HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(SSE2_Average,                                     "Average",                                          SSE2,       -1,           16,          2,            {INS_invalid,   INS_pavgb,     INS_invalid,   INS_pavgw,     INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_Commutative)
+HARDWARE_INTRINSIC(SSE2_CompareEqual,                                "CompareEqual",                                     SSE2,        0,           16,          2,            {INS_pcmpeqb,   INS_pcmpeqb,   INS_pcmpeqw,   INS_pcmpeqw,   INS_pcmpeqd,   INS_pcmpeqd,   INS_invalid,   INS_invalid,   INS_invalid,   INS_cmppd},             HW_Category_SimpleSIMD,                        HW_Flag_Commutative)
+HARDWARE_INTRINSIC(SSE2_CompareGreaterThan,                          "CompareGreaterThan",                               SSE2,        6,           16,          2,            {INS_pcmpgtb,   INS_invalid,   INS_pcmpgtw,   INS_invalid,   INS_pcmpgtd,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_cmppd},             HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(SSE2_CompareGreaterThanOrEqual,                   "CompareGreaterThanOrEqual",                        SSE2,        5,           16,          2,            {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_cmppd},             HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(SSE2_CompareLessThan,                             "CompareLessThan",                                  SSE2,        1,           16,          2,            {INS_pcmpgtb,   INS_invalid,   INS_pcmpgtw,   INS_invalid,   INS_pcmpgtd,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_cmppd},             HW_Category_Special,                           HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(SSE2_CompareLessThanOrEqual,                      "CompareLessThanOrEqual",                           SSE2,        2,           16,          2,            {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_cmppd},             HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(SSE2_CompareNotEqual,                             "CompareNotEqual",                                  SSE2,        4,           16,          2,            {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_cmppd},             HW_Category_SimpleSIMD,                        HW_Flag_Commutative)
+HARDWARE_INTRINSIC(SSE2_CompareNotGreaterThan,                       "CompareNotGreaterThan",                            SSE2,        2,           16,          2,            {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_cmppd},             HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(SSE2_CompareNotGreaterThanOrEqual,                "CompareNotGreaterThanOrEqual",                     SSE2,        1,           16,          2,            {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_cmppd},             HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(SSE2_CompareNotLessThan,                          "CompareNotLessThan",                               SSE2,        5,           16,          2,            {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_cmppd},             HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(SSE2_CompareNotLessThanOrEqual,                   "CompareNotLessThanOrEqual",                        SSE2,        6,           16,          2,            {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_cmppd},             HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(SSE2_CompareOrdered,                              "CompareOrdered",                                   SSE2,        7,           16,          2,            {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_cmppd},             HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(SSE2_CompareUnordered,                            "CompareUnordered",                                 SSE2,        3,           16,          2,            {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_cmppd},             HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(SSE2_ConvertToVector128Double,                    "ConvertToVector128Double",                         SSE2,       -1,           16,          1,            {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_cvtdq2pd,  INS_invalid,   INS_invalid,   INS_invalid,   INS_cvtps2pd,  INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_BaseTypeFromArg)
+HARDWARE_INTRINSIC(SSE2_ConvertToVector128Int32,                     "ConvertToVector128Int32",                          SSE2,       -1,           16,          1,            {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_cvtps2dq,  INS_cvtpd2dq},          HW_Category_SimpleSIMD,                        HW_Flag_BaseTypeFromArg)
+HARDWARE_INTRINSIC(SSE2_ConvertToVector128Int32WithTruncation,       "ConvertToVector128Int32WithTruncation",            SSE2,       -1,           16,          1,            {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_cvttps2dq, INS_cvttpd2dq},         HW_Category_SimpleSIMD,                        HW_Flag_BaseTypeFromArg)
+HARDWARE_INTRINSIC(SSE2_ConvertToVector128Single,                    "ConvertToVector128Single",                         SSE2,       -1,           16,          1,            {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_cvtdq2ps,  INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_cvtpd2ps},          HW_Category_SimpleSIMD,                        HW_Flag_BaseTypeFromArg)
+HARDWARE_INTRINSIC(SSE2_Divide,                                      "Divide",                                           SSE2,       -1,           16,          2,            {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_divpd},             HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(SSE2_Max,                                         "Max",                                              SSE2,       -1,           16,          2,            {INS_invalid,   INS_pmaxub,    INS_pmaxsw,    INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_maxpd},             HW_Category_SimpleSIMD,                        HW_Flag_Commutative)
+HARDWARE_INTRINSIC(SSE2_Min,                                         "Min",                                              SSE2,       -1,           16,          2,            {INS_invalid,   INS_pminub,    INS_pminsw,    INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_minpd},             HW_Category_SimpleSIMD,                        HW_Flag_Commutative)
+HARDWARE_INTRINSIC(SSE2_MoveMask,                                    "MoveMask",                                         SSE2,       -1,           16,          1,            {INS_pmovmskb,  INS_pmovmskb,  INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_movmskpd},          HW_Category_Special,                           HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(SSE2_Multiply,                                    "Multiply",                                         SSE2,       -1,           16,          2,            {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_pmuludq,   INS_invalid,   INS_invalid,   INS_invalid,   INS_mulpd},             HW_Category_SimpleSIMD,                        HW_Flag_Commutative|HW_Flag_BaseTypeFromArg)
+HARDWARE_INTRINSIC(SSE2_MultiplyHigh,                                "MultiplyHigh",                                     SSE2,       -1,           16,          2,            {INS_invalid,   INS_invalid,   INS_pmulhw,    INS_pmulhuw,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_Commutative)
+HARDWARE_INTRINSIC(SSE2_MultiplyHorizontalAdd,                       "MultiplyHorizontalAdd",                            SSE2,       -1,           16,          2,            {INS_invalid,   INS_invalid,   INS_pmaddwd,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_Commutative|HW_Flag_BaseTypeFromArg)
+HARDWARE_INTRINSIC(SSE2_MultiplyLow,                                 "MultiplyLow",                                      SSE2,       -1,           16,          2,            {INS_invalid,   INS_invalid,   INS_pmullw,    INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_Commutative)
+HARDWARE_INTRINSIC(SSE2_Or,                                          "Or",                                               SSE2,       -1,           16,          2,            {INS_por,       INS_por,       INS_por,       INS_por,       INS_por,       INS_por,       INS_por,       INS_por,       INS_invalid,   INS_orpd},              HW_Category_SimpleSIMD,                        HW_Flag_Commutative)
+HARDWARE_INTRINSIC(SSE2_PackSignedSaturate,                          "PackSignedSaturate",                               SSE2,       -1,           16,          2,            {INS_invalid,   INS_invalid,   INS_packsswb,  INS_invalid,   INS_packssdw,  INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_BaseTypeFromArg)
+HARDWARE_INTRINSIC(SSE2_PackUnsignedSaturate,                        "PackUnsignedSaturate",                             SSE2,       -1,           16,          2,            {INS_invalid,   INS_invalid,   INS_packuswb,  INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_BaseTypeFromArg)
+HARDWARE_INTRINSIC(SSE2_SetZeroVector128,                            "SetZeroVector128",                                 SSE2,       -1,           16,          0,            {INS_pxor,      INS_pxor,      INS_pxor,      INS_pxor,      INS_pxor,      INS_pxor,      INS_pxor,      INS_pxor,      INS_invalid,   INS_xorpd},             HW_Category_Helper,                            HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(SSE2_SumAbsoluteDifferences,                      "SumAbsoluteDifferences",                           SSE2,       -1,           16,          2,            {INS_invalid,   INS_psadbw,    INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_BaseTypeFromArg)
+HARDWARE_INTRINSIC(SSE2_Sqrt,                                        "Sqrt",                                             SSE2,       -1,           16,          1,            {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_sqrtpd},            HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(SSE2_Subtract,                                    "Subtract",                                         SSE2,       -1,           16,          2,            {INS_psubb,     INS_psubb,     INS_psubw,     INS_psubw,     INS_psubd,     INS_psubd,     INS_psubq,     INS_psubq,     INS_invalid,   INS_subpd},             HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(SSE2_SubtractSaturate,                            "SubtractSaturate",                                 SSE2,       -1,           16,          2,            {INS_psubsb,    INS_psubusb,   INS_psubsw,    INS_psubusw,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(SSE2_UnpackHigh,                                  "UnpackHigh",                                       SSE2,       -1,           16,          2,            {INS_punpckhbw, INS_punpckhbw, INS_punpckhwd, INS_punpckhwd, INS_punpckhdq, INS_punpckhdq, INS_punpckhqdq,INS_punpckhqdq,INS_invalid,   INS_unpckhpd},          HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(SSE2_UnpackLow,                                   "UnpackLow",                                        SSE2,       -1,           16,          2,            {INS_punpcklbw, INS_punpcklbw, INS_punpcklwd, INS_punpcklwd, INS_punpckldq, INS_punpckldq, INS_punpcklqdq,INS_punpcklqdq,INS_invalid,   INS_unpcklpd},          HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(SSE2_Xor,                                         "Xor",                                              SSE2,       -1,           16,          2,            {INS_pxor,      INS_pxor,      INS_pxor,      INS_pxor,      INS_pxor,      INS_pxor,      INS_pxor,      INS_pxor,      INS_invalid,   INS_xorpd},             HW_Category_SimpleSIMD,                        HW_Flag_Commutative)
+
+//  SSE3 Intrinsics
+HARDWARE_INTRINSIC(SSE3_IsSupported,                                 "get_IsSupported",                                  SSE3,       -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)
+
+//  SSSE3 Intrinsics
+HARDWARE_INTRINSIC(SSSE3_IsSupported,                                "get_IsSupported",                                  SSSE3,      -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)
+
+//  SSE41 Intrinsics
+HARDWARE_INTRINSIC(SSE41_IsSupported,                                "get_IsSupported",                                  SSE41,      -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(SSE41_Multiply,                                   "Multiply",                                         SSE41,      -1,           16,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_pmuldq,    INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_Commutative)
+HARDWARE_INTRINSIC(SSE41_BlendVariable,                              "BlendVariable",                                    SSE41,      -1,           16,           3,           {INS_pblendvb,  INS_pblendvb,  INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_blendvps,  INS_blendvpd},          HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
+
+//  SSE42 Intrinsics
+HARDWARE_INTRINSIC(SSE42_IsSupported,                                "get_IsSupported",                                  SSE42,      -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(SSE42_Crc32,                                      "Crc32",                                            SSE42,      -1,           0,            2,           {INS_invalid,   INS_crc32,     INS_invalid,   INS_crc32,     INS_invalid,   INS_crc32,     INS_invalid,   INS_crc32,     INS_invalid,   INS_invalid},           HW_Category_Scalar,                            HW_Flag_NoFlag)
+
+//  AVX Intrinsics
+//  TODO-XArch When implementing SetZeroVector256 add case to switch table in gentree.cpp
+//  GenTree::NumChildren() to handle properly loop hoisting
+HARDWARE_INTRINSIC(AVX_IsSupported,                                  "get_IsSupported",                                  AVX,        -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(AVX_Add,                                          "Add",                                              AVX,        -1,           32,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_addps,     INS_addpd},             HW_Category_SimpleSIMD,                        HW_Flag_Commutative)
+HARDWARE_INTRINSIC(AVX_Multiply,                                     "Multiply",                                         AVX,        -1,           32,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_mulps,     INS_mulpd},             HW_Category_SimpleSIMD,                        HW_Flag_Commutative)
+HARDWARE_INTRINSIC(AVX_Reciprocal,                                   "Reciprocal",                                       AVX,        -1,           32,           1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_rcpps,     INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(AVX_BlendVariable,                                "BlendVariable",                                    AVX,        -1,           32,           3,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_vblendvps, INS_vblendvpd},         HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
+
+//  AVX2 Intrinsics
+HARDWARE_INTRINSIC(AVX2_IsSupported,                                 "get_IsSupported",                                  AVX2,       -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(AVX2_Add,                                         "Add",                                              AVX2,       -1,           32,           2,           {INS_paddb,     INS_paddb,     INS_paddw,     INS_paddw,     INS_paddd,     INS_paddd,     INS_paddq,     INS_paddq,     INS_invalid,   INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_Commutative)
+HARDWARE_INTRINSIC(AVX2_Multiply,                                    "Multiply",                                         AVX2,       -1,           32,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_pmuldq,    INS_pmuludq,   INS_invalid,   INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_Commutative)
+HARDWARE_INTRINSIC(AVX2_BlendVariable,                               "BlendVariable",                                    AVX2,       -1,           32,           3,           {INS_vpblendvb, INS_vpblendvb, INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
+
+//  AES Intrinsics
+HARDWARE_INTRINSIC(AES_IsSupported,                                  "get_IsSupported",                                  AES,        -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)
+
+//  BMI1 Intrinsics
+HARDWARE_INTRINSIC(BMI1_IsSupported,                                 "get_IsSupported",                                  BMI1,       -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)
+
+//  BMI2 Intrinsics
+HARDWARE_INTRINSIC(BMI2_IsSupported,                                 "get_IsSupported",                                  BMI2,       -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)
+
+//  FMA Intrinsics
+HARDWARE_INTRINSIC(FMA_IsSupported,                                  "get_IsSupported",                                  FMA,        -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)
+
+//  LZCNT Intrinsics
+HARDWARE_INTRINSIC(LZCNT_IsSupported,                                "get_IsSupported",                                  LZCNT,      -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(LZCNT_LeadingZeroCount,                           "LeadingZeroCount",                                 LZCNT,      -1,           0,            1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_lzcnt,     INS_invalid,   INS_lzcnt,     INS_invalid,   INS_invalid},           HW_Category_Scalar,                            HW_Flag_NoFlag)
 
 //  PCLMULQDQ Intrinsics
-HARDWARE_INTRINSIC(PCLMULQDQ_IsSupported,                            "get_IsSupported",                                  PCLMULQDQ,  -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)                 
+HARDWARE_INTRINSIC(PCLMULQDQ_IsSupported,                            "get_IsSupported",                                  PCLMULQDQ,  -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)
 
 //  POPCNT Intrinsics
-HARDWARE_INTRINSIC(POPCNT_IsSupported,                               "get_IsSupported",                                  POPCNT,     -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)                 
-HARDWARE_INTRINSIC(POPCNT_PopCount,                                  "PopCount",                                         POPCNT,     -1,           0,            1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_popcnt,    INS_invalid,   INS_popcnt,    INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_Scalar,                            HW_Flag_NoFlag)                 
+HARDWARE_INTRINSIC(POPCNT_IsSupported,                               "get_IsSupported",                                  POPCNT,     -1,           0,            0,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_IsSupportedProperty,               HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(POPCNT_PopCount,                                  "PopCount",                                         POPCNT,     -1,           0,            1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_popcnt,    INS_invalid,   INS_popcnt,    INS_invalid,   INS_invalid,   INS_invalid},           HW_Category_Scalar,                            HW_Flag_NoFlag)
 #endif // FEATURE_HW_INTRINSIC
 
 #undef HARDWARE_INTRINSIC
index 09e3c72..434f5e9 100644 (file)
@@ -529,7 +529,7 @@ GenTree* Compiler::impX86HWIntrinsic(NamedIntrinsic        intrinsic,
     // table-driven importer of simple intrinsics
     if (impIsTableDrivenHWIntrinsic(category, flags))
     {
-        if (!varTypeIsSIMD(retType))
+        if (!varTypeIsSIMD(retType) || (flags & HW_Flag_BaseTypeFromArg))
         {
             if (retType != TYP_VOID)
             {
@@ -791,9 +791,38 @@ GenTree* Compiler::impSSE2Intrinsic(NamedIntrinsic        intrinsic,
     GenTree*  retNode  = nullptr;
     GenTree*  op1      = nullptr;
     GenTree*  op2      = nullptr;
+    int       ival     = -1;
+    int       simdSize = simdSizeOfHWIntrinsic(intrinsic, sig);
     var_types baseType = TYP_UNKNOWN;
+    var_types retType  = TYP_UNKNOWN;
+
     switch (intrinsic)
     {
+        case NI_SSE2_CompareLessThan:
+            assert(sig->numArgs == 2);
+            op2      = impSIMDPopStack(TYP_SIMD16);
+            op1      = impSIMDPopStack(TYP_SIMD16);
+            baseType = getBaseTypeOfSIMDType(sig->retTypeSigClass);
+            if (baseType == TYP_DOUBLE)
+            {
+                retNode = gtNewSimdHWIntrinsicNode(TYP_SIMD16, op1, op2, intrinsic, baseType, simdSize);
+            }
+            else
+            {
+                retNode =
+                    gtNewSimdHWIntrinsicNode(TYP_SIMD16, op2, op1, NI_SSE2_CompareGreaterThan, baseType, simdSize);
+            }
+            break;
+
+        case NI_SSE2_MoveMask:
+            assert(sig->numArgs == 1);
+            retType = JITtype2varType(sig->retType);
+            assert(retType == TYP_INT);
+            op1      = impSIMDPopStack(TYP_SIMD16);
+            baseType = getBaseTypeOfSIMDType(info.compCompHnd->getArgClass(sig, sig->args));
+            retNode  = gtNewSimdHWIntrinsicNode(retType, op1, intrinsic, baseType, simdSize);
+            break;
+
         default:
             JITDUMP("Not implemented hardware intrinsic");
             break;
index c2ad1f9..ca61a66 100644 (file)
@@ -180,9 +180,10 @@ INSTMUL(imul_15, "imul", 0, IUM_RD, 0, 1, BAD_CODE, 0x4400003868, BAD_CODE)
 INST3(FIRST_SSE2_INSTRUCTION, "FIRST_SSE2_INSTRUCTION",  0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, BAD_CODE)
 
 // These are the SSE instructions used on x86
-INST3( mov_i2xmm,   "movd"        , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE, PCKDBL(0x6E)) // Move int reg to a xmm reg. reg1=xmm reg, reg2=int reg 
-INST3( mov_xmm2i,   "movd"        , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE, PCKDBL(0x7E)) // Move xmm reg to an int reg. reg1=xmm reg, reg2=int reg 
+INST3( mov_i2xmm,   "movd"        , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE, PCKDBL(0x6E)) // Move int reg to a xmm reg. reg1=xmm reg, reg2=int reg
+INST3( mov_xmm2i,   "movd"        , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE, PCKDBL(0x7E)) // Move xmm reg to an int reg. reg1=xmm reg, reg2=int reg
 INST3( pmovmskb,    "pmovmskb"    , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE, PCKDBL(0xD7)) // Move the MSB bits of all bytes in a xmm reg to an int reg
+INST3( movmskpd,    "movmskpd"    , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE, PCKDBL(0x50)) // Extract 2-bit sign mask from xmm and store in reg. The upper bits of r32 or r64 are filled with zeros.
 INST3( movq,        "movq"        , 0, IUM_WR, 0, 0, PCKDBL(0xD6), BAD_CODE, SSEFLT(0x7E))
 INST3( movsdsse2,   "movsd"       , 0, IUM_WR, 0, 0, SSEDBL(0x11), BAD_CODE, SSEDBL(0x10))
 
@@ -293,7 +294,7 @@ INST3( ucomisd,   "ucomisd",    0, IUM_RD, 0, 0, BAD_CODE, BAD_CODE, PCKDBL(0x2E
 // Note that these instructions not only compare but also overwrite the first source.
 INST3( cmpps,     "cmpps",      0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, PCKFLT(0xC2))    // compare packed singles
 INST3( cmppd,     "cmppd",      0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, PCKDBL(0xC2))    // compare packed doubles
-INST3( cmpss,     "cmpss",      0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSEFLT(0xC2))    // compare scalar singles 
+INST3( cmpss,     "cmpss",      0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSEFLT(0xC2))    // compare scalar singles
 INST3( cmpsd,     "cmpsd",      0, IUM_WR, 0, 0, BAD_CODE, BAD_CODE, SSEDBL(0xC2))    // compare scalar doubles
 
 //SSE2 packed integer operations
@@ -301,16 +302,30 @@ INST3( paddb,       "paddb"       , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,
 INST3( paddw,       "paddw"       , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xFD))   // Add packed word (16-bit) integers
 INST3( paddd,       "paddd"       , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xFE))   // Add packed double-word (32-bit) integers
 INST3( paddq,       "paddq"       , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xD4))   // Add packed quad-word (64-bit) integers
+INST3( paddsb,      "paddsb"      , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xEC))   // Add packed signed byte integers and saturate the results
+INST3( paddsw,      "paddsw"      , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xED))   // Add packed signed word integers and saturate the results
+INST3( paddusb,     "paddusb"     , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xDC))   // Add packed unsigned byte integers and saturate the results
+INST3( paddusw,     "paddusw"     , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xDD))   // Add packed unsigned word integers and saturate the results
+INST3( pavgb,       "pavgb"       , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xE0))   // Average of packed byte integers
+INST3( pavgw,       "pavgw"       , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xE3))   // Average of packed word integers
 INST3( psubb,       "psubb"       , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xF8))   // Subtract packed word (16-bit) integers
 INST3( psubw,       "psubw"       , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xF9))   // Subtract packed word (16-bit) integers
 INST3( psubd,       "psubd"       , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xFA))   // Subtract packed double-word (32-bit) integers
 INST3( psubq,       "psubq"       , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xFB))   // subtract packed quad-word (64-bit) integers
+INST3( pmaddwd,     "pmaddwd"     , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xF5))   // Multiply packed signed 16-bit integers in a and b, producing intermediate signed 32-bit integers. Horizontally add adjacent pairs of intermediate 32-bit integers, and pack the results in dst
+INST3( pmulhw,      "pmulhw"      , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xE5))   // Multiply high the packed 16-bit signed integers
+INST3( pmulhuw,     "pmulhuw"     , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xE4))   // Multiply high the packed 16-bit unsigned integers
 INST3( pmuludq,     "pmuludq"     , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xF4))   // packed multiply 32-bit unsigned integers and store 64-bit result
 INST3( pmullw,      "pmullw"      , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xD5))   // Packed multiply 16 bit unsigned integers and store lower 16 bits of each result
 INST3( pand,        "pand"        , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xDB))   // Packed bit-wise AND of two xmm regs
 INST3( pandn,       "pandn"       , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xDF))   // Packed bit-wise AND NOT of two xmm regs
 INST3( por,         "por"         , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xEB))   // Packed bit-wise OR of two xmm regs
 INST3( pxor,        "pxor"        , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xEF))   // Packed bit-wise XOR of two xmm regs
+INST3( psadbw,      "psadbw"      , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xF6))   // Compute the sum of absolute differences of packed unsigned 8-bit integers
+INST3( psubsb,      "psubsb"      , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xE8))   // Subtract packed 8-bit integers in b from packed 8-bit integers in a using saturation
+INST3( psubusb,     "psubusb"     , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xD8))   // Subtract packed unsigned 8-bit integers in b from packed unsigned 8-bit integers in a using saturation
+INST3( psubsw,      "psubsw"      , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xE9))   // Subtract packed 16-bit integers in b from packed 16-bit integers in a using saturation
+INST3( psubusw,     "psubusw"     , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xD9))   // Subtract packed unsigned 16-bit integers in b from packed unsigned 16-bit integers in a using saturation
 
 // Note that the shift immediates share the same encoding between left and right-shift, and are distinguished by the Reg/Opcode,
 // which is handled in emitxarch.cpp.
@@ -323,6 +338,7 @@ INST3( psrld,       "psrld"       , 0, IUM_WR, 0, 0, BAD_CODE,     PCKDBL(0x72),
 INST3( psllw,       "psllw"       , 0, IUM_WR, 0, 0, BAD_CODE,     PCKDBL(0x71),  BAD_CODE    )   // Packed shift left logical of 16-bit integers
 INST3( psrlw,       "psrlw"       , 0, IUM_WR, 0, 0, BAD_CODE,     PCKDBL(0x71),  BAD_CODE    )   // Packed shift right logical of 16-bit integers
 INST3( psrad,       "psrad"       , 0, IUM_WR, 0, 0, BAD_CODE,     PCKDBL(0x72),  BAD_CODE    )   // Packed shift right arithmetic of 32-bit integers
+INST3( psraw,       "psraw"       , 0, IUM_WR, 0, 0, BAD_CODE,     PCKDBL(0x71),  BAD_CODE    )   // Packed shift right arithmetic of 16-bit integers
 
 INST3( pmaxub,      "pmaxub"      , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xDE))   // packed maximum unsigned bytes
 INST3( pminub,      "pminub"      , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0xDA))   // packed minimum unsigned bytes
@@ -345,6 +361,8 @@ INST3( punpckhqdq,  "punpckhqdq"  , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,
 INST3( punpcklqdq,  "punpcklqdq"  , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0x6C))   // Packed logical (unsigned) widen uint to ulong (lo)
 INST3( punpckhwd,   "punpckhwd"   , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0x69))   // Packed logical (unsigned) widen ushort to uint (hi)
 INST3( punpcklwd,   "punpcklwd"   , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0x61))   // Packed logical (unsigned) widen ushort to uint (lo)
+INST3( unpckhpd,    "unpckhpd"    , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0x15))   // Packed logical (unsigned) widen ubyte to ushort (hi)
+INST3( unpcklpd,    "unpcklpd"    , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0x14))   // Packed logical (unsigned) widen ubyte to ushort (hi)
 
 INST3( packssdw,    "packssdw"    , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0x6B))   // Pack (narrow) int to short with saturation
 INST3( packsswb,    "packsswb"    , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE,      PCKDBL(0x63))   // Pack (narrow) short to byte with saturation
index 9fc055e..b328c27 100644 (file)
@@ -260,7 +260,7 @@ GenTree* Lowering::LowerNode(GenTree* node)
         case GT_SIMD:
             LowerSIMD(node->AsSIMD());
             break;
-#endif //
+#endif // FEATURE_SIMD
 
 #ifdef FEATURE_HW_INTRINSICS
         case GT_HWIntrinsic:
index 772f403..2c164e9 100644 (file)
@@ -41,7 +41,7 @@ enum HWIntrinsicFlag : unsigned int
     HW_Flag_Commutative = 0x1,
 
     // Full range IMM intrinsic
-    // - the immediate value is vaild on the full range of imm8 (0-255)
+    // - the immediate value is valid on the full range of imm8 (0-255)
     HW_Flag_FullRangeIMM = 0x2,
 
     // Generic
@@ -74,6 +74,9 @@ enum HWIntrinsicFlag : unsigned int
     // Copy Upper bits
     // some SIMD scalar intrinsics need the semantics of copying upper bits from the source operand
     HW_Flag_CopyUpperBits = 0x200,
+
+    // Select base type using argument type
+    HW_Flag_BaseTypeFromArg = 0x400,
 };
 
 inline HWIntrinsicFlag operator|(HWIntrinsicFlag c1, HWIntrinsicFlag c2)
index 7a84f91..31614a0 100644 (file)
@@ -11,7 +11,7 @@ using System.Runtime.Intrinsics;
 
 namespace IntelHardwareIntrinsicTest
 {
-    class Program
+    static class Program
     {
         const int Pass = 100;
         const int Fail = 0;
index bf74e0a..ed084d2 100644 (file)
@@ -1,18 +1,19 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
     <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+    <ProjectGuid>{CB11ECA5-6119-4E68-B036-7DFF909291F0}</ProjectGuid>
     <OutputType>Exe</OutputType>
     <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
     <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
   </PropertyGroup>
   <!-- Default configurations to help VS understand the configurations -->
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
   <ItemGroup>
     <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
@@ -21,7 +22,8 @@
   </ItemGroup>
   <PropertyGroup>
     <DebugType>None</DebugType>
-    <Optimize></Optimize>
+    <Optimize>
+    </Optimize>
   </PropertyGroup>
   <ItemGroup>
     <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
@@ -30,5 +32,6 @@
     <Compile Include="Max.cs" />
   </ItemGroup>
   <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
-  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
-</Project>
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
index c7251e4..5832968 100644 (file)
@@ -1,18 +1,19 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
     <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+    <ProjectGuid>{8109234B-3F93-4F71-8968-942201A100E6}</ProjectGuid>
     <OutputType>Exe</OutputType>
     <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
     <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
   </PropertyGroup>
   <!-- Default configurations to help VS understand the configurations -->
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
   <ItemGroup>
     <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
@@ -30,5 +31,6 @@
     <Compile Include="Max.cs" />
   </ItemGroup>
   <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
-  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
-</Project>
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate.cs
new file mode 100644 (file)
index 0000000..3473c82
--- /dev/null
@@ -0,0 +1,127 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.AddSaturate);
+
+            if (Sse2.IsSupported)
+            {
+                using (var shortTable = TestTableSse2<short>.Create(testsCount))
+                using (var ushortTable = TestTableSse2<ushort>.Create(testsCount))
+                using (var sbyteTable = TestTableSse2<sbyte>.Create(testsCount))
+                using (var byteTable = TestTableSse2<byte>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<short>, Vector128<short>, Vector128<short>) value = shortTable[i];
+                        var result = Sse2.AddSaturate(value.Item1, value.Item2);
+                        shortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<ushort>, Vector128<ushort>, Vector128<ushort>) value = ushortTable[i];
+                        var result = Sse2.AddSaturate(value.Item1, value.Item2);
+                        ushortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<sbyte>, Vector128<sbyte>, Vector128<sbyte>) value = sbyteTable[i];
+                        var result = Sse2.AddSaturate(value.Item1, value.Item2);
+                        sbyteTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<byte>, Vector128<byte>, Vector128<byte>) value = byteTable[i];
+                        var result = Sse2.AddSaturate(value.Item1, value.Item2);
+                        byteTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<short> checkInt16 = (short x, short y, short z, ref short a) =>
+                    {
+                        int value = x + y;
+                        value = Math.Max(value, short.MinValue);
+                        value = Math.Min(value, short.MaxValue);
+                        a = (short) value;
+                        return a == z;
+                    };
+
+                    if (!shortTable.CheckResult(checkInt16))
+                    {
+                        PrintError(shortTable, methodUnderTestName, "(short x, short y, short z, ref short a) => (a = (short)(x & y)) == z", checkInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<ushort> checkUInt16 = (ushort x, ushort y, ushort z, ref ushort a) =>
+                    {
+                        int value = x + y;
+                        value = Math.Max(value, 0);
+                        value = Math.Min(value, ushort.MaxValue);
+                        a = (ushort) value;
+                        return a == z;
+                    };
+
+                    if (!ushortTable.CheckResult(checkUInt16))
+                    {
+                        PrintError(ushortTable, methodUnderTestName, "(ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)(x & y)) == z", checkUInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<sbyte> checkSByte = (sbyte x, sbyte y, sbyte z, ref sbyte a) =>
+                    {
+                        int value = x + y;
+                        value = Math.Max(value, sbyte.MinValue);
+                        value = Math.Min(value, sbyte.MaxValue);
+                        a = (sbyte) value;
+                        return a == z;
+                    };
+
+                    if (!sbyteTable.CheckResult(checkSByte))
+                    {
+                        PrintError(sbyteTable, methodUnderTestName, "(sbyte x, sbyte y, sbyte z, ref sbyte a) => (a = (sbyte)(x & y)) == z", checkSByte);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<byte> checkByte = (byte x, byte y, byte z, ref byte a) =>
+                    {
+                        int value = x + y;
+                        value = Math.Max(value, 0);                        
+                        value = Math.Min(value, byte.MaxValue);
+                        a = (byte) value;
+                        return a == z;
+                    };
+
+                    if (!byteTable.CheckResult(checkByte))
+                    {
+                        PrintError(byteTable, methodUnderTestName, "(byte x, byte y, byte z, ref byte a) => (a = (byte)(x & y)) == z", checkByte);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate_r.csproj
new file mode 100644 (file)
index 0000000..8e24109
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{B09B2F36-803A-4435-BCFA-0E83F963840F}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="AddSaturate.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AddSaturate_ro.csproj
new file mode 100644 (file)
index 0000000..3c1dd7e
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{28A6B11C-68B9-45AF-A42C-C5886AAF6748}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="AddSaturate.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.cs
new file mode 100644 (file)
index 0000000..2a54745
--- /dev/null
@@ -0,0 +1,187 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.And);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double>.Create(testsCount))
+                using (var longTable = TestTableSse2<long>.Create(testsCount))
+                using (var ulongTable = TestTableSse2<ulong>.Create(testsCount))
+                using (var intTable = TestTableSse2<int>.Create(testsCount))
+                using (var uintTable = TestTableSse2<uint>.Create(testsCount))
+                using (var shortTable = TestTableSse2<short>.Create(testsCount))
+                using (var ushortTable = TestTableSse2<ushort>.Create(testsCount))
+                using (var sbyteTable = TestTableSse2<sbyte>.Create(testsCount))
+                using (var byteTable = TestTableSse2<byte>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        var result = Sse2.And(value.Item1, value.Item2);
+                        doubleTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<long>, Vector128<long>, Vector128<long>) value = longTable[i];
+                        var result = Sse2.And(value.Item1, value.Item2);
+                        longTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<ulong>, Vector128<ulong>, Vector128<ulong>) value = ulongTable[i];
+                        var result = Sse2.And(value.Item1, value.Item2);
+                        ulongTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<int>, Vector128<int>, Vector128<int>) value = intTable[i];
+                        var result = Sse2.And(value.Item1, value.Item2);
+                        intTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<uint>, Vector128<uint>, Vector128<uint>) value = uintTable[i];
+                        var result = Sse2.And(value.Item1, value.Item2);
+                        uintTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<short>, Vector128<short>, Vector128<short>) value = shortTable[i];
+                        var result = Sse2.And(value.Item1, value.Item2);
+                        shortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<ushort>, Vector128<ushort>, Vector128<ushort>) value = ushortTable[i];
+                        var result = Sse2.And(value.Item1, value.Item2);
+                        ushortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<sbyte>, Vector128<sbyte>, Vector128<sbyte>) value = sbyteTable[i];
+                        var result = Sse2.And(value.Item1, value.Item2);
+                        sbyteTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<byte>, Vector128<byte>, Vector128<byte>) value = byteTable[i];
+                        var result = Sse2.And(value.Item1, value.Item2);
+                        byteTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<double> checkDouble = (double x, double y, double z, ref double a) => (a = BinaryAnd(x, y)) == z;
+
+                    if (!doubleTable.CheckResult(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(double x, double y, double z, ref double a) => (a = BinaryAnd(x, y)) == z", checkDouble);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<long> checkLong = (long x, long y, long z, ref long a) => (a = x & y) == z;
+
+                    if (!longTable.CheckResult(checkLong))
+                    {
+                        PrintError(longTable, methodUnderTestName, "(long x, long y, long z, ref long a) => (a = x & y) == z", checkLong);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<ulong> checkUlong = (ulong x, ulong y, ulong z, ref ulong a) => (a = x & y) == z;
+
+                    if (!longTable.CheckResult(checkLong))
+                    {
+                        PrintError(ulongTable, methodUnderTestName, "(ulong x, ulong y, ulong z, ref ulong a) => (a = x & y) == z", checkUlong);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<int> checkInt32 = (int x, int y, int z, ref int a) => (a = x & y) == z;
+
+                    if (!intTable.CheckResult(checkInt32))
+                    {
+                        PrintError(intTable, methodUnderTestName, "(int x, int y, int z, ref int a) => (a = x & y) == z", checkInt32);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<uint> checkUInt32 = (uint x, uint y, uint z, ref uint a) => (a = x & y) == z;
+
+                    if (!uintTable.CheckResult(checkUInt32))
+                    {
+                        PrintError(uintTable, methodUnderTestName, "(uint x, uint y, uint z, ref uint a) => (a = x & y) == z", checkUInt32);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<short> checkInt16 = (short x, short y, short z, ref short a) => (a = (short)(x & y)) == z;
+
+                    if (!shortTable.CheckResult(checkInt16))
+                    {
+                        PrintError(shortTable, methodUnderTestName, "(short x, short y, short z, ref short a) => (a = (short)(x & y)) == z", checkInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<ushort> checkUInt16 = (ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)(x & y)) == z;
+
+                    if (!ushortTable.CheckResult(checkUInt16))
+                    {
+                        PrintError(ushortTable, methodUnderTestName, "(ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)(x & y)) == z", checkUInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<sbyte> checkSByte = (sbyte x, sbyte y, sbyte z, ref sbyte a) => (a = (sbyte)(x & y)) == z;
+
+                    if (!sbyteTable.CheckResult(checkSByte))
+                    {
+                        PrintError(sbyteTable, methodUnderTestName, "(sbyte x, sbyte y, sbyte z, ref sbyte a) => (a = (sbyte)(x & y)) == z", checkSByte);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<byte> checkByte = (byte x, byte y, byte z, ref byte a) => (a = (byte)(x & y)) == z;
+
+                    if (!byteTable.CheckResult(checkByte))
+                    {
+                        PrintError(byteTable, methodUnderTestName, "(byte x, byte y, byte z, ref byte a) => (a = (byte)(x & y)) == z", checkByte);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+
+        public static unsafe double BinaryAnd(double x, double y)
+        {
+            var xUlong = BitConverter.ToUInt64(BitConverter.GetBytes(x));
+            var yUlong = BitConverter.ToUInt64(BitConverter.GetBytes(y));
+            var longAnd = xUlong & yUlong;
+            return BitConverter.ToDouble(BitConverter.GetBytes(longAnd));
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.cs
new file mode 100644 (file)
index 0000000..a757419
--- /dev/null
@@ -0,0 +1,187 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.AndNot);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double>.Create(testsCount))
+                using (var longTable = TestTableSse2<long>.Create(testsCount))
+                using (var ulongTable = TestTableSse2<ulong>.Create(testsCount))
+                using (var intTable = TestTableSse2<int>.Create(testsCount))
+                using (var uintTable = TestTableSse2<uint>.Create(testsCount))
+                using (var shortTable = TestTableSse2<short>.Create(testsCount))
+                using (var ushortTable = TestTableSse2<ushort>.Create(testsCount))
+                using (var sbyteTable = TestTableSse2<sbyte>.Create(testsCount))
+                using (var byteTable = TestTableSse2<byte>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        var result = Sse2.AndNot(value.Item1, value.Item2);
+                        doubleTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<long>, Vector128<long>, Vector128<long>) value = longTable[i];
+                        var result = Sse2.AndNot(value.Item1, value.Item2);
+                        longTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<ulong>, Vector128<ulong>, Vector128<ulong>) value = ulongTable[i];
+                        var result = Sse2.AndNot(value.Item1, value.Item2);
+                        ulongTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<int>, Vector128<int>, Vector128<int>) value = intTable[i];
+                        var result = Sse2.AndNot(value.Item1, value.Item2);
+                        intTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<uint>, Vector128<uint>, Vector128<uint>) value = uintTable[i];
+                        var result = Sse2.AndNot(value.Item1, value.Item2);
+                        uintTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<short>, Vector128<short>, Vector128<short>) value = shortTable[i];
+                        var result = Sse2.AndNot(value.Item1, value.Item2);
+                        shortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<ushort>, Vector128<ushort>, Vector128<ushort>) value = ushortTable[i];
+                        var result = Sse2.AndNot(value.Item1, value.Item2);
+                        ushortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<sbyte>, Vector128<sbyte>, Vector128<sbyte>) value = sbyteTable[i];
+                        var result = Sse2.AndNot(value.Item1, value.Item2);
+                        sbyteTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<byte>, Vector128<byte>, Vector128<byte>) value = byteTable[i];
+                        var result = Sse2.AndNot(value.Item1, value.Item2);
+                        byteTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<double> checkDouble = (double x, double y, double z, ref double a) => (a = BinaryAndNot(x, y)) == z;
+
+                    if (!doubleTable.CheckResult(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(double x, double y, double z, ref double a) => (a = BinaryAndNot(x, y)) == z", checkDouble);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<long> checkLong = (long x, long y, long z, ref long a) => (a = (~x) & y) == z;
+
+                    if (!longTable.CheckResult(checkLong))
+                    {
+                        PrintError(longTable, methodUnderTestName, "(long x, long y, long z, ref long a) => (a = (~x) & y) == z", checkLong);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<ulong> checkUlong = (ulong x, ulong y, ulong z, ref ulong a) => (a = (~x) & y) == z;
+
+                    if (!longTable.CheckResult(checkLong))
+                    {
+                        PrintError(ulongTable, methodUnderTestName, "(ulong x, ulong y, ulong z, ref ulong a) => (a = (~x) & y) == z", checkUlong);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<int> checkInt32 = (int x, int y, int z, ref int a) => (a = (~x) & y) == z;
+
+                    if (!intTable.CheckResult(checkInt32))
+                    {
+                        PrintError(intTable, methodUnderTestName, "(int x, int y, int z, ref int a) => (a = (~x) & y) == z", checkInt32);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<uint> checkUInt32 = (uint x, uint y, uint z, ref uint a) => (a = (~x) & y) == z;
+
+                    if (!uintTable.CheckResult(checkUInt32))
+                    {
+                        PrintError(uintTable, methodUnderTestName, "(uint x, uint y, uint z, ref uint a) => (a = (~x) & y) == z", checkUInt32);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<short> checkInt16 = (short x, short y, short z, ref short a) => (a = (short)((~x) & y)) == z;
+
+                    if (!shortTable.CheckResult(checkInt16))
+                    {
+                        PrintError(shortTable, methodUnderTestName, "(short x, short y, short z, ref short a) => (a = (short)((~x) & y)) == z", checkInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<ushort> checkUInt16 = (ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)((~x) & y)) == z;
+
+                    if (!ushortTable.CheckResult(checkUInt16))
+                    {
+                        PrintError(ushortTable, methodUnderTestName, "(ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)((~x) & y)) == z", checkUInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<sbyte> checkSByte = (sbyte x, sbyte y, sbyte z, ref sbyte a) => (a = (sbyte)((~x) & y)) == z;
+
+                    if (!sbyteTable.CheckResult(checkSByte))
+                    {
+                        PrintError(sbyteTable, methodUnderTestName, "(sbyte x, sbyte y, sbyte z, ref sbyte a) =>(a = (sbyte)((~x) & y)) == z", checkSByte);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<byte> checkByte = (byte x, byte y, byte z, ref byte a) => (a = (byte)((~x) & y)) == z;
+
+                    if (!byteTable.CheckResult(checkByte))
+                    {
+                        PrintError(byteTable, methodUnderTestName, "(byte x, byte y, byte z, ref byte a) =>  (a = (byte)((~x) & y)) == z", checkByte);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+
+        public static double BinaryAndNot(double x, double y)
+        {
+            var xLong = BitConverter.ToInt64(BitConverter.GetBytes(x));
+            var yLong = BitConverter.ToInt64(BitConverter.GetBytes(y));
+            xLong = ((~xLong) & yLong);
+            return BitConverter.ToDouble(BitConverter.GetBytes(xLong));
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot_r.csproj
new file mode 100644 (file)
index 0000000..0b2fce0
--- /dev/null
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{1FEAE9EB-3D81-4367-8B88-91348178128D}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <PropertyGroup>
+    <LangVersion>7.1</LangVersion>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="AndNot.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot_ro.csproj
new file mode 100644 (file)
index 0000000..72b237b
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{39F85E0C-902F-4426-B91D-5190B280A7F5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="AndNot.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And_r.csproj
new file mode 100644 (file)
index 0000000..c598393
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="And.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And_ro.csproj
new file mode 100644 (file)
index 0000000..49cb64b
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{76498BB3-401E-45B1-8A11-818B392E2003}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="And.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Average.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Average.cs
new file mode 100644 (file)
index 0000000..54f0b15
--- /dev/null
@@ -0,0 +1,69 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.Average);
+
+            if (Sse2.IsSupported)
+            {
+                using (var ushortTable = TestTableSse2<ushort>.Create(testsCount))
+                using (var byteTable = TestTableSse2<byte>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<ushort>, Vector128<ushort>, Vector128<ushort>) value = ushortTable[i];
+                        Vector128<ushort> result = Sse2.Average(value.Item1, value.Item2);
+                        ushortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<byte>, Vector128<byte>, Vector128<byte>) value = byteTable[i];
+                        Vector128<byte> result = Sse2.Average(value.Item1, value.Item2);
+                        byteTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<ushort> checkUshort = (ushort x, ushort y, ushort z, ref ushort a) =>
+                    (a = (ushort)((x + y + 1) >> 1)) == z;
+
+                    if (!ushortTable.CheckResult(checkUshort))
+                    {
+                        PrintError(ushortTable, methodUnderTestName, "(x, y, z, ref a) => (a = (x + y + 1) >> 1) == z", checkUshort);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<byte> checkByte = (byte x, byte y, byte z, ref byte a) =>
+                    (a = (byte)((x + y + 1) >> 1)) == z;
+
+                    if (!byteTable.CheckResult(checkByte))
+                    {
+                        PrintError(byteTable, methodUnderTestName, "(x, y, z, ref a) => (a = (x + y + 1) >> 1) == z", checkByte);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Average_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Average_r.csproj
new file mode 100644 (file)
index 0000000..cd2ed88
--- /dev/null
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{A1460AF7-173B-46EB-80BC-2CBAB97364AE}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <PropertyGroup>
+    <LangVersion>7.1</LangVersion>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Average.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Average_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Average_ro.csproj
new file mode 100644 (file)
index 0000000..875df8d
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{5D32628E-9C43-4DF7-B5C1-FD596CCCB996}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Average.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.cs
new file mode 100644 (file)
index 0000000..45ac941
--- /dev/null
@@ -0,0 +1,150 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics.X86;
+using System.Runtime.Intrinsics;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.CompareEqual);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double>.Create(testsCount))
+                using (var intTable = TestTableSse2<int>.Create(testsCount))
+                using (var uintTable = TestTableSse2<uint>.Create(testsCount))
+                using (var shortTable = TestTableSse2<short>.Create(testsCount))
+                using (var ushortTable = TestTableSse2<ushort>.Create(testsCount))
+                using (var sbyteTable = TestTableSse2<sbyte>.Create(testsCount))
+                using (var byteTable = TestTableSse2<byte>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        var result = Sse2.CompareEqual(value.Item1, value.Item2);
+                        doubleTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<int>, Vector128<int>, Vector128<int>) value = intTable[i];
+                        var result = Sse2.CompareEqual(value.Item1, value.Item2);
+                        intTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<uint>, Vector128<uint>, Vector128<uint>) value = uintTable[i];
+                        var result = Sse2.CompareEqual(value.Item1, value.Item2);
+                        uintTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<short>, Vector128<short>, Vector128<short>) value = shortTable[i];
+                        var result = Sse2.CompareEqual(value.Item1, value.Item2);
+                        shortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<ushort>, Vector128<ushort>, Vector128<ushort>) value = ushortTable[i];
+                        var result = Sse2.CompareEqual(value.Item1, value.Item2);
+                        ushortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<sbyte>, Vector128<sbyte>, Vector128<sbyte>) value = sbyteTable[i];
+                        var result = Sse2.CompareEqual(value.Item1, value.Item2);
+                        sbyteTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<byte>, Vector128<byte>, Vector128<byte>) value = byteTable[i];
+                        var result = Sse2.CompareEqual(value.Item1, value.Item2);
+                        byteTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<double> checkDouble = (double x, double y, double z, ref double a) =>
+                    {
+                        a = x == y ? BitConverter.Int64BitsToDouble(-1) : 0;
+                        return BitConverter.DoubleToInt64Bits(a) == BitConverter.DoubleToInt64Bits(z);
+                    }; 
+
+                    if (!doubleTable.CheckResult(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(double x, double y, double z, ref double a) => (a = x == y ? -1l : 0) == z", checkDouble);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<int> checkInt32 = (int x, int y, int z, ref int a) =>  (a = x == y ? -1 : 0) == z;
+
+                    if (!intTable.CheckResult(checkInt32))
+                    {
+                        PrintError(intTable, methodUnderTestName, "(int x, int y, int z, ref int a) =>  (a = x == y ? -1 : 0) == z);", checkInt32);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<uint> checkUInt32 = (uint x, uint y, uint z, ref uint a) => (a = x == y ? 0xffffffff : 0) == z;
+
+                    if (!uintTable.CheckResult(checkUInt32))
+                    {
+                        PrintError(uintTable, methodUnderTestName, "(uint x, uint y, uint z, ref uint a) => (a = x == y ? 0xffffffff : 0) == z", checkUInt32);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<short> checkInt16 = (short x, short y, short z, ref short a) => (a = (short)(x == y ? -1 : 0)) == z;
+
+                    if (!shortTable.CheckResult(checkInt16))
+                    {
+                        PrintError(shortTable, methodUnderTestName, "(short x, short y, short z, ref short a) => (a = (short)(x == y ? -1 : 0)) == z", checkInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<ushort> checkUInt16 = (ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)(x == y ? 0xffff : 0)) == z;
+
+                    if (!ushortTable.CheckResult(checkUInt16))
+                    {
+                        PrintError(ushortTable, methodUnderTestName, "(ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)(x == y ? 0xffff : 0)) == z", checkUInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<sbyte> checkSByte = (sbyte x, sbyte y, sbyte z, ref sbyte a) => (a = (sbyte) (x == y ? -1 : 0)) == z;
+
+                    if (!sbyteTable.CheckResult(checkSByte))
+                    {
+                        PrintError(sbyteTable, methodUnderTestName, "(sbyte x, sbyte y, sbyte z, ref sbyte a) => (a = (sbyte) (x == y ? -1 : 0) == z", checkSByte);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<byte> checkByte = (byte x, byte y, byte z, ref byte a) => (a = (byte)(x == y ? 0xff : 0)) == z;
+
+                    if (!byteTable.CheckResult(checkByte))
+                    {
+                        PrintError(byteTable, methodUnderTestName, "(byte x, byte y, byte z, ref byte a) => (a = (byte)(x == y ? 0xff : 0)) == z", checkByte);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual_r.csproj
new file mode 100644 (file)
index 0000000..8cde1ea
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{EB82DD03-0CB7-41E2-8879-63C128833B6E}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompareEqual.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual_ro.csproj
new file mode 100644 (file)
index 0000000..6b4082f
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{81E414C4-4281-4C1F-BC30-EACDCD551D1D}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompareEqual.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.cs
new file mode 100644 (file)
index 0000000..04290ac
--- /dev/null
@@ -0,0 +1,105 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        private const int Pass = 100;
+        private const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.CompareGreaterThan);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double>.Create(testsCount))
+                using (var intTable = TestTableSse2<int>.Create(testsCount))
+                using (var shortTable = TestTableSse2<short>.Create(testsCount))
+                using (var sbyteTable = TestTableSse2<sbyte>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        var result = Sse2.CompareGreaterThan(value.Item1, value.Item2);
+                        doubleTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<int>, Vector128<int>, Vector128<int>) value = intTable[i];
+                        var result = Sse2.CompareGreaterThan(value.Item1, value.Item2);
+                        intTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<short>, Vector128<short>, Vector128<short>) value = shortTable[i];
+                        var result = Sse2.CompareGreaterThan(value.Item1, value.Item2);
+                        shortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<sbyte>, Vector128<sbyte>, Vector128<sbyte>) value = sbyteTable[i];
+                        var result = Sse2.CompareGreaterThan(value.Item1, value.Item2);
+                        sbyteTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<double> checkDouble = (double x, double y, double z, ref double a) =>
+                    {
+                        a = x > y ? BitConverter.Int64BitsToDouble(-1) : 0;
+                        return BitConverter.DoubleToInt64Bits(a) == BitConverter.DoubleToInt64Bits(z);
+                    };
+
+                    if (!doubleTable.CheckResult(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(x, y, z, ref a) => (a = x > y ? double.NaN : 0) == z", checkDouble);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<int> checkInt32 = (int x, int y, int z, ref int a) => (a = x > y ? -1 : 0) == z;
+
+                    if (!intTable.CheckResult(checkInt32))
+                    {
+                        PrintError(intTable, methodUnderTestName, "(x, y, z, a) => (a = x > y ? -1 : 0) == z", checkInt32);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<short> checkInt16 = (short x, short y, short z, ref short a)
+                        => (a = (short)(x > y ? -1 : 0)) == z;
+
+                    if (!shortTable.CheckResult(checkInt16))
+                    {
+                        PrintError(shortTable, methodUnderTestName, "(x, y, z) => (x > y ? -1 : 0) == z", checkInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<sbyte> checkSByte = (sbyte x, sbyte y, sbyte z, ref sbyte a)
+                        => (a = (sbyte)(x > y ? -1 : 0)) == z;
+
+                    if (!sbyteTable.CheckResult(checkSByte))
+                    {
+                        PrintError(sbyteTable, methodUnderTestName, "(x, y, z) => (x > y ? -1 : 0) == z", checkSByte);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThanOrEqual.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThanOrEqual.cs
new file mode 100644 (file)
index 0000000..1555ff2
--- /dev/null
@@ -0,0 +1,55 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        private const int Pass = 100;
+        private const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.CompareGreaterThanOrEqual);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        var result = Sse2.CompareGreaterThanOrEqual(value.Item1, value.Item2);
+                        doubleTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<double> checkDouble = (double x, double y, double z, ref double a) =>
+                    {
+                        a = x >= y ? BitConverter.Int64BitsToDouble(-1) : 0;
+                        return BitConverter.DoubleToInt64Bits(a) == BitConverter.DoubleToInt64Bits(z);
+                    };
+
+                    if (!doubleTable.CheckResult(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(x, y, z, ref a) => (a = x > y ? double.NaN : 0) == z", checkDouble);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThanOrEqual_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThanOrEqual_r.csproj
new file mode 100644 (file)
index 0000000..725f168
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{87F2B90D-85D3-4304-99D3-355F109BE961}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompareGreaterThanOrEqual.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThanOrEqual_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThanOrEqual_ro.csproj
new file mode 100644 (file)
index 0000000..08c7386
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{A9EBC815-0839-4047-8602-7AB7AFB9C876}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompareGreaterThanOrEqual.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan_r.csproj
new file mode 100644 (file)
index 0000000..f93b438
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{C28A4AAF-7F4E-4FC2-B7E8-AB856A453C8F}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompareGreaterThan.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan_ro.csproj
new file mode 100644 (file)
index 0000000..b07cf68
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{083F679A-B810-4523-892B-B86CC2089A05}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompareGreaterThan.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.cs
new file mode 100644 (file)
index 0000000..ad70fab
--- /dev/null
@@ -0,0 +1,104 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics.X86;
+using System.Runtime.Intrinsics;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+
+        const int Pass = 100;
+        const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.CompareLessThan);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double>.Create(testsCount))
+                using (var intTable = TestTableSse2<int>.Create(testsCount))
+                using (var shortTable = TestTableSse2<short>.Create(testsCount))
+                using (var sbyteTable = TestTableSse2<sbyte>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        var result = Sse2.CompareLessThan(value.Item1, value.Item2);
+                        doubleTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<int>, Vector128<int>, Vector128<int>) value = intTable[i];
+                        var result = Sse2.CompareLessThan(value.Item1, value.Item2);
+                        intTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<short>, Vector128<short>, Vector128<short>) value = shortTable[i];
+                        var result = Sse2.CompareLessThan(value.Item1, value.Item2);
+                        shortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<sbyte>, Vector128<sbyte>, Vector128<sbyte>) value = sbyteTable[i];
+                        var result = Sse2.CompareLessThan(value.Item1, value.Item2);
+                        sbyteTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<double> checkDouble = (double x, double y, double z, ref double a) =>
+                    {
+                        a = x < y ? BitConverter.Int64BitsToDouble(-1) : 0;
+                        return BitConverter.DoubleToInt64Bits(a) == BitConverter.DoubleToInt64Bits(z);
+                    };
+
+                    if (!doubleTable.CheckResult(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(double x, double y, double z, ref double a) => (a = x < y ? BitConverter.Int64BitsToDouble(-1) : 0) == z", checkDouble);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<int> checkInt32 = (int x, int y, int z, ref int a) => (a = x < y ? -1 : 0) == z;
+
+                    if (!intTable.CheckResult(checkInt32))
+                    {
+                        PrintError(intTable, methodUnderTestName, "(int x, int y, int z, ref int a) => (a = x < y ? -1 : 0) == z;", checkInt32);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<short> checkInt16 = (short x, short y, short z, ref short a) => (a = (short)(x < y ? -1 : 0)) == z;
+
+                    if (!shortTable.CheckResult(checkInt16))
+                    {
+                        PrintError(shortTable, methodUnderTestName, "(short x, short y, short z, ref short a) => (a = (short)(x < y ? -1 : 0)) == z", checkInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<sbyte> checkSByte = (sbyte x, sbyte y, sbyte z, ref sbyte a) => (a = (sbyte)(x < y ? -1 : 0)) == z;
+
+                    if (!sbyteTable.CheckResult(checkSByte))
+                    {
+                        PrintError(sbyteTable, methodUnderTestName, "(sbyte x, sbyte y, sbyte z, ref sbyte a) => (a = (sbyte)(x < y ? -1 : 0)) == z", checkSByte);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThanOrEqual.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThanOrEqual.cs
new file mode 100644 (file)
index 0000000..d56a55e
--- /dev/null
@@ -0,0 +1,55 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        private const int Pass = 100;
+        private const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.CompareLessThanOrEqual);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        var result = Sse2.CompareLessThanOrEqual(value.Item1, value.Item2);
+                        doubleTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<double> checkDouble = (double x, double y, double z, ref double a) =>
+                    {
+                        a = x <= y ? BitConverter.Int64BitsToDouble(-1) : 0;
+                        return BitConverter.DoubleToInt64Bits(a) == BitConverter.DoubleToInt64Bits(z);
+                    };
+
+                    if (!doubleTable.CheckResult(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(x, y, z, ref a) => (a = x <= y ? double.NaN : 0) == z", checkDouble);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThanOrEqual_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThanOrEqual_r.csproj
new file mode 100644 (file)
index 0000000..a183a38
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{398DEA1A-16E3-4EE8-8668-54DFB80EB7AB}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompareLessThanOrEqual.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThanOrEqual_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThanOrEqual_ro.csproj
new file mode 100644 (file)
index 0000000..0414733
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{3AC17539-DEBA-4FFB-BE4A-4FCB21C37294}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompareLessThanOrEqual.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan_r.csproj
new file mode 100644 (file)
index 0000000..4577a52
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{93E4851E-5200-4A1E-AC26-FD8B18476570}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompareLessThan.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan_ro.csproj
new file mode 100644 (file)
index 0000000..4012f4e
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{EFB18286-69A8-4260-8AD9-94A576984ECB}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompareLessThan.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotEqual.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotEqual.cs
new file mode 100644 (file)
index 0000000..6a4615e
--- /dev/null
@@ -0,0 +1,55 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        private const int Pass = 100;
+        private const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.CompareNotEqual);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        var result = Sse2.CompareNotEqual(value.Item1, value.Item2);
+                        doubleTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<double> checkDouble = (double x, double y, double z, ref double a) =>
+                    {
+                        a = x != y ? BitConverter.Int64BitsToDouble(-1) : 0;
+                        return BitConverter.DoubleToInt64Bits(a) == BitConverter.DoubleToInt64Bits(z);
+                    };
+
+                    if (!doubleTable.CheckResult(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(x, y, z, ref a) => (a = x != y ? double.NaN : 0) == z", checkDouble);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotEqual_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotEqual_r.csproj
new file mode 100644 (file)
index 0000000..b98123c
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{9E2D750B-1AD6-4CCB-8CEE-856A702714DB}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompareNotEqual.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotEqual_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotEqual_ro.csproj
new file mode 100644 (file)
index 0000000..341273a
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{A51475EC-9B61-442A-B8E9-90817E8C5FF3}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompareNotEqual.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThan.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThan.cs
new file mode 100644 (file)
index 0000000..6fbeef8
--- /dev/null
@@ -0,0 +1,56 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        private const int Pass = 100;
+        private const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.CompareNotGreaterThan);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        var result = Sse2.CompareNotGreaterThan(value.Item1, value.Item2);
+                        doubleTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<double> checkDouble = (double x, double y, double z, ref double a) =>
+                    {
+                        // Exactly after Intel manual
+                        a = !(x > y) ? BitConverter.Int64BitsToDouble(-1) : 0;
+                        return BitConverter.DoubleToInt64Bits(a) == BitConverter.DoubleToInt64Bits(z);
+                    };
+
+                    if (!doubleTable.CheckResult(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(x, y, z, ref a) => (a = !(x > y) ? double.NaN : 0) == z", checkDouble);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThanOrEqual.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThanOrEqual.cs
new file mode 100644 (file)
index 0000000..42b8f27
--- /dev/null
@@ -0,0 +1,55 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        private const int Pass = 100;
+        private const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.CompareNotGreaterThanOrEqual);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        var result = Sse2.CompareNotGreaterThanOrEqual(value.Item1, value.Item2);
+                        doubleTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<double> checkDouble = (double x, double y, double z, ref double a) =>
+                    {
+                        a = !(x >= y) ? BitConverter.Int64BitsToDouble(-1) : 0;
+                        return BitConverter.DoubleToInt64Bits(a) == BitConverter.DoubleToInt64Bits(z);
+                    };
+
+                    if (!doubleTable.CheckResult(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(x, y, z, ref a) => (a = !(x >= y) ? double.NaN : 0) == z", checkDouble);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThanOrEqual_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThanOrEqual_r.csproj
new file mode 100644 (file)
index 0000000..841a9b5
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{9719321A-FA33-43E6-B01E-102879E77321}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompareNotGreaterThanOrEqual.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThanOrEqual_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThanOrEqual_ro.csproj
new file mode 100644 (file)
index 0000000..96d983e
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{93C1DB28-D5A7-493D-8017-9E028D39E025}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompareNotGreaterThanOrEqual.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThan_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThan_r.csproj
new file mode 100644 (file)
index 0000000..3db7ae5
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{CE864D5D-9D54-4000-A5BE-EC7052673CE5}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompareNotGreaterThan.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThan_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThan_ro.csproj
new file mode 100644 (file)
index 0000000..16b5b58
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{8B32892C-136B-4809-A082-F4EEF0FD0A8F}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompareNotGreaterThan.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThan.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThan.cs
new file mode 100644 (file)
index 0000000..cf48c68
--- /dev/null
@@ -0,0 +1,55 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        private const int Pass = 100;
+        private const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.CompareNotLessThan);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        var result = Sse2.CompareNotLessThan(value.Item1, value.Item2);
+                        doubleTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<double> checkDouble = (double x, double y, double z, ref double a) =>
+                    {
+                        a = !(x < y) ? BitConverter.Int64BitsToDouble(-1) : 0;
+                        return BitConverter.DoubleToInt64Bits(a) == BitConverter.DoubleToInt64Bits(z);
+                    };
+
+                    if (!doubleTable.CheckResult(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(x, y, z, ref a) => (a = !(x < y) ? double.NaN : 0) == z", checkDouble);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThanOrEqual.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThanOrEqual.cs
new file mode 100644 (file)
index 0000000..2862717
--- /dev/null
@@ -0,0 +1,55 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        private const int Pass = 100;
+        private const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.CompareNotLessThanOrEqual);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        var result = Sse2.CompareNotLessThanOrEqual(value.Item1, value.Item2);
+                        doubleTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<double> checkDouble = (double x, double y, double z, ref double a) =>
+                    {
+                        a = !(x <= y) ? BitConverter.Int64BitsToDouble(-1) : 0;
+                        return BitConverter.DoubleToInt64Bits(a) == BitConverter.DoubleToInt64Bits(z);
+                    };
+
+                    if (!doubleTable.CheckResult(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(x, y, z, ref a) => (a = !(x <= y) ? double.NaN : 0) == z", checkDouble);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThanOrEqual_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThanOrEqual_r.csproj
new file mode 100644 (file)
index 0000000..6f02e3c
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{608FCA63-FF4F-4A38-9503-9CF51D291BAB}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompareNotLessThanOrEqual.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThanOrEqual_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThanOrEqual_ro.csproj
new file mode 100644 (file)
index 0000000..2fb947b
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{D61F7DC7-97A3-4A5A-8A49-B80195B7EBFA}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompareNotLessThanOrEqual.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThan_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThan_r.csproj
new file mode 100644 (file)
index 0000000..1a3549a
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{BF772C6E-6EA2-4649-9618-D3DB0AE49F41}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompareNotLessThan.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThan_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThan_ro.csproj
new file mode 100644 (file)
index 0000000..61d7742
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{44063F5C-8943-4FC0-AEDF-45ED4A744CA9}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompareNotLessThan.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareOrdered.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareOrdered.cs
new file mode 100644 (file)
index 0000000..03f9ee6
--- /dev/null
@@ -0,0 +1,62 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        private const int Pass = 100;
+        private const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.CompareOrdered);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        var result = Sse2.CompareOrdered(value.Item1, value.Item2);
+                        doubleTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<double> checkDouble = (double x, double y, double z, ref double a) =>
+                    {
+                        if (!double.IsNaN(x) && !double.IsNaN(y))
+                        {
+                            a = BitConverter.Int64BitsToDouble(-1);
+                        }
+                        else
+                        {
+                            a = 0;
+                        }
+                        return BitConverter.DoubleToInt64Bits(a) == BitConverter.DoubleToInt64Bits(z);
+                    };
+
+                    if (!doubleTable.CheckResult(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(x, y, z, ref a) => (a = (!double.IsNaN(x) && !double.IsNaN(y)) ? double.NaN : 0) == z", checkDouble);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareOrdered_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareOrdered_r.csproj
new file mode 100644 (file)
index 0000000..1f76671
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{2099478C-8A85-4032-8F86-402DA54F8FA2}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompareOrdered.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareOrdered_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareOrdered_ro.csproj
new file mode 100644 (file)
index 0000000..9e9d5c5
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{AA7AFEBE-8C40-4A22-8A1E-5FC39EDD9A51}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompareOrdered.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareUnordered.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareUnordered.cs
new file mode 100644 (file)
index 0000000..036aac6
--- /dev/null
@@ -0,0 +1,62 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        private const int Pass = 100;
+        private const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.CompareUnordered);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        var result = Sse2.CompareUnordered(value.Item1, value.Item2);
+                        doubleTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<double> checkDouble = (double x, double y, double z, ref double a) =>
+                    {
+                        if (double.IsNaN(x) || double.IsNaN(y))
+                        {
+                            a = BitConverter.Int64BitsToDouble(-1);
+                        }
+                        else
+                        {
+                            a = 0;
+                        }
+                        return BitConverter.DoubleToInt64Bits(a) == BitConverter.DoubleToInt64Bits(z);
+                    };
+
+                    if (!doubleTable.CheckResult(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(x, y, z, ref a) => (a = (double.IsNaN(x) || double.IsNaN(y)) ? double.NaN : 0) == z", checkDouble);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareUnordered_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareUnordered_r.csproj
new file mode 100644 (file)
index 0000000..94f475d
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{15931119-A410-40C5-9FCC-D7A714C68512}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompareUnordered.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareUnordered_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareUnordered_ro.csproj
new file mode 100644 (file)
index 0000000..a994bc7
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{66739F14-FEA4-4993-B0E7-3E9B0D824FED}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="CompareUnordered.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Double.cs
new file mode 100644 (file)
index 0000000..bee8701
--- /dev/null
@@ -0,0 +1,72 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics.X86;
+using System.Runtime.Intrinsics;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.ConvertToVector128Double);
+
+            if (Sse2.IsSupported)
+            {
+                using (var floatTable = TestTableSse2<float, double>.Create(testsCount, 2.0))
+                using (var intTable = TestTableSse2<int, double>.Create(testsCount, 2.0))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<float>, Vector128<float>) value = floatTable[i];
+                        var result = Sse2.ConvertToVector128Double(value.Item1);
+                        floatTable.SetOutArrayU(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<int>, Vector128<int>) value = intTable[i];
+                        var result = Sse2.ConvertToVector128Double(value.Item1);
+                        intTable.SetOutArrayU(result);
+                    }
+
+                    CheckMethodFour<float, double> checkDouble = (float x1, float x2, double z1, double z2, ref double a1, ref double a2) =>
+                    {
+                        return (a1 = (double)x1) == z1 && (a2 = (double)x2) == z2;
+                    };
+
+                    if (!floatTable.CheckConvertToVector128Double(checkDouble))
+                    {
+                        PrintError(floatTable, methodUnderTestName, "(float x, float y, double z, ref double a) => (a = (double)x) == z", checkDouble);
+                        testResult = Fail;
+                    }
+
+                    CheckMethodFour<int, double> checkInt32 = (int x1, int x2, double z1, double z2, ref double a1, ref double a2) =>
+                    {
+                        return (a1 = (double)x1) == z1 && (a2 = (double)x2) == z2;
+                    };
+
+                    if (!intTable.CheckConvertToVector128Double(checkInt32))
+                    {
+                        PrintError(intTable, methodUnderTestName, "(int x, int y, double z, ref double a) =>  (a = (double)x) == z", checkInt32);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Double_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Double_r.csproj
new file mode 100644 (file)
index 0000000..e9a7488
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{D87DF85C-7593-4FB9-97B5-A93B25EC80DC}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="ConvertToVector128Double.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Double_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Double_ro.csproj
new file mode 100644 (file)
index 0000000..90c9015
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{A66024E0-4878-42B5-AF63-67BDF1DAC96B}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="ConvertToVector128Double.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Int32.cs
new file mode 100644 (file)
index 0000000..2e46ed2
--- /dev/null
@@ -0,0 +1,72 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics.X86;
+using System.Runtime.Intrinsics;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.ConvertToVector128Int32);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double, int>.Create(testsCount, 0.5))
+                using (var floatTable = TestTableSse2<float, int>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        Vector128<int> result = Sse2.ConvertToVector128Int32(value.Item1);
+                        doubleTable.SetOutArrayU(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<float>, Vector128<float>) value = floatTable[i];
+                        Vector128<int> result = Sse2.ConvertToVector128Int32(value.Item1);
+                        floatTable.SetOutArrayU(result);
+                    }
+
+                    CheckMethodFour<double, int> checkDouble = (double x1, double x2, int z1, int z2, ref int a1, ref int a2) =>
+                    {
+                        a1 = (int) Math.Round(x1, 0, MidpointRounding.ToEven);
+                        a2 = (int)Math.Round(x2, 0, MidpointRounding.ToEven);
+                        return a1 == z1 && a2 == z2;
+                    };
+
+                    if (!doubleTable.CheckConvertDoubleToVector128Int32(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(double x, double y, int z, ref int a) => (a = (int)x) == z", checkDouble);
+                        testResult = Fail;
+                    }
+
+                    CheckMethodTwo<float, int> checkFloat = (float x, float y, int z, ref int a) =>  (a = (int) MathF.Round(x, 0, MidpointRounding.ToEven)) == z;
+
+                    if (!floatTable.CheckResult(checkFloat))
+                    {
+                        PrintError(floatTable, methodUnderTestName, "(float x, float y, int z, ref int a) =>  (a = (int)x) == z", checkFloat);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Int32WithTruncation.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Int32WithTruncation.cs
new file mode 100644 (file)
index 0000000..0d35aa0
--- /dev/null
@@ -0,0 +1,70 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics.X86;
+using System.Runtime.Intrinsics;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.ConvertToVector128Int32WithTruncation);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double, int>.Create(testsCount, 0.5))
+                using (var floatTable = TestTableSse2<float, int>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        Vector128<int> result = Sse2.ConvertToVector128Int32WithTruncation(value.Item1);
+                        doubleTable.SetOutArrayU(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<float>, Vector128<float>) value = floatTable[i];
+                        Vector128<int> result = Sse2.ConvertToVector128Int32WithTruncation(value.Item1);
+                        floatTable.SetOutArrayU(result);
+                    }
+
+                    CheckMethodFour<double, int> checkDouble = (double x1, double x2, int z1, int z2, ref int a1, ref int a2) =>
+                    {
+                        return (a1 = (int)(x1 > 0 ? Math.Floor(x1) : Math.Ceiling(x1))) == z1 &&
+                            (a2 = (int)(x2 > 0 ? Math.Floor(x2) : Math.Ceiling(x2))) == z2;
+                    };
+
+                    if (!doubleTable.CheckConvertDoubleToVector128Single(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(double x, double y, int z, ref int a) => (a = convertWithTruncation((int)x)) == z", checkDouble);
+                        testResult = Fail;
+                    }
+
+                    CheckMethodTwo<float, int> checkFloat = (float x, float y, int z, ref int a) => (a = (int)(x > 0 ? Math.Floor(x) : Math.Ceiling(x))) == z;
+
+                    if (!floatTable.CheckResult(checkFloat))
+                    {
+                        PrintError(floatTable, methodUnderTestName, "(float x, float y, int z, ref int a) => (a1 = (int)(x > 0 ? Math.Floor(x) : Math.Ceiling(x))) == z", checkFloat);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Int32WithTruncation_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Int32WithTruncation_r.csproj
new file mode 100644 (file)
index 0000000..da7f80c
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{C50DD400-4CB4-4D43-85F1-A9123020CB56}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="ConvertToVector128Int32WithTruncation.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Int32WithTruncation_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Int32WithTruncation_ro.csproj
new file mode 100644 (file)
index 0000000..4818dae
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{1121116A-17F6-4B68-A4A1-9B8E4AE1DFEA}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="ConvertToVector128Int32WithTruncation.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Int32_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Int32_r.csproj
new file mode 100644 (file)
index 0000000..59f76ab
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{E42146CD-285E-43A8-B254-5B252594EAFB}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="ConvertToVector128Int32.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Int32_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Int32_ro.csproj
new file mode 100644 (file)
index 0000000..2064797
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{38DA713E-D154-4724-9BA8-5E7A19A160C4}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="ConvertToVector128Int32.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Single.cs
new file mode 100644 (file)
index 0000000..92a50db
--- /dev/null
@@ -0,0 +1,72 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics.X86;
+using System.Runtime.Intrinsics;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.ConvertToVector128Single);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double, float>.Create(testsCount, 0.5))
+                using (var intTable = TestTableSse2<int, float>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        Vector128<float> result = Sse2.ConvertToVector128Single(value.Item1);
+                        doubleTable.SetOutArrayU(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<int>, Vector128<int>) value = intTable[i];
+                        Vector128<float> result = Sse2.ConvertToVector128Single(value.Item1);
+                        intTable.SetOutArrayU(result);
+                    }
+
+                    CheckMethodFour<double, float> checkDouble = (double x1, double x2, float z1, float z2, ref float a1, ref float a2) =>
+                    {
+                        return (a1 = (float)x1) == z1 && (a2 = (float)x2) == z2;
+                    };
+
+                    if (!doubleTable.CheckConvertDoubleToVector128Single(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(double x1, double x2, float z1, float z2, ref float a1, ref float a2) => (a = (float)x) == z", checkDouble);
+                        testResult = Fail;
+                    }
+
+                    CheckMethodFour<int, float> checkInt32 = (int x1, int x2, float z1, float z2, ref float a1, ref float a2) =>
+                    {
+                        return (a1 = (float)x1) == z1 && (a2 = (float)x2) == z2;
+                    };
+
+                    if (!intTable.CheckConvertInt32ToVector128Single(checkInt32))
+                    {
+                        PrintError(intTable, methodUnderTestName, "(int x1, int x2, float z1, float z2, ref float a1, ref float a2) => (a = (float)x) == z", checkInt32);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Single_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Single_r.csproj
new file mode 100644 (file)
index 0000000..2f5cfc6
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{3CD4F47E-D859-4E65-AEE0-255A88CB5AD0}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="ConvertToVector128Single.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Single_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/ConvertToVector128Single_ro.csproj
new file mode 100644 (file)
index 0000000..581389f
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{29C530A3-9347-4AAB-A067-CDF52A18CA1D}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="ConvertToVector128Single.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Divide.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Divide.cs
new file mode 100644 (file)
index 0000000..764277a
--- /dev/null
@@ -0,0 +1,51 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        private const int Pass = 100;
+        private const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.Divide);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        var result = Sse2.Divide(value.Item1, value.Item2);
+                        doubleTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<double> checkDouble = (double x, double y, double z, ref double a) => (a = x / y) == z;
+
+                    if (!doubleTable.CheckResult(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(double x, double y, double z, ref double a) => (a = x / y) == z", checkDouble);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Divide_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Divide_r.csproj
new file mode 100644 (file)
index 0000000..3978150
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{87A3726E-381D-417E-B498-3C4FFB632544}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Divide.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Divide_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Divide_ro.csproj
new file mode 100644 (file)
index 0000000..eeacfa2
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{8AABA105-3887-4CA6-83F9-3CD59DAAC7E8}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Divide.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.cs
new file mode 100644 (file)
index 0000000..996c1b5
--- /dev/null
@@ -0,0 +1,83 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.Max);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double>.Create(testsCount))
+                using (var shortTable = TestTableSse2<short>.Create(testsCount))
+                using (var byteTable = TestTableSse2<byte>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        var result = Sse2.Max(value.Item1, value.Item2);
+                        doubleTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<short>, Vector128<short>, Vector128<short>) value = shortTable[i];
+                        var result = Sse2.Max(value.Item1, value.Item2);
+                        shortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<byte>, Vector128<byte>, Vector128<byte>) value = byteTable[i];
+                        var result = Sse2.Max(value.Item1, value.Item2);
+                        byteTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<double> checkDouble = (double x, double y, double z, ref double a) => (a = x > y ? x : y) == z;
+
+                    if (!doubleTable.CheckResult(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(double x, double y, double z, ref double a) => (a = x > y ? x : y) == z", checkDouble);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<short> checkInt16 = (short x, short y, short z, ref short a) => (a = x > y ? x : y) == z;
+
+                    if (!shortTable.CheckResult(checkInt16))
+                    {
+                        PrintError(shortTable, methodUnderTestName, "(short x, short y, short z, ref short a) => (a = x > y ? x : y) == z", checkInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<byte> checkByte = (byte x, byte y, byte z, ref byte a) => (a = x > y ? x : y) == z;
+
+                    if (!byteTable.CheckResult(checkByte))
+                    {
+                        PrintError(byteTable, methodUnderTestName, "(byte x, byte y, byte z, ref byte a) => (a = x > y ? x : y) == z", checkByte);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max_r.csproj
new file mode 100644 (file)
index 0000000..756e49a
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{E47ED2C4-6A89-43E3-AD1A-8FEDA7D8FA03}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Max.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max_ro.csproj
new file mode 100644 (file)
index 0000000..aa9defa
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{75455928-80BB-4905-956F-0D53BFC4D804}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Max.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.cs
new file mode 100644 (file)
index 0000000..29f6e90
--- /dev/null
@@ -0,0 +1,83 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.Min);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double>.Create(testsCount))
+                using (var shortTable = TestTableSse2<short>.Create(testsCount))
+                using (var byteTable = TestTableSse2<byte>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        var result = Sse2.Min(value.Item1, value.Item2);
+                        doubleTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<short>, Vector128<short>, Vector128<short>) value = shortTable[i];
+                        var result = Sse2.Min(value.Item1, value.Item2);
+                        shortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<byte>, Vector128<byte>, Vector128<byte>) value = byteTable[i];
+                        var result = Sse2.Min(value.Item1, value.Item2);
+                        byteTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<double> checkDouble = (double x, double y, double z, ref double a) => (a = x > y ? y : x) == z;
+
+                    if (!doubleTable.CheckResult(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(double x, double y, double z, ref double a) => (a = BitwiseOr(x, y)) == z", checkDouble);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<short> checkInt16 = (short x, short y, short z, ref short a) => (a = x > y ? y : x) == z;
+
+                    if (!shortTable.CheckResult(checkInt16))
+                    {
+                        PrintError(shortTable, methodUnderTestName, "(short x, short y, short z, ref short a) => (a = (short)(x | y)) == z", checkInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<byte> checkByte = (byte x, byte y, byte z, ref byte a) => (a = x > y ? y : x) == z;
+
+                    if (!byteTable.CheckResult(checkByte))
+                    {
+                        PrintError(byteTable, methodUnderTestName, "(byte x, byte y, byte z, ref byte a) => (a = (byte)(x | y)) == z", checkByte);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min_r.csproj
new file mode 100644 (file)
index 0000000..3d28c6f
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{78A91B0F-6535-42D7-B64C-948DF295B6BB}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Min.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min_ro.csproj
new file mode 100644 (file)
index 0000000..0e20e01
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{C392B2A4-03ED-4A52-8419-C17085646869}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Min.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Multiply.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Multiply.cs
new file mode 100644 (file)
index 0000000..701253b
--- /dev/null
@@ -0,0 +1,71 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        internal static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.Multiply);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double>.Create(testsCount))
+                using (var uintTable = TestTableSse2<uint, ulong>.Create(testsCount, 2.0))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        Vector128<double> result = Sse2.Multiply(value.Item1, value.Item2);
+                        doubleTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<uint>, Vector128<uint>) value = uintTable[i];
+                        Vector128<ulong> result = Sse2.Multiply(value.Item1, value.Item2);
+                        uintTable.SetOutArrayU(result);
+                    }
+
+                    CheckMethod<double> checkDouble = (double x, double y, double z, ref double a) => (a = x * y) == z;
+
+                    if (!doubleTable.CheckResult(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(double x, double y, double z, ref double a) => (a = x * y) == z", checkDouble);
+                        testResult = Fail;
+                    }
+
+                    CheckMethodFive<uint, ulong> checkUInt32 = (uint x1, uint x2, uint y1, uint y2, ulong z1, ulong z2, ref ulong a1, ref ulong a2) =>
+                    {
+                        a1 = (ulong)x1 * y1;
+                        a2 = (ulong)x2 * y2;
+                        return a1 == z1 && a2 == z2;
+                    };
+
+                    if (!uintTable.CheckMultiplyUInt32ToUInt64(checkUInt32))
+                    {
+                        PrintError(uintTable, methodUnderTestName, "(uint x1, uint x2, uint y1, uint y2, ulong z1, ulong z2, ref ulong a1, ref ulong a2) => (a1 = (ulong)x1 * y1) == z1 && (a2 = (ulong)x2 * y2) == z2", checkUInt32);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyHigh.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyHigh.cs
new file mode 100644 (file)
index 0000000..a94cfe3
--- /dev/null
@@ -0,0 +1,67 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        internal static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.MultiplyHigh);
+
+            if (Sse2.IsSupported)
+            {
+                using (var shortTable = TestTableSse2<short>.Create(testsCount))
+                using (var ushortTable = TestTableSse2<ushort>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<short>, Vector128<short>, Vector128<short>) value = shortTable[i];
+                        Vector128<short> result = Sse2.MultiplyHigh(value.Item1, value.Item2);
+                        shortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<ushort>, Vector128<ushort>, Vector128<ushort>) value = ushortTable[i];
+                        Vector128<ushort> result = Sse2.MultiplyHigh(value.Item1, value.Item2);
+                        ushortTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<short> checkInt16 = (short x, short y, short z, ref short a) => (a = (short)((x * y) >> 16)) == z;
+
+                    if (!shortTable.CheckResult(checkInt16))
+                    {
+                        PrintError(shortTable, methodUnderTestName, "(short x, short y, short z, ref short a) => (a = (short)((x * y) >> 16)) == z", checkInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<ushort> checkUInt16 = (ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)((x * y) >> 16)) == z;
+
+                    if (!ushortTable.CheckResult(checkUInt16))
+                    {
+                        PrintError(ushortTable, methodUnderTestName, "(ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)((x * y) >> 16)) == z", checkUInt16);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyHigh_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyHigh_r.csproj
new file mode 100644 (file)
index 0000000..3772f6a
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{D7FCA7C1-F6E5-4731-926B-65ABCF7ACA5E}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="MultiplyHigh.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyHigh_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyHigh_ro.csproj
new file mode 100644 (file)
index 0000000..b3d07f0
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{266DD6E8-A588-44D7-B208-3F5A123BB577}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="MultiplyHigh.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyHorizontalAdd.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyHorizontalAdd.cs
new file mode 100644 (file)
index 0000000..b582b25
--- /dev/null
@@ -0,0 +1,56 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        internal static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.MultiplyHorizontalAdd);
+
+            if (Sse2.IsSupported)
+            {
+                Console.WriteLine($"Test started");
+
+                using (var shortTable = TestTableSse2<short, int>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<short>, Vector128<short>) value = shortTable[i];
+                        var result = Sse2.MultiplyHorizontalAdd(value.Item1, value.Item2);
+                        shortTable.SetOutArrayU(result);
+                    }
+
+                    CheckMethodThree<short, int> checkInt16 = (short x1, short x2, short y1, short y2, int z, ref int a) =>
+                    (a = (int)x1 * y1 + (int)x2 * y2) == z;
+
+                    if (!shortTable.CheckMultiplyHorizontalAdd(checkInt16))
+                    {
+                        PrintError(shortTable, methodUnderTestName, "(short x1, short x2, short y1, short y2, int z, ref int a) => (a = (int)x1 * y1 + (int)x2 * y2) == z", checkInt16);
+                        testResult = Fail;
+                    }
+                }
+
+                Console.WriteLine($"Test finished with result: {testResult}");
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyHorizontalAdd_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyHorizontalAdd_r.csproj
new file mode 100644 (file)
index 0000000..e99d2d0
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{EEDE2DAC-02AD-4A7B-A1ED-9D91DBA53E41}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="MultiplyHorizontalAdd.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyHorizontalAdd_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyHorizontalAdd_ro.csproj
new file mode 100644 (file)
index 0000000..c35f5e8
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{7FA90B82-1C1C-4D39-8032-16C9EF595F54}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="MultiplyHorizontalAdd.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyLow.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyLow.cs
new file mode 100644 (file)
index 0000000..c3482b7
--- /dev/null
@@ -0,0 +1,56 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        internal static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.MultiplyLow);
+
+            if (Sse2.IsSupported)
+            {
+                using (var shortTable = TestTableSse2<short>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<short>, Vector128<short>, Vector128<short>) value = shortTable[i];
+                        Vector128<short> result = Sse2.MultiplyLow(value.Item1, value.Item2);
+                        shortTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<short> checkInt16 = (short x, short y, short z, ref short a) =>
+                    {
+                        var tmp = ((int)x * y) * 0x0000ffff;
+                        a = unchecked((short)tmp);
+                        return -a == z;
+                    };
+
+                    if (!shortTable.CheckResult(checkInt16))
+                    {
+                        PrintError(shortTable, methodUnderTestName, "(short x, short y, int z, ref int a) => (a = (int)x * y >> 16 | sign) == z", checkInt16);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyLow_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyLow_r.csproj
new file mode 100644 (file)
index 0000000..ff4ae23
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{80E745AB-AF02-47F7-A0D2-8BC29072F1B2}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="MultiplyLow.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyLow_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/MultiplyLow_ro.csproj
new file mode 100644 (file)
index 0000000..ea134fe
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{8316C4EE-22A2-4A34-93A5-106A3AB623FF}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="MultiplyLow.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Multiply_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Multiply_r.csproj
new file mode 100644 (file)
index 0000000..08ee68d
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{750A2506-0993-4BD6-B350-9D1CDF4736A1}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Multiply.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Multiply_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Multiply_ro.csproj
new file mode 100644 (file)
index 0000000..a653a51
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{9B509A79-A647-4FA8-A057-0D7935EC3A0A}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Multiply.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.cs
new file mode 100644 (file)
index 0000000..7958224
--- /dev/null
@@ -0,0 +1,187 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.Or);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double>.Create(testsCount))
+                using (var longTable = TestTableSse2<long>.Create(testsCount))
+                using (var ulongTable = TestTableSse2<ulong>.Create(testsCount))
+                using (var intTable = TestTableSse2<int>.Create(testsCount))
+                using (var uintTable = TestTableSse2<uint>.Create(testsCount))
+                using (var shortTable = TestTableSse2<short>.Create(testsCount))
+                using (var ushortTable = TestTableSse2<ushort>.Create(testsCount))
+                using (var sbyteTable = TestTableSse2<sbyte>.Create(testsCount))
+                using (var byteTable = TestTableSse2<byte>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        var result = Sse2.Or(value.Item1, value.Item2);
+                        doubleTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<long>, Vector128<long>, Vector128<long>) value = longTable[i];
+                        var result = Sse2.Or(value.Item1, value.Item2);
+                        longTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<ulong>, Vector128<ulong>, Vector128<ulong>) value = ulongTable[i];
+                        var result = Sse2.Or(value.Item1, value.Item2);
+                        ulongTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<int>, Vector128<int>, Vector128<int>) value = intTable[i];
+                        var result = Sse2.Or(value.Item1, value.Item2);
+                        intTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<uint>, Vector128<uint>, Vector128<uint>) value = uintTable[i];
+                        var result = Sse2.Or(value.Item1, value.Item2);
+                        uintTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<short>, Vector128<short>, Vector128<short>) value = shortTable[i];
+                        var result = Sse2.Or(value.Item1, value.Item2);
+                        shortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<ushort>, Vector128<ushort>, Vector128<ushort>) value = ushortTable[i];
+                        var result = Sse2.Or(value.Item1, value.Item2);
+                        ushortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<sbyte>, Vector128<sbyte>, Vector128<sbyte>) value = sbyteTable[i];
+                        var result = Sse2.Or(value.Item1, value.Item2);
+                        sbyteTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<byte>, Vector128<byte>, Vector128<byte>) value = byteTable[i];
+                        var result = Sse2.Or(value.Item1, value.Item2);
+                        byteTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<double> checkDouble = (double x, double y, double z, ref double a) => (a = BitwiseOr(x, y)) == z;
+
+                    if (!doubleTable.CheckResult(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(double x, double y, double z, ref double a) => (a = BitwiseOr(x, y)) == z", checkDouble);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<long> checkLong = (long x, long y, long z, ref long a) => (a = x | y) == z;
+
+                    if (!longTable.CheckResult(checkLong))
+                    {
+                        PrintError(longTable, methodUnderTestName, "(long x, long y, long z, ref long a) => (a = x | y) == z", checkLong);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<ulong> checkUlong = (ulong x, ulong y, ulong z, ref ulong a) => (a = x | y) == z;
+
+                    if (!longTable.CheckResult(checkLong))
+                    {
+                        PrintError(ulongTable, methodUnderTestName, "(ulong x, ulong y, ulong z, ref ulong a) => (a = x | y) == z", checkUlong);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<int> checkInt32 = (int x, int y, int z, ref int a) => (a = x | y) == z;
+
+                    if (!intTable.CheckResult(checkInt32))
+                    {
+                        PrintError(intTable, methodUnderTestName, "(int x, int y, int z, ref int a) => (a = x | y) == z", checkInt32);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<uint> checkUInt32 = (uint x, uint y, uint z, ref uint a) => (a = x | y) == z;
+
+                    if (!uintTable.CheckResult(checkUInt32))
+                    {
+                        PrintError(uintTable, methodUnderTestName, "(uint x, uint y, uint z, ref uint a) => (a = x | y) == z", checkUInt32);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<short> checkInt16 = (short x, short y, short z, ref short a) => (a = (short)(x | y)) == z;
+
+                    if (!shortTable.CheckResult(checkInt16))
+                    {
+                        PrintError(shortTable, methodUnderTestName, "(short x, short y, short z, ref short a) => (a = (short)(x | y)) == z", checkInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<ushort> checkUInt16 = (ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)(x | y)) == z;
+
+                    if (!ushortTable.CheckResult(checkUInt16))
+                    {
+                        PrintError(ushortTable, methodUnderTestName, "(ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)(x | y)) == z", checkUInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<sbyte> checkSByte = (sbyte x, sbyte y, sbyte z, ref sbyte a) => (a = (sbyte)(x | y)) == z;
+
+                    if (!sbyteTable.CheckResult(checkSByte))
+                    {
+                        PrintError(sbyteTable, methodUnderTestName, "(sbyte x, sbyte y, sbyte z, ref sbyte a) => (a = (sbyte)(x | y)) == z", checkSByte);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<byte> checkByte = (byte x, byte y, byte z, ref byte a) => (a = (byte)(x | y)) == z;
+
+                    if (!byteTable.CheckResult(checkByte))
+                    {
+                        PrintError(byteTable, methodUnderTestName, "(byte x, byte y, byte z, ref byte a) => (a = (byte)(x | y)) == z", checkByte);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+
+        public static unsafe double BitwiseOr(double x, double y)
+        {
+            var xUlong = BitConverter.ToUInt64(BitConverter.GetBytes(x));
+            var yUlong = BitConverter.ToUInt64(BitConverter.GetBytes(y));
+            var longAnd = xUlong | yUlong;
+            return BitConverter.ToDouble(BitConverter.GetBytes(longAnd));
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or_r.csproj
new file mode 100644 (file)
index 0000000..d0be377
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{44DBB8A7-5F29-4813-B2E3-7978EA45BED8}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Or.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or_ro.csproj
new file mode 100644 (file)
index 0000000..abf2512
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{3625F7C3-45E3-43A5-92B9-9028B9F9476B}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Or.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/PackSignedSaturate.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/PackSignedSaturate.cs
new file mode 100644 (file)
index 0000000..ebe447d
--- /dev/null
@@ -0,0 +1,123 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        internal static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.PackSignedSaturate);
+
+            if (Sse2.IsSupported)
+            {
+                using (var intTable = TestTableSse2<int, short>.Create(testsCount, 0.5))
+                using (var shortTable = TestTableSse2<short, sbyte>.Create(testsCount, 0.5))
+                {
+                    intTable.Initialize(InitMode.NumberFirstVectors);
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<int>, Vector128<int>) value = intTable[i];
+                        Vector128<short> result = Sse2.PackSignedSaturate(value.Item1, value.Item2);
+                        intTable.SetOutArrayU(result, i);
+                    }
+
+                    shortTable.Initialize(InitMode.NumberFirstVectors);
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<short>, Vector128<short>) value = shortTable[i];
+                        Vector128<sbyte> result = Sse2.PackSignedSaturate(value.Item1, value.Item2);
+                        shortTable.SetOutArrayU(result);
+                    }
+
+                    CheckMethodSix<int, short> checkInt32 =
+                        (ValueTuple<int, int, int, int> x, ValueTuple<int, int, int, int> y,
+                        ValueTuple<short, short, short, short, short, short, short, ValueTuple<short>> z,
+                        ref short a1, ref short a2, ref short a3, ref short a4, ref short a5, ref short a6, ref short a7, ref short a8) =>
+                        {
+                            a1 = ToInt16Saturate(x.Item1);
+                            a2 = ToInt16Saturate(x.Item2);
+                            a3 = ToInt16Saturate(x.Item3);
+                            a4 = ToInt16Saturate(x.Item4);
+                            a5 = ToInt16Saturate(y.Item1);
+                            a6 = ToInt16Saturate(y.Item2);
+                            a7 = ToInt16Saturate(y.Item3);
+                            a8 = ToInt16Saturate(y.Item4);
+                            return a1 == z.Item1 && a2 == z.Item2 && a3 == z.Item3 && a4 == z.Item4 &&
+                                a5 == z.Item5 && a6 == z.Item6 && a7 == z.Item7 && a8 == z.Item8;
+                        };
+
+                    if (!intTable.CheckPackSaturate(checkInt32))
+                    {
+                        PrintError(intTable, methodUnderTestName, "CheckPackSaturate", checkInt32);
+                        testResult = Fail;
+                    }
+
+                    CheckMethodSixteen<short, sbyte> checkInt16 =
+                        (ValueTuple<short, short, short, short, short, short, short, ValueTuple<short>> x,
+                         ValueTuple<short, short, short, short, short, short, short, ValueTuple<short>> y,
+                        ValueTuple<sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, ValueTuple<sbyte>> z1,
+                        ValueTuple<sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, ValueTuple<sbyte>> z2,
+                        ref sbyte a1, ref sbyte a2, ref sbyte a3, ref sbyte a4, ref sbyte a5, ref sbyte a6, ref sbyte a7, ref sbyte a8,
+                        ref sbyte a9, ref sbyte a10, ref sbyte a11, ref sbyte a12, ref sbyte a13, ref sbyte a14, ref sbyte a15, ref sbyte a16) =>
+                        {
+                            a1 = ToSByteSaturate(x.Item1);
+                            a2 = ToSByteSaturate(x.Item2);
+                            a3 = ToSByteSaturate(x.Item3);
+                            a4 = ToSByteSaturate(x.Item4);
+                            a5 = ToSByteSaturate(x.Item5);
+                            a6 = ToSByteSaturate(x.Item6);
+                            a7 = ToSByteSaturate(x.Item7);
+                            a8 = ToSByteSaturate(x.Item8);
+                            a9 = ToSByteSaturate(y.Item1);
+                            a10 = ToSByteSaturate(y.Item2);
+                            a11 = ToSByteSaturate(y.Item3);
+                            a12 = ToSByteSaturate(y.Item4);
+                            a13 = ToSByteSaturate(y.Item5);
+                            a14 = ToSByteSaturate(y.Item6);
+                            a15 = ToSByteSaturate(y.Item7);
+                            a16 = ToSByteSaturate(y.Item8);
+
+                            return a1 == z1.Item1 && a2 == z1.Item2 && a3 == z1.Item3 && a4 == z1.Item4 &&
+                                a5 == z1.Item5 && a6 == z1.Item6 && a7 == z1.Item7 && a8 == z1.Item8 &&
+                                a9 == z2.Item1 && a10 == z2.Item2 && a11 == z2.Item3 && a12 == z2.Item4 &&
+                                a13 == z2.Item5 && a14 == z2.Item6 && a15 == z2.Item7 && a16 == z2.Item8;
+                        };
+
+
+                    if (!shortTable.CheckPackSaturate(checkInt16))
+                    {
+                        PrintError(shortTable, methodUnderTestName, "CheckPackSaturate", checkInt16);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+            return testResult;
+        }
+
+        private static short ToInt16Saturate(int value)
+        {
+            return (short)(value > short.MaxValue ? short.MaxValue : value < short.MinValue ? short.MinValue : value);
+        }
+
+        private static sbyte ToSByteSaturate(short value)
+        {
+            return (sbyte)(value > sbyte.MaxValue ? sbyte.MaxValue : value < sbyte.MinValue ? sbyte.MinValue : value);
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/PackSignedSaturate_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/PackSignedSaturate_r.csproj
new file mode 100644 (file)
index 0000000..b7abbba
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{A0B71B98-843A-4CEB-84D5-EF1058A4830D}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="PackSignedSaturate.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/PackSignedSaturate_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/PackSignedSaturate_ro.csproj
new file mode 100644 (file)
index 0000000..14d11a6
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{A1A59671-D8A9-4580-9211-9DCB9CDC338F}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="PackSignedSaturate.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/PackUnsignedSaturate.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/PackUnsignedSaturate.cs
new file mode 100644 (file)
index 0000000..c0e6a08
--- /dev/null
@@ -0,0 +1,85 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        internal static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.PackUnsignedSaturate);
+
+            if (Sse2.IsSupported)
+            {
+                using (var shortTable = TestTableSse2<short, byte>.Create(testsCount, 0.5))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<short>, Vector128<short>) value = shortTable[i];
+                        Vector128<byte> result = Sse2.PackUnsignedSaturate(value.Item1, value.Item2);
+                        shortTable.SetOutArrayU(result);
+                    }
+
+                    CheckMethodSixteen<short, byte> checkInt16 =
+                        (ValueTuple<short, short, short, short, short, short, short, ValueTuple<short>> x,
+                        ValueTuple<short, short, short, short, short, short, short, ValueTuple<short>> y,
+                        ValueTuple<byte, byte, byte, byte, byte, byte, byte, ValueTuple<byte>> z1,
+                        ValueTuple<byte, byte, byte, byte, byte, byte, byte, ValueTuple<byte>> z2,
+                        ref byte a1, ref byte a2, ref byte a3, ref byte a4, ref byte a5, ref byte a6, ref byte a7, ref byte a8,
+                        ref byte a9, ref byte a10, ref byte a11, ref byte a12, ref byte a13, ref byte a14, ref byte a15, ref byte a16) =>
+                    {
+                        a1 = ToByteSaturate(x.Item1);
+                        a2 = ToByteSaturate(x.Item2);
+                        a3 = ToByteSaturate(x.Item3);
+                        a4 = ToByteSaturate(x.Item4);
+                        a5 = ToByteSaturate(x.Item5);
+                        a6 = ToByteSaturate(x.Item6);
+                        a7 = ToByteSaturate(x.Item7);
+                        a8 = ToByteSaturate(x.Item8);
+                        a9 = ToByteSaturate(y.Item1);
+                        a10 = ToByteSaturate(y.Item2);
+                        a11 = ToByteSaturate(y.Item3);
+                        a12 = ToByteSaturate(y.Item4);
+                        a13 = ToByteSaturate(y.Item5);
+                        a14 = ToByteSaturate(y.Item6);
+                        a15 = ToByteSaturate(y.Item7);
+                        a16 = ToByteSaturate(y.Item8);
+
+                        return a1 == z1.Item1 && a2 == z1.Item2 && a3 == z1.Item3 && a4 == z1.Item4 &&
+                            a5 == z1.Item5 && a6 == z1.Item6 && a7 == z1.Item7 && a8 == z1.Item8 &&
+                            a9 == z2.Item1 && a10 == z2.Item2 && a11 == z2.Item3 && a12 == z2.Item4 &&
+                            a13 == z2.Item5 && a14 == z2.Item6 && a15 == z2.Item7 && a16 == z2.Item8;
+                    };
+
+                    if (!shortTable.CheckPackSaturate(checkInt16))
+                    {
+                        PrintError(shortTable, methodUnderTestName, "CheckPackSaturate", checkInt16);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+
+        private static byte ToByteSaturate(short value)
+        {
+            return (byte)(value > byte.MaxValue ? byte.MaxValue : value < 0 ? 0 : value);
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/PackUnsignedSaturate_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/PackUnsignedSaturate_r.csproj
new file mode 100644 (file)
index 0000000..5d059e9
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{A11D2E47-7AA7-4D13-9087-39785BB82D7C}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="PackUnsignedSaturate.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/PackUnsignedSaturate_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/PackUnsignedSaturate_ro.csproj
new file mode 100644 (file)
index 0000000..0f1936b
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{C8295B8E-35C4-4A29-8BF7-44A1F9525ACC}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="PackUnsignedSaturate.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetZeroVector128.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetZeroVector128.cs
new file mode 100644 (file)
index 0000000..4a5974a
--- /dev/null
@@ -0,0 +1,178 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.SetZeroVector128);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double>.Create(testsCount))
+                using (var longTable = TestTableSse2<long>.Create(testsCount))
+                using (var ulongTable = TestTableSse2<ulong>.Create(testsCount))
+                using (var intTable = TestTableSse2<int>.Create(testsCount))
+                using (var uintTable = TestTableSse2<uint>.Create(testsCount))
+                using (var shortTable = TestTableSse2<short>.Create(testsCount))
+                using (var ushortTable = TestTableSse2<ushort>.Create(testsCount))
+                using (var sbyteTable = TestTableSse2<sbyte>.Create(testsCount))
+                using (var byteTable = TestTableSse2<byte>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        Vector128<double> result = Sse2.SetZeroVector128<double>();
+                        doubleTable.SetOutArray(result, i);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        Vector128<long> result = Sse2.SetZeroVector128<long>();
+                        longTable.SetOutArray(result, i);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        Vector128<ulong> result = Sse2.SetZeroVector128<ulong>();
+                        ulongTable.SetOutArray(result, i);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        Vector128<int> result = Sse2.SetZeroVector128<int>();
+                        intTable.SetOutArray(result, i);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        Vector128<uint> result = Sse2.SetZeroVector128<uint>();
+                        uintTable.SetOutArray(result, i);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        Vector128<short> result = Sse2.SetZeroVector128<short>();
+                        shortTable.SetOutArray(result, i);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        Vector128<ushort> result = Sse2.SetZeroVector128<ushort>();
+                        ushortTable.SetOutArray(result, i);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        Vector128<sbyte> result = Sse2.SetZeroVector128<sbyte>();
+                        sbyteTable.SetOutArray(result, i);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        Vector128<byte> result = Sse2.SetZeroVector128<byte>();
+                        byteTable.SetOutArray(result, i);
+                    }
+
+                    CheckMethod<double> checkDouble = (double x, double y, double z, ref double a) => (a = BitwiseXor(x, x)) == z;
+
+                    if (!doubleTable.CheckResult(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(double x, double y, double z, ref double a) => (a = BitwiseXor(x, y)) == z", checkDouble);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<long> checkLong = (long x, long y, long z, ref long a) => (a = x ^ x) == z;
+
+                    if (!longTable.CheckResult(checkLong))
+                    {
+                        PrintError(longTable, methodUnderTestName, "(long x, long y, long z, ref long a) => (a = x ^ x) == z", checkLong);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<ulong> checkUlong = (ulong x, ulong y, ulong z, ref ulong a) => (a = x ^ x) == z;
+
+                    if (!longTable.CheckResult(checkLong))
+                    {
+                        PrintError(ulongTable, methodUnderTestName, "(ulong x, ulong y, ulong z, ref ulong a) => (a = x ^ x) == z", checkUlong);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<int> checkInt32 = (int x, int y, int z, ref int a) => (a = x ^ x) == z;
+
+                    if (!intTable.CheckResult(checkInt32))
+                    {
+                        PrintError(intTable, methodUnderTestName, "(int x, int y, int z, ref int a) => (a = x ^ x) == z", checkInt32);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<uint> checkUInt32 = (uint x, uint y, uint z, ref uint a) => (a = x ^ x) == z;
+
+                    if (!uintTable.CheckResult(checkUInt32))
+                    {
+                        PrintError(uintTable, methodUnderTestName, "(uint x, uint y, uint z, ref uint a) => (a = x ^ x) == z", checkUInt32);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<short> checkInt16 = (short x, short y, short z, ref short a) => (a = (short)(x ^ x)) == z;
+
+                    if (!shortTable.CheckResult(checkInt16))
+                    {
+                        PrintError(shortTable, methodUnderTestName, "(short x, short y, short z, ref short a) => (a = (short)(x ^ x)) == z", checkInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<ushort> checkUInt16 = (ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)(x ^ x)) == z;
+
+                    if (!ushortTable.CheckResult(checkUInt16))
+                    {
+                        PrintError(ushortTable, methodUnderTestName, "(ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)(x ^ x)) == z", checkUInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<sbyte> checkSByte = (sbyte x, sbyte y, sbyte z, ref sbyte a) => (a = (sbyte)(x ^ x)) == z;
+
+                    if (!sbyteTable.CheckResult(checkSByte))
+                    {
+                        PrintError(sbyteTable, methodUnderTestName, "(sbyte x, sbyte y, sbyte z, ref sbyte a) => (a = (sbyte)(x ^ x)) == z", checkSByte);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<byte> checkByte = (byte x, byte y, byte z, ref byte a) => (a = (byte)(x ^ x)) == z;
+
+                    if (!byteTable.CheckResult(checkByte))
+                    {
+                        PrintError(byteTable, methodUnderTestName, "(byte x, byte y, byte z, ref byte a) => (a = (byte)(x ^ x)) == z", checkByte);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+
+        public static unsafe double BitwiseXor(double x, double y)
+        {
+            var xUlong = BitConverter.ToUInt64(BitConverter.GetBytes(x));
+            var yUlong = BitConverter.ToUInt64(BitConverter.GetBytes(y));
+            var longAnd = xUlong ^ yUlong;
+            return BitConverter.ToDouble(BitConverter.GetBytes(longAnd));
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetZeroVector128_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetZeroVector128_r.csproj
new file mode 100644 (file)
index 0000000..cf2d1d1
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{CEE19E36-E1A6-4C13-93EB-35FB2F69DF7D}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="SetZeroVector128.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetZeroVector128_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SetZeroVector128_ro.csproj
new file mode 100644 (file)
index 0000000..5dabc1b
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{5EDC665C-0CA9-4061-B048-06DE58DF3B79}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="SetZeroVector128.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sqrt.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sqrt.cs
new file mode 100644 (file)
index 0000000..58c19ee
--- /dev/null
@@ -0,0 +1,51 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.Sqrt);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        var result = Sse2.Sqrt(value.Item1);
+                        doubleTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<double> checkDouble = (double x, double y, double z, ref double a) => (a = Math.Sqrt(x)) == z;
+
+                    if (!doubleTable.CheckResult(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(double x, double y, double z, ref double a) => (a = x - y) == z", checkDouble);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sqrt_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sqrt_r.csproj
new file mode 100644 (file)
index 0000000..fe9c470
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{51841B25-F26B-41A4-8C77-C7FE92548A4C}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Sqrt.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sqrt_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Sqrt_ro.csproj
new file mode 100644 (file)
index 0000000..7e8a25e
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{066503AD-D4E3-453D-AE7A-685199416339}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Sqrt.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.cs
new file mode 100644 (file)
index 0000000..ce786d6
--- /dev/null
@@ -0,0 +1,179 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.Subtract);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double>.Create(testsCount))
+                using (var longTable = TestTableSse2<long>.Create(testsCount))
+                using (var ulongTable = TestTableSse2<ulong>.Create(testsCount))
+                using (var intTable = TestTableSse2<int>.Create(testsCount))
+                using (var uintTable = TestTableSse2<uint>.Create(testsCount))
+                using (var shortTable = TestTableSse2<short>.Create(testsCount))
+                using (var ushortTable = TestTableSse2<ushort>.Create(testsCount))
+                using (var sbyteTable = TestTableSse2<sbyte>.Create(testsCount))
+                using (var byteTable = TestTableSse2<byte>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        var result = Sse2.Subtract(value.Item1, value.Item2);
+                        doubleTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<long>, Vector128<long>, Vector128<long>) value = longTable[i];
+                        var result = Sse2.Subtract(value.Item1, value.Item2);
+                        longTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<ulong>, Vector128<ulong>, Vector128<ulong>) value = ulongTable[i];
+                        var result = Sse2.Subtract(value.Item1, value.Item2);
+                        ulongTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<int>, Vector128<int>, Vector128<int>) value = intTable[i];
+                        var result = Sse2.Subtract(value.Item1, value.Item2);
+                        intTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<uint>, Vector128<uint>, Vector128<uint>) value = uintTable[i];
+                        var result = Sse2.Subtract(value.Item1, value.Item2);
+                        uintTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<short>, Vector128<short>, Vector128<short>) value = shortTable[i];
+                        var result = Sse2.Subtract(value.Item1, value.Item2);
+                        shortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<ushort>, Vector128<ushort>, Vector128<ushort>) value = ushortTable[i];
+                        var result = Sse2.Subtract(value.Item1, value.Item2);
+                        ushortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<sbyte>, Vector128<sbyte>, Vector128<sbyte>) value = sbyteTable[i];
+                        var result = Sse2.Subtract(value.Item1, value.Item2);
+                        sbyteTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<byte>, Vector128<byte>, Vector128<byte>) value = byteTable[i];
+                        var result = Sse2.Subtract(value.Item1, value.Item2);
+                        byteTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<double> checkDouble = (double x, double y, double z, ref double a) => (a = x - y) == z;
+
+                    if (!doubleTable.CheckResult(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(double x, double y, double z, ref double a) => (a = x - y) == z", checkDouble);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<long> checkLong = (long x, long y, long z, ref long a) => (a = x - y) == z;
+
+                    if (!longTable.CheckResult(checkLong))
+                    {
+                        PrintError(longTable, methodUnderTestName, "(long x, long y, long z, ref long a) => (a = x - y) == z", checkLong);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<ulong> checkUlong = (ulong x, ulong y, ulong z, ref ulong a) => (a = x - y) == z;
+
+                    if (!longTable.CheckResult(checkLong))
+                    {
+                        PrintError(ulongTable, methodUnderTestName, "(ulong x, ulong y, ulong z, ref ulong a) => (a = x - y) == z", checkUlong);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<int> checkInt32 = (int x, int y, int z, ref int a) => (a = x - y) == z;
+
+                    if (!intTable.CheckResult(checkInt32))
+                    {
+                        PrintError(intTable, methodUnderTestName, "(int x, int y, int z, ref int a) => (a = x - y) == z", checkInt32);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<uint> checkUInt32 = (uint x, uint y, uint z, ref uint a) => (a = x - y) == z;
+
+                    if (!uintTable.CheckResult(checkUInt32))
+                    {
+                        PrintError(uintTable, methodUnderTestName, "(uint x, uint y, uint z, ref uint a) => (a = x - y) == z", checkUInt32);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<short> checkInt16 = (short x, short y, short z, ref short a) => (a = (short)(x - y)) == z;
+
+                    if (!shortTable.CheckResult(checkInt16))
+                    {
+                        PrintError(shortTable, methodUnderTestName, "(short x, short y, short z, ref short a) => (a = (short)(x - y)) == z", checkInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<ushort> checkUInt16 = (ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)(x - y)) == z;
+
+                    if (!ushortTable.CheckResult(checkUInt16))
+                    {
+                        PrintError(ushortTable, methodUnderTestName, "(ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)(x - y)) == z", checkUInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<sbyte> checkSByte = (sbyte x, sbyte y, sbyte z, ref sbyte a) => (a = (sbyte)(x - y)) == z;
+
+                    if (!sbyteTable.CheckResult(checkSByte))
+                    {
+                        PrintError(sbyteTable, methodUnderTestName, "(sbyte x, sbyte y, sbyte z, ref sbyte a) => (a = (sbyte)(x - y)) == z", checkSByte);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<byte> checkByte = (byte x, byte y, byte z, ref byte a) => (a = (byte)(x - y)) == z;
+
+                    if (!byteTable.CheckResult(checkByte))
+                    {
+                        PrintError(byteTable, methodUnderTestName, "(byte x, byte y, byte z, ref byte a) => (a = (byte)(x - y)) == z", checkByte);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate.cs
new file mode 100644 (file)
index 0000000..b1c5b5c
--- /dev/null
@@ -0,0 +1,127 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.SubtractSaturate);
+
+            if (Sse2.IsSupported)
+            {
+                using (var shortTable = TestTableSse2<short>.Create(testsCount))
+                using (var ushortTable = TestTableSse2<ushort>.Create(testsCount))
+                using (var sbyteTable = TestTableSse2<sbyte>.Create(testsCount))
+                using (var byteTable = TestTableSse2<byte>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<short>, Vector128<short>, Vector128<short>) value = shortTable[i];
+                        var result = Sse2.SubtractSaturate(value.Item1, value.Item2);
+                        shortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<ushort>, Vector128<ushort>, Vector128<ushort>) value = ushortTable[i];
+                        var result = Sse2.SubtractSaturate(value.Item1, value.Item2);
+                        ushortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<sbyte>, Vector128<sbyte>, Vector128<sbyte>) value = sbyteTable[i];
+                        var result = Sse2.SubtractSaturate(value.Item1, value.Item2);
+                        sbyteTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<byte>, Vector128<byte>, Vector128<byte>) value = byteTable[i];
+                        var result = Sse2.SubtractSaturate(value.Item1, value.Item2);
+                        byteTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<short> checkInt16 = (short x, short y, short z, ref short a) =>
+                    {
+                        int value = (int)x - y;
+                        value = Math.Max(value, short.MinValue);
+                        value = Math.Min(value, short.MaxValue);
+                        a = (short) value;
+                        return a == z;
+                    };
+
+                    if (!shortTable.CheckResult(checkInt16))
+                    {
+                        PrintError(shortTable, methodUnderTestName, "(short x, short y, short z, ref short a) => (a = (short)(x - y)) == z", checkInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<ushort> checkUInt16 = (ushort x, ushort y, ushort z, ref ushort a) =>
+                    {
+                        int value = (int)x - y;
+                        value = Math.Max(value, 0);
+                        value = Math.Min(value, ushort.MaxValue);
+                        a = (ushort) value;
+                        return a == z;
+                    };
+
+                    if (!ushortTable.CheckResult(checkUInt16))
+                    {
+                        PrintError(ushortTable, methodUnderTestName, "(ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)(x & y)) == z", checkUInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<sbyte> checkSByte = (sbyte x, sbyte y, sbyte z, ref sbyte a) =>
+                    {
+                        int value = (int)x - y;
+                        value = Math.Max(value, sbyte.MinValue);
+                        value = Math.Min(value, sbyte.MaxValue);
+                        a = (sbyte) value;
+                        return a == z;
+                    };
+
+                    if (!sbyteTable.CheckResult(checkSByte))
+                    {
+                        PrintError(sbyteTable, methodUnderTestName, "(sbyte x, sbyte y, sbyte z, ref sbyte a) => (a = (sbyte)(x & y)) == z", checkSByte);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<byte> checkByte = (byte x, byte y, byte z, ref byte a) =>
+                    {
+                        int value = (int)x - y;
+                        value = Math.Max(value, 0);
+                        value = Math.Min(value, byte.MaxValue);
+                        a = (byte) value;
+                        return a == z;
+                    };
+
+                    if (!byteTable.CheckResult(checkByte))
+                    {
+                        PrintError(byteTable, methodUnderTestName, "(byte x, byte y, byte z, ref byte a) => (a = (byte)(x & y)) == z", checkByte);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate_r.csproj
new file mode 100644 (file)
index 0000000..3bcd3d3
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{03A382F5-1AC9-419C-8EA8-0387D5D50815}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="SubtractSaturate.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SubtractSaturate_ro.csproj
new file mode 100644 (file)
index 0000000..7b21f7f
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{E6D16C91-1AE1-455C-947B-A16955D90984}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="SubtractSaturate.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract_r.csproj
new file mode 100644 (file)
index 0000000..accd716
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{DDE1DDD6-B6BD-42D2-9D49-5BCE2E707442}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Subtract.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract_ro.csproj
new file mode 100644 (file)
index 0000000..810f233
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{7B7FCE02-0D75-4BE2-80C0-29F2D410FDF3}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Subtract.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SumAbsoluteDifferences.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SumAbsoluteDifferences.cs
new file mode 100644 (file)
index 0000000..8a696a1
--- /dev/null
@@ -0,0 +1,62 @@
+// 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.
+//
+
+using System;
+using System.Linq;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.SumAbsoluteDifferences);
+
+            if (Sse2.IsSupported)
+            {
+                using (var byteTable = TestTableSse2<byte, long>.Create(testsCount, 8.0))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<byte>, Vector128<byte>) value = byteTable[i];
+                        var result = Sse2.SumAbsoluteDifferences(value.Item1, value.Item2);
+                        byteTable.SetOutArrayU(result);
+                    }
+
+                    CheckMethodEightOne<byte, long> checkByte = (Span<byte> x, Span<byte> y, long z, ref long a) =>
+                    {
+                        short[] tmpArray = new short[8];
+                        for (int i = 0; i < 8; i++)
+                        {
+                            tmpArray[i] = (short)Math.Abs(x[i] - y[i]);
+                        }
+
+                        foreach (short s in tmpArray) a += s;
+                        return a == z;
+                    };
+
+                    if (!byteTable.CheckResult(checkByte))
+                    {
+                        PrintError(byteTable, methodUnderTestName, "(Span<byte> x, Span<byte> y, long z, ref long a) => SumAbsoluteDifferences", checkByte);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SumAbsoluteDifferences_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SumAbsoluteDifferences_r.csproj
new file mode 100644 (file)
index 0000000..bd27f08
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{5E8D9C85-4EF4-4A7E-8294-3F64C4340945}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="SumAbsoluteDifferences.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SumAbsoluteDifferences_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/SumAbsoluteDifferences_ro.csproj
new file mode 100644 (file)
index 0000000..76129da
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{8B32C158-D842-4D93-867B-6D9AD688AB92}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="SumAbsoluteDifferences.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/TestTableSse2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/TestTableSse2.cs
new file mode 100644 (file)
index 0000000..8233c16
--- /dev/null
@@ -0,0 +1,1460 @@
+// 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.
+//
+
+using System;
+using System.Globalization;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    public delegate bool CheckMethod<T>(T x, T y, T z, ref T c);
+
+    public delegate bool CheckMethodTwo<T, U>(T x, T y, U z, ref U c);
+
+    public delegate bool CheckMethodTwo<T, U, V>(T x, V y, U z, ref U c);
+
+    public delegate bool CheckMethodThree<T, U>(T x1, T x2, T y1, T y2, U z, ref U c);
+
+    public delegate bool CheckMethodFour<T, U>(T x1, T x2, U z1, U z2, ref U c1, ref U c2);
+
+    public delegate bool CheckMethodFive<T, U>(T x1, T x2, T y1, T y2, U z1, U z2, ref U c1, ref U c2);
+
+    public delegate bool CheckMethodFourTFourU<T, U>(
+        ValueTuple<T, T, T, T> x,
+        ValueTuple<T, T, T, T> y,
+        ValueTuple<U, U, U, U> z,
+        ref U a1, ref U a2, ref U a3, ref U a4);
+
+    public delegate bool CheckMethodSix<T, U>(
+        ValueTuple<T, T, T, T> x,
+        ValueTuple<T, T, T, T> y,
+        ValueTuple<U, U, U, U, U, U, U, ValueTuple<U>> z,
+        ref U a1, ref U a2, ref U a3, ref U a4, ref U a5, ref U a6, ref U a7, ref U a8);
+
+    public delegate bool CheckMethodEightOne<T, U>(
+        Span<T> x, Span<T> y, U z, ref U a);
+
+    public delegate bool CheckMethodEightOfTEightOfU<T, U>(
+        ValueTuple<T, T, T, T, T, T, T, ValueTuple<T>> x,
+        ValueTuple<T, T, T, T, T, T, T, ValueTuple<T>> y,
+        ValueTuple<U, U, U, U, U, U, U, ValueTuple<U>> z,
+        ref U a1, ref U a2, ref U a3, ref U a4, ref U a5, ref U a6, ref U a7, ref U a8);
+
+    public delegate bool CheckMethodEightImm<T, U, V>(
+        Span<T> x, T value, V i, Span<U> z, Span<U> a);
+
+    public delegate bool CheckMethodSixteen<T, U>(
+        ValueTuple<T, T, T, T, T, T, T, ValueTuple<T>> x,
+        ValueTuple<T, T, T, T, T, T, T, ValueTuple<T>> y,
+        ValueTuple<U, U, U, U, U, U, U, ValueTuple<U>> z1,
+        ValueTuple<U, U, U, U, U, U, U, ValueTuple<U>> z2,
+        ref U a1, ref U a2, ref U a3, ref U a4, ref U a5, ref U a6, ref U a7, ref U a8,
+        ref U a9, ref U a10, ref U a11, ref U a12, ref U a13, ref U a14, ref U a15, ref U a16);
+
+    public delegate bool CheckMethodSixteenOfAll<T, U>(
+        ValueTuple<T, T, T, T, T, T, T, ValueTuple<T>> x1,
+        ValueTuple<T, T, T, T, T, T, T, ValueTuple<T>> x2,
+        ValueTuple<T, T, T, T, T, T, T, ValueTuple<T>> y1,
+        ValueTuple<T, T, T, T, T, T, T, ValueTuple<T>> y2,
+        ValueTuple<U, U, U, U, U, U, U, ValueTuple<U>> z1,
+        ValueTuple<U, U, U, U, U, U, U, ValueTuple<U>> z2,
+        ref U a1, ref U a2, ref U a3, ref U a4, ref U a5, ref U a6, ref U a7, ref U a8,
+        ref U a9, ref U a10, ref U a11, ref U a12, ref U a13, ref U a14, ref U a15, ref U a16);
+
+    [Flags]
+    public enum InitMode
+    {
+        Undefined = 0,
+        NumberFirstVectors = 0b00000001
+    }
+
+    public unsafe struct TestTableSse2<T> : IDisposable where T : struct
+    {
+        private const int _stepSize = 16;
+        private int _scalarStepSize;
+
+        private GCHandle _inHandle1;
+        private GCHandle _inHandle2;
+        private GCHandle _outHandle;
+        private GCHandle _checkHandle;
+
+        private int _index;
+
+        public T[] inArray1;
+        public T[] inArray2;
+        public T[] outArray;
+        public T[] checkArray;
+
+        public void* InArray1Ptr => _inHandle1.AddrOfPinnedObject().ToPointer();
+        public void* InArray2Ptr => _inHandle2.AddrOfPinnedObject().ToPointer();
+        public void* OutArrayPtr => _outHandle.AddrOfPinnedObject().ToPointer();
+        public void* CheckArrayPtr => _checkHandle.AddrOfPinnedObject().ToPointer();
+
+        public Vector128<T> Vector1 => Unsafe.Read<Vector128<T>>((byte*)InArray1Ptr + (_index * _stepSize));
+        public Vector128<T> Vector2 => Unsafe.Read<Vector128<T>>((byte*)InArray2Ptr + (_index * _stepSize));
+        public Vector128<T> Vector3 => Unsafe.Read<Vector128<T>>((byte*)OutArrayPtr + (_index * _stepSize));
+        public int Index { get => _index; set => _index = value; }
+
+        public void SetOutArray(Vector128<T> value, int index = -1)
+        {
+            index = index < 0 ? _index : index;
+            Unsafe.Write((byte*)OutArrayPtr + (index * _stepSize), value);
+        }
+
+        public (Vector128<T>, Vector128<T>, Vector128<T>) this[int index]
+        {
+            get
+            {
+                _index = index;
+                return new ValueTuple<Vector128<T>, Vector128<T>, Vector128<T>>(Vector1, Vector2, Vector3);
+            }
+        }
+
+        public ValueTuple<T, T, T, T> GetDataPoint(int index)
+        {
+            return (inArray1[index], inArray2[index], outArray[index], checkArray[index]);
+        }
+
+        public static TestTableSse2<T> Create(int lengthInVectors)
+        {
+            int length = _stepSize / Marshal.SizeOf<T>() * lengthInVectors;
+            var table = new TestTableSse2<T>(new T[length], new T[length], new T[length], new T[length]);
+            table.Initialize();
+            return table;
+        }
+
+        public TestTableSse2(T[] a, T[] b, T[] c, T[] d)
+        {
+            inArray1 = a;
+            inArray2 = b;
+            outArray = c;
+            checkArray = d;
+            _scalarStepSize = Marshal.SizeOf<T>();
+            _index = 0;
+            _inHandle1 = GCHandle.Alloc(inArray1, GCHandleType.Pinned);
+            _inHandle2 = GCHandle.Alloc(inArray2, GCHandleType.Pinned);
+            _outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned);
+            _checkHandle = GCHandle.Alloc(checkArray, GCHandleType.Pinned);
+            Initialize();
+        }
+
+        public void Initialize()
+        {
+            Random random = new Random(unchecked((int)(DateTime.UtcNow.Ticks & 0x00000000ffffffffl)));
+            if (inArray1 is double[])
+            {
+                var array1 = inArray1 as double[];
+                var array2 = inArray2 as double[];
+                for (int i = 0; i < inArray1.Length; i++)
+                {
+                    array1[i] = random.NextDouble() * random.Next();
+                    array2[i] = random.NextDouble() * random.Next();
+                }
+            }
+            else if (inArray1 is float[])
+            {
+                var arrayFloat1 = inArray1 as float[];
+                var arrayFloat2 = inArray2 as float[];
+                for (int i = 0; i < inArray1.Length; i++)
+                {
+                    arrayFloat1[i] = (float)(random.NextDouble() * random.Next(ushort.MaxValue));
+                    arrayFloat2[i] = (float)(random.NextDouble() * random.Next(ushort.MaxValue));
+                }
+            }
+            else
+            {
+                random.NextBytes(new Span<byte>(InArray1Ptr, inArray1.Length * _scalarStepSize));
+                random.NextBytes(new Span<byte>(InArray2Ptr, inArray1.Length * _scalarStepSize));
+            }
+        }
+
+        public bool CheckResult(CheckMethod<T> check)
+        {
+            bool result = true;
+            for (int i = 0; i < inArray1.Length; i++)
+            {
+                if (!check(inArray1[i], inArray2[i], outArray[i], ref checkArray[i]))
+                {
+                    result = false;
+                }
+            }
+            return result;
+        }
+
+        public void Dispose()
+        {
+            _inHandle1.Free();
+            _inHandle2.Free();
+            _outHandle.Free();
+            _checkHandle.Free();
+        }
+    }
+
+    public unsafe struct TestTableSse2<T, U> : IDisposable where T : struct where U : struct
+    {
+        private const int _stepSize = 16;
+        private int _tSize;
+
+        private GCHandle _inHandle1;
+        private GCHandle _inHandle2;
+        private GCHandle _outHandle;
+        private GCHandle _checkHandle;
+
+        private int _index;
+
+        public T[] inArray1;
+        public T[] inArray2;
+        public U[] outArray;
+        public U[] checkArray;
+
+        public void* InArray1Ptr => _inHandle1.AddrOfPinnedObject().ToPointer();
+        public void* InArray2Ptr => _inHandle2.AddrOfPinnedObject().ToPointer();
+        public void* OutArrayPtr => _outHandle.AddrOfPinnedObject().ToPointer();
+        public void* CheckArrayPtr => _checkHandle.AddrOfPinnedObject().ToPointer();
+
+        public Vector128<T> Vector1 => Unsafe.Read<Vector128<T>>((byte*)InArray1Ptr + (_index * _stepSize));
+        public Vector128<T> Vector2 => Unsafe.Read<Vector128<T>>((byte*)InArray2Ptr + (_index * _stepSize));
+        public Vector128<U> Vector3 => Unsafe.Read<Vector128<U>>((byte*)OutArrayPtr + (_index * _stepSize));
+        public Vector128<U> Vector4 => Unsafe.Read<Vector128<U>>((byte*)CheckArrayPtr + (_index * _stepSize));
+
+        public int Index { get => _index; set => _index = value; }
+
+        public void SetOutArray(Vector128<T> value, int index = -1)
+        {
+            index = index < 0 ? _index : index;
+            Unsafe.Write((byte*)OutArrayPtr + (index * _stepSize), value);
+        }
+
+        public void SetOutArrayU(Vector128<U> value, int index = -1)
+        {
+            index = index < 0 ? _index : index;
+            Unsafe.Write((byte*)OutArrayPtr + (_index * _stepSize), value);
+        }
+
+        public (Vector128<T>, Vector128<T>) this[int index]
+        {
+            get
+            {
+                _index = index;
+                return (Vector1, Vector2);
+            }
+        }
+
+        public ValueTuple<T, T, T, T> GetQuad4DataPoint(int index)
+        {
+            var value3 = Unsafe.Read<T>((byte*)OutArrayPtr + (_index * _stepSize));
+            var value4 = Unsafe.Read<T>((byte*)CheckArrayPtr + (_index * _stepSize));
+            return (inArray1[index], inArray2[index], value3, value4);
+        }
+
+        public unsafe ValueTuple<T, T, U, U> GetQuad22DataPoint(int index)
+        {
+            return (inArray1[index], inArray2[index], outArray[index], checkArray[index]);
+        }
+
+        public ValueTuple<T, T, T, T, U, U> GetHexa42DataPoint(int index)
+        {
+            return (inArray1[index], inArray1[index + 1], inArray2[index], inArray2[index + 1], outArray[index], checkArray[index]);
+        }
+
+        public ValueTuple<T, T, U, U, U, U> GetHexa24DataPoint(int index)
+        {
+            return (inArray1[index], inArray1[index + 1], outArray[index], outArray[index + 1], checkArray[index], checkArray[index + 1]);
+        }
+
+        public ValueTuple<T, T, T, T, U, U, U, ValueTuple<U>> GetOcta44DataPoint(int index)
+        {
+            return new ValueTuple<T, T, T, T, U, U, U, ValueTuple<U>>(inArray1[index], inArray1[index + 2], inArray2[index], inArray2[index + 2],
+                outArray[index], outArray[index + 1], checkArray[index], new ValueTuple<U>(checkArray[index + 1]));
+        }
+
+        public ValueTuple<ValueTuple<T, T, T, T>, ValueTuple<T, T, T, T>, ValueTuple<U, U, U, U, U, U, U, ValueTuple<U>>, ValueTuple<U, U, U, U, U, U, U, ValueTuple<U>>> GetCheckMethodSix4DataPoint(int index)
+        {
+            return ((inArray1[index], inArray1[index + 1], inArray1[index + 2], inArray1[index + 3]),
+                (inArray2[index], inArray2[index + 1], inArray2[index + 2], inArray2[index + 3]),
+                (outArray[index], outArray[index + 1], outArray[index + 2], outArray[index + 3],
+                outArray[index + 4], outArray[index + 5], outArray[index + 6], (outArray[index + 7])),
+                (checkArray[index], checkArray[index + 1], checkArray[index + 2], checkArray[index + 3],
+                checkArray[index + 4], checkArray[index + 5], checkArray[index + 6], (checkArray[index + 7])));
+        }
+
+        public ValueTuple<ValueTuple<T, T, T, T, T, T, T , ValueTuple<T>>, ValueTuple<T, T, T, T, T, T, T, ValueTuple<T>>, ValueTuple<U, U, U, U, U, U, U, ValueTuple<U>>, ValueTuple<U, U, U, U, U, U, U, ValueTuple<U>>, ValueTuple<U, U, U, U, U, U, U, ValueTuple<U>>, ValueTuple<U, U, U, U, U, U, U, ValueTuple<U>>> GetCheckMethodSixteen4DataPoint(int index)
+        {
+            return ((inArray1[index], inArray1[index + 1], inArray1[index + 2], inArray1[index + 3], inArray1[index + 4], inArray1[index + 5], inArray1[index + 6], inArray1[index + 7]),
+                    (inArray2[index], inArray2[index + 1], inArray2[index + 2], inArray2[index + 3], inArray2[index + 4], inArray2[index + 5], inArray2[index + 6], inArray2[index + 7]),
+                    (outArray[index], outArray[index + 1], outArray[index + 2], outArray[index + 3], outArray[index + 4], outArray[index + 5], outArray[index + 6], outArray[index + 7]),
+                    (outArray[index + 8], outArray[index + 9], outArray[index + 10], outArray[index + 11], outArray[index + 12], outArray[index + 13], outArray[index + 14], outArray[index + 15]),
+                    (checkArray[index], checkArray[index + 1], checkArray[index + 2], checkArray[index + 3], checkArray[index + 4], checkArray[index + 5], checkArray[index + 6], checkArray[index + 7]),
+                    (checkArray[index + 8], checkArray[index + 9], checkArray[index + 10], checkArray[index + 11], checkArray[index + 12], checkArray[index + 13], checkArray[index + 14], checkArray[index + 15]));
+        }
+
+        public ValueTuple<ValueTuple<T, T, T, T>, ValueTuple<T, T, T, T>, ValueTuple<U, U, U, U>, ValueTuple<U, U, U, U>> GetQuad44DataPoint(int index)
+        {
+            return ((inArray1[index], inArray1[index + 1], inArray1[index + 2], inArray1[index + 3]),
+                    (inArray2[index], inArray2[index + 1], inArray2[index + 2], inArray2[index + 3]),
+                    (outArray[index], outArray[index + 1], outArray[index + 2], outArray[index + 3]),
+                    (checkArray[index], checkArray[index + 1], checkArray[index + 2], checkArray[index + 3]));
+        }
+
+        public ((T, T, T, T, T, T, T, T), (T, T, T, T, T, T, T, T), U, U) GetEightOneDataPoint(int index)
+        {
+            return ((inArray1[index], inArray1[index + 1], inArray1[index + 2], inArray1[index + 3], inArray1[index + 4], inArray1[index + 5], inArray1[index + 6], inArray1[index + 7]),
+                    (inArray2[index], inArray2[index + 1], inArray2[index + 2], inArray2[index + 3], inArray2[index + 4], inArray2[index + 5], inArray2[index + 6], inArray2[index + 7]),
+                    outArray[index], checkArray[index]);
+        }
+
+        public ((T, T, T, T, T, T, T, T), (T, T, T, T, T, T, T, T), (U, U, U, U, U, U, U, U), (U, U, U, U, U, U, U, U)) GetOcta88DataPoint(int index)
+        {
+            return ((inArray1[index], inArray1[index + 1], inArray1[index + 2], inArray1[index + 3], inArray1[index + 4], inArray1[index + 5], inArray1[index + 6], inArray1[index + 7]),
+                    (inArray2[index], inArray2[index + 1], inArray2[index + 2], inArray2[index + 3], inArray2[index + 4], inArray2[index + 5], inArray2[index + 6], inArray2[index + 7]),
+                    (outArray[index], outArray[index + 1], outArray[index + 2], outArray[index + 3], outArray[index + 4], outArray[index + 5], outArray[index + 6], outArray[index + 7]),
+                    (checkArray[index], checkArray[index + 1], checkArray[index + 2], checkArray[index + 3], checkArray[index + 4], checkArray[index + 5], checkArray[index + 6], checkArray[index + 7]));
+        }
+
+        public ((T, T, T, T, T, T, T, T), (T, T, T, T, T, T, T, T), (T, T, T, T, T, T, T, T), (T, T, T, T, T, T, T, T), (U, U, U, U, U, U, U, U), (U, U, U, U, U, U, U, U), (U, U, U, U, U, U, U, U), (U, U, U, U, U, U, U, U)) GetHexadecaDataPoint(int index)
+        {
+            return ((inArray1[index], inArray1[index + 1], inArray1[index + 2], inArray1[index + 3], inArray1[index + 4], inArray1[index + 5], inArray1[index + 6], inArray1[index + 7]),
+                    (inArray1[index + 8], inArray1[index + 9], inArray1[index + 10], inArray1[index + 11], inArray1[index + 12], inArray1[index + 13], inArray1[index + 14], inArray1[index + 15]),
+                    (inArray2[index], inArray2[index + 1], inArray2[index + 2], inArray2[index + 3], inArray2[index + 4], inArray2[index + 5], inArray2[index + 6], inArray2[index + 7]),
+                    (inArray2[index + 8], inArray2[index + 9], inArray2[index + 10], inArray2[index + 11], inArray2[index + 12], inArray2[index + 13], inArray2[index + 14], inArray2[index + 15]),
+                    (outArray[index], outArray[index + 1], outArray[index + 2], outArray[index + 3], outArray[index + 4], outArray[index + 5], outArray[index + 6], outArray[index + 7]),
+                    (outArray[index + 8], outArray[index + 9], outArray[index + 10], outArray[index + 11], outArray[index + 12], outArray[index + 13], outArray[index + 14], outArray[index + 15]),
+                    (checkArray[index], checkArray[index + 1], checkArray[index + 2], checkArray[index + 3], checkArray[index + 4], checkArray[index + 5], checkArray[index + 6], checkArray[index + 7]),
+                    (checkArray[index + 8], checkArray[index + 9], checkArray[index + 10], checkArray[index + 11], checkArray[index + 12], checkArray[index + 13], checkArray[index + 14], checkArray[index + 15]));
+        }
+
+        public static TestTableSse2<T, U> Create(int lengthInVectors, double tSizeMultiplier = 1.0)
+        {
+           return new TestTableSse2<T, U>(lengthInVectors, tSizeMultiplier);
+        }
+
+        public TestTableSse2(int lengthInVectors, double tSizeMultiplier = 1.0, double uSizeMultiplier = 1.0, bool initialize = true)
+        {
+            _tSize = Marshal.SizeOf<T>();
+            int length = _stepSize / _tSize * lengthInVectors;
+            inArray1 = new T[(int)(length * (1 / uSizeMultiplier))];
+            inArray2 = new T[(int)(length * (1 / uSizeMultiplier))];
+            outArray = new U[(int)(length * (1/ tSizeMultiplier))];
+            checkArray = new U[(int)(length * (1 / tSizeMultiplier))];
+            _index = 0;
+            _inHandle1 = GCHandle.Alloc(inArray1, GCHandleType.Pinned);
+            _inHandle2 = GCHandle.Alloc(inArray2, GCHandleType.Pinned);
+            _outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned);
+            _checkHandle = GCHandle.Alloc(checkArray, GCHandleType.Pinned);
+            if (initialize)
+            {
+                Initialize();
+            }
+        }
+
+        public void Initialize()
+        {
+            Initialize(InitMode.Undefined);
+        }
+
+        public void Initialize(InitMode mode = InitMode.Undefined)
+        {
+            if (mode == InitMode.Undefined)
+            {
+                Random random = new Random(unchecked((int)(DateTime.UtcNow.Ticks & 0x00000000ffffffffl)));
+                if (inArray1 is double[])
+                {
+                    var array1 = inArray1 as double[];
+                    var array2 = inArray2 as double[];
+                    for (int i = 0; i < array1.Length; i++)
+                    {
+                        array1[i] = random.NextDouble() * random.Next();
+                        array2[i] = random.NextDouble() * random.Next();
+                    }
+                }
+                else if (inArray1 is float[])
+                {
+                    var arrayFloat1 = inArray1 as float[];
+                    var arrayFloat2 = inArray2 as float[];
+                    for (int i = 0; i < arrayFloat1.Length; i++)
+                    {
+                        arrayFloat1[i] = (float)(random.NextDouble() * random.Next(ushort.MaxValue));
+                        arrayFloat2[i] = (float)(random.NextDouble() * random.Next(ushort.MaxValue));
+                    }
+                }
+                else
+                {
+                    random.NextBytes(new Span<byte>(((byte*)InArray1Ptr), inArray1.Length * _tSize));
+                    random.NextBytes(new Span<byte>(((byte*)InArray2Ptr), inArray2.Length * _tSize));
+                }
+            }
+            else if (mode == InitMode.NumberFirstVectors)
+            {
+                InitializeWithVectorNumbering();
+            }
+        }
+
+        private void InitializeWithVectorNumbering()
+        {
+            Type baseType = typeof(T);
+            if (inArray1 is double[] doubleArray1)
+            {
+                double[] doubleArray2 = inArray2 as double[];
+                for (double i = 0.0, j = 10000.0; i < doubleArray1.Length; i++, j++)
+                {
+                    doubleArray1[(int)i] = i;
+                    doubleArray2[(int)i] = j;
+                }
+            }
+            else if (inArray1 is float[] floatArray1)
+            {
+                float[] floatArray2 = inArray2 as float[];
+                for (float i = 0.0f, j = 10000.0f; i < floatArray1.Length; i++, j++)
+                {
+                    floatArray1[(int)i] = i;
+                    floatArray2[(int)i] = j;
+                }
+            }
+            else if (inArray1 is byte[] byteArray1)
+            {
+                byte[] byteArray2 = inArray2 as byte[];
+                for (byte i = 0, j = 100; i < byteArray1.Length; i++, j++)
+                {
+                    byteArray1[i] = i;
+                    byteArray2[i] = j;
+                }
+            }
+            else if (inArray1 is sbyte[] sbyteArray1)
+            {
+                sbyte[] sbyteArray2 = inArray2 as sbyte[];
+                for (sbyte i = 0, j = 100; i < sbyteArray1.Length; i++, j++)
+                {
+                    sbyteArray1[i] = i;
+                    sbyteArray2[i] = j;
+                }
+            }
+            else if (inArray1 is short[] shortArray1)
+            {
+                short[] shortArray2 = inArray2 as short[];
+                for (short i = 0, j = 10000; i < shortArray1.Length; i++, j++)
+                {
+                    shortArray1[i] = i;
+                    shortArray2[i] = j;
+                }
+
+            }
+            else if (inArray1 is ushort[] ushortArray1)
+            {
+                ushort[] ushortArray2 = inArray2 as ushort[];
+                for (ushort i = 0, j = 10000; i < ushortArray1.Length; i++, j++)
+                {
+                    ushortArray1[i] = i;
+                    ushortArray2[i] = j;
+                }
+            }
+            else if (inArray1 is int[] intArray1)
+            {
+                int[] intArray2 = inArray2 as int[];
+                for (int i = 0, j = 10000; i < intArray1.Length; i++, j++)
+                {
+                    intArray1[i] = i;
+                    intArray2[i] = j;
+                }
+            }
+            else if (inArray1 is uint[] uintArray1)
+            {
+                uint[] uintArray2 = inArray2 as uint[];
+                for (uint i = 0, j = 10000; i < uintArray1.Length; i++, j++)
+                {
+                    uintArray1[i] = i;
+                    uintArray2[i] = j;
+                }
+            }
+            else if (inArray1 is long[] longArray1)
+            {
+                long[] longArray2 = inArray2 as long[];
+                for (long i = 0, j = 10000; i < longArray1.Length; i++, j++)
+                {
+                    longArray1[i] = i;
+                    longArray2[i] = j;
+                }
+            }
+            else if (inArray1 is ulong[] ulongArray1)
+            {
+                ulong[] ulongArray2 = inArray2 as ulong[];
+                for (uint i = 0, j = 10000; i < ulongArray1.Length; i++, j++)
+                {
+                    ulongArray1[i] = i;
+                    ulongArray2[i] = j;
+                }
+            }
+        }
+
+        public bool CheckResult(CheckMethodTwo<T, U> check)
+        {
+            bool result = true;
+            for (int i = 0; i < inArray1.Length; i++)
+            {
+                if (!check(inArray1[i], inArray2[i], outArray[i], ref checkArray[i]))
+                {
+                    result = false;
+                }
+            }
+            return result;
+        }
+
+        public bool CheckResult(CheckMethodThree<T, U> check)
+        {
+            bool result = true;
+            for (int i = 0; i < inArray1.Length - 1; i+=2)
+            {
+                if (!check(inArray1[i], inArray1[i+1], inArray2[i], inArray2[i+1], outArray[i], ref checkArray[i]))
+                {
+                    result = false;
+                }
+            }
+            return result;
+        }
+
+        public bool CheckPackSaturate(CheckMethodFour<T, U> check)
+        {
+            bool result = true;
+            for (int i = 0, j = 0; j < outArray.Length - 1 && i < inArray1.Length; i++, j += 2)
+            {
+                if (!check(inArray1[i], inArray2[i], outArray[j], outArray[j + 1], ref checkArray[j], ref checkArray[j + 1]))
+                {
+                    result = false;
+                }
+            }
+            return result;
+        }
+
+
+        public bool CheckConvertDoubleToVector128Single(CheckMethodFour<T, U> check)
+        {
+            bool result = true;
+            for (int i = 0, j = 0; j < outArray.Length - 3 && i < inArray1.Length - 1; i += 2, j += 4)
+            {
+                if (!check(inArray1[i], inArray1[i + 1], outArray[j], outArray[j + 1], ref checkArray[j], ref checkArray[j + 1]))
+                {
+                    result = false;
+                }
+            }
+            return result;
+        }
+
+        public bool CheckConvertInt32ToVector128Single(CheckMethodFour<T, U> check)
+        {
+            bool result = true;
+            for (int i = 0, j = 0; i < inArray1.Length - 3; i += 2, j += 2)
+            {
+                if (!check(inArray1[i], inArray1[i + 1], outArray[j], outArray[j + 1], ref checkArray[j], ref checkArray[j + 1]))
+                {
+                    result = false;
+                }
+            }
+            return result;
+        }
+
+        public bool CheckConvertDoubleToVector128Int32(CheckMethodFour<T, U> check)
+        {
+            bool result = true;
+            for (int i = 0, j = 0; i < inArray1.Length - 1 && j < outArray.Length - 3; i += 2, j += 4)
+            {
+                if (!check(inArray1[i], inArray1[i + 1], outArray[j], outArray[j + 1], ref checkArray[j], ref checkArray[j + 1]))
+                {
+                    result = false;
+                }
+            }
+            return result;
+        }
+
+        public bool CheckConvertToVector128Double(CheckMethodFour<T, U> check)
+        {
+            bool result = true;
+            for (int i = 0, j = 0; i < inArray1.Length - 3; i += 4, j += 2)
+            {
+                if (!check(inArray1[i], inArray1[i + 1], outArray[j], outArray[j+1], ref checkArray[j], ref checkArray[j+1]))
+                {
+                    result = false;
+                }
+            }
+            return result;
+        }
+
+        public bool CheckUnpack(CheckMethodFourTFourU<T, U> check)
+        {
+            bool result = true;
+            for (int i = 0, j = 0; j < outArray.Length - 3 && i < inArray1.Length - 3; i += 4, j += 4)
+            {
+                if (!check(
+                    (inArray1[i], inArray1[i+1], inArray1[i+2], inArray1[i+3]),
+                    (inArray2[i], inArray2[i + 1], inArray2[i + 2], inArray2[i + 3]),
+                    (outArray[j], outArray[j + 1], outArray[j + 2], outArray[j + 3]),
+                    ref checkArray[j], ref checkArray[j + 1], ref checkArray[j + 2], ref checkArray[j + 3]))
+                {
+                    result = false;
+                }
+            }
+            return result;
+        }
+
+        public bool CheckMultiplyUInt32ToUInt64(CheckMethodFive<T, U> check)
+        {
+            bool result = true;
+            int i = 0, j = 0;
+            for (; i < inArray1.Length - 3 && j < outArray.Length - 1; i += 4, j += 2)
+            {
+                if (!check(inArray1[i], inArray1[i + 2], inArray2[i], inArray2[i + 2], outArray[j], outArray[j + 1], ref checkArray[j], ref checkArray[j + 1]))
+                {
+                    result = false;
+                }
+            }
+            return result;
+        }
+
+        public bool CheckUnpackHiDouble(CheckMethodFive<T, U> check)
+        {
+            bool result = true;
+            int i = 0, j = 0;
+            for (; i < inArray1.Length - 1 && j < outArray.Length - 1; i += 2, j += 2)
+            {
+                if (!check(inArray1[i], inArray1[i + 1], inArray2[i], inArray2[i + 1], outArray[j], outArray[j + 1], ref checkArray[j], ref checkArray[j + 1]))
+                {
+                    result = false;
+                }
+            }
+            return result;
+        }
+
+        public bool CheckMultiplyHorizontalAdd(CheckMethodThree<T, U> check)
+        {
+            bool result = true;
+            for (int i = 0, j = 0; i < inArray1.Length - 1; i += 2, j++)
+            {
+                if (!check(inArray1[i], inArray1[i + 1], inArray2[i], inArray2[i + 1], outArray[j], ref checkArray[j]))
+                {
+                    result = false;
+                }
+            }
+            return result;
+        }
+
+        public bool CheckPackSaturate(CheckMethodSix<T, U> check)
+        {
+            bool result = true;
+            for (int i = 0, j = 0; i < inArray1.Length - 3 & j < outArray.Length - 7; i += 4, j += 8)
+            {
+                bool test = check(
+                    (inArray1[i], inArray1[i+1], inArray1[i+2], inArray1[i+3]),
+                    (inArray2[i], inArray2[i+1], inArray2[i+2], inArray2[i+3]),
+                    (outArray[j], outArray[j+1], outArray[j+2], outArray[j+3],
+                    outArray[j+4], outArray[j+5], outArray[j+6], outArray[j+7]),
+                    ref checkArray[j], ref checkArray[j+1], ref checkArray[j+2], ref checkArray[j+3],
+                    ref checkArray[j+4], ref checkArray[j+5], ref checkArray[j+6], ref checkArray[j+7]
+                );
+
+                if (!test)
+                {
+                    result = false;
+                }
+            }
+            return result;
+        }
+
+        public bool CheckResult(CheckMethodEightOne<T, U> check)
+        {
+            bool result = true;
+            for (int i = 0, j = 0; i < inArray1.Length - 7 & j < outArray.Length; i += 8, j += 1)
+            {
+                Span<T> x = new Span<T>(inArray1, i, 8);
+                Span<T> y = new Span<T>(inArray2, i, 8);
+
+                if (!check(x, y, outArray[j], ref checkArray[j]))
+                {
+                    result = false;
+                }
+            }
+            return result;
+        }
+
+        public bool CheckUnpack(CheckMethodEightOfTEightOfU<T, U> check)
+        {
+            bool result = true;
+            for (int i = 0, j = 0; i < inArray1.Length - 7 & j < outArray.Length - 7; i += 8, j += 8)
+            {
+                bool test = check(
+                    (inArray1[i], inArray1[i + 1], inArray1[i + 2], inArray1[i + 3], inArray1[i + 4], inArray1[i + 5], inArray1[i + 6], inArray1[i + 7]),
+                    (inArray2[i], inArray2[i + 1], inArray2[i + 2], inArray2[i + 3], inArray2[i + 4], inArray2[i + 5], inArray2[i + 6], inArray2[i + 7]),
+                    (outArray[j], outArray[j + 1], outArray[j + 2], outArray[j + 3], outArray[j + 4], outArray[j + 5], outArray[j + 6], outArray[j + 7]),
+                    ref checkArray[j], ref checkArray[j + 1], ref checkArray[j + 2], ref checkArray[j + 3],
+                    ref checkArray[j + 4], ref checkArray[j + 5], ref checkArray[j + 6], ref checkArray[j + 7]
+                );
+
+                if (!test)
+                {
+                    result = false;
+                }
+            }
+            return result;
+        }
+
+        public bool CheckPackSaturate(CheckMethodSixteen<T, U> check)
+        {
+            bool result = true;
+            for (int i = 0, j = 0; i < inArray1.Length - 7 & j < outArray.Length - 15; i += 8, j += 16)
+            {
+                bool test = check(
+                    (inArray1[i], inArray1[i + 1], inArray1[i + 2], inArray1[i + 3], inArray1[i + 4], inArray1[i + 5], inArray1[i + 6], inArray1[i + 7]),
+                    (inArray2[i], inArray2[i + 1], inArray2[i + 2], inArray2[i + 3], inArray2[i + 4], inArray2[i + 5], inArray2[i + 6], inArray2[i + 7]),
+                    (outArray[j], outArray[j + 1], outArray[j + 2], outArray[j + 3], outArray[j + 4], outArray[j + 5], outArray[j + 6], outArray[j + 7]),
+                    (outArray[j + 8], outArray[j + 9], outArray[j + 10], outArray[j + 11], outArray[j + 12], outArray[j + 13], outArray[j + 14], outArray[j + 15]),
+                    ref checkArray[j], ref checkArray[j + 1], ref checkArray[j + 2], ref checkArray[j + 3],
+                    ref checkArray[j + 4], ref checkArray[j + 5], ref checkArray[j + 6], ref checkArray[j + 7],
+                    ref checkArray[j + 8], ref checkArray[j + 9], ref checkArray[j + 10], ref checkArray[j + 11],
+                    ref checkArray[j + 12], ref checkArray[j + 13], ref checkArray[j + 14], ref checkArray[j + 15]
+                );
+
+                if (!test)
+                {
+                    result = false;
+                }
+            }
+            return result;
+        }
+
+        public bool CheckUnpack(CheckMethodSixteenOfAll<T, U> check)
+        {
+            bool result = true;
+            for (int i = 0, j = 0; i < inArray1.Length - 15 & j < outArray.Length - 15; i += 16, j += 16)
+            {
+                bool test = check(
+                    (inArray1[i], inArray1[i + 1], inArray1[i + 2], inArray1[i + 3], inArray1[i + 4], inArray1[i + 5], inArray1[i + 6], inArray1[i + 7]),
+                    (inArray1[i + 8], inArray1[i + 9], inArray1[i + 10], inArray1[i + 11], inArray1[i + 12], inArray1[i + 13], inArray1[i + 14], inArray1[i + 15]),
+                    (inArray2[i], inArray2[i + 1], inArray2[i + 2], inArray2[i + 3], inArray2[i + 4], inArray2[i + 5], inArray2[i + 6], inArray2[i + 7]),
+                    (inArray2[i + 8], inArray2[i + 9], inArray2[i + 10], inArray2[i + 11], inArray2[i + 12], inArray2[i + 13], inArray2[i + 14], inArray2[i + 15]),
+                    (outArray[j], outArray[j + 1], outArray[j + 2], outArray[j + 3], outArray[j + 4], outArray[j + 5], outArray[j + 6], outArray[j + 7]),
+                    (outArray[j + 8], outArray[j + 9], outArray[j + 10], outArray[j + 11], outArray[j + 12], outArray[j + 13], outArray[j + 14], outArray[j + 15]),
+                    ref checkArray[j], ref checkArray[j + 1], ref checkArray[j + 2], ref checkArray[j + 3],
+                    ref checkArray[j + 4], ref checkArray[j + 5], ref checkArray[j + 6], ref checkArray[j + 7],
+                    ref checkArray[j + 8], ref checkArray[j + 9], ref checkArray[j + 10], ref checkArray[j + 11],
+                    ref checkArray[j + 12], ref checkArray[j + 13], ref checkArray[j + 14], ref checkArray[j + 15]
+                );
+
+                if (!test)
+                {
+                    result = false;
+                }
+            }
+            return result;
+        }
+
+        public void Dispose()
+        {
+            _inHandle1.Free();
+            _inHandle2.Free();
+            _outHandle.Free();
+            _checkHandle.Free();
+        }
+    }
+
+    public unsafe struct TestTableTuvSse2<T, U, V> : IDisposable where T : struct where U : struct where V : struct
+    {
+        private const int _stepSize = 16;
+        private int _tSize;
+
+        private GCHandle _inHandle1;
+        private GCHandle _inHandle2;
+        private GCHandle _outHandle;
+        private GCHandle _checkHandle;
+
+        private int _index;
+
+        public T[] inArray1;
+        public V[] inArray2;
+        public U[] outArray;
+        public U[] checkArray;
+
+        public void* InArray1Ptr => _inHandle1.AddrOfPinnedObject().ToPointer();
+        public void* InArray2Ptr => _inHandle2.AddrOfPinnedObject().ToPointer();
+        public void* OutArrayPtr => _outHandle.AddrOfPinnedObject().ToPointer();
+        public void* CheckArrayPtr => _checkHandle.AddrOfPinnedObject().ToPointer();
+
+        public Vector128<T> Vector1 => Unsafe.Read<Vector128<T>>((byte*)InArray1Ptr + (_index * _stepSize));
+        public Vector128<V> Vector2 => Unsafe.Read<Vector128<V>>((byte*)InArray2Ptr + (_index * _stepSize));
+        public Vector128<U> Vector3 => Unsafe.Read<Vector128<U>>((byte*)OutArrayPtr + (_index * _stepSize));
+        public Vector128<U> Vector4 => Unsafe.Read<Vector128<U>>((byte*)CheckArrayPtr + (_index * _stepSize));
+
+        public int Index { get => _index; set => _index = value; }
+
+        public void SetOutArray(Vector128<T> value, int index = -1)
+        {
+            index = index < 0 ? _index : index;
+            Unsafe.Write((byte*)OutArrayPtr + (_index * _stepSize), value);
+        }
+
+        public Vector128<T> this[int index]
+        {
+            get
+            {
+                _index = index;
+                return Vector1;
+            }
+        }
+
+        public ValueTuple<T, V, U, U> GetQuad4DataPoint(int index)
+        {
+            var value3 = Unsafe.Read<U>((byte*)OutArrayPtr + (_index * _stepSize));
+            var value4 = Unsafe.Read<U>((byte*)CheckArrayPtr + (_index * _stepSize));
+            return (inArray1[index], inArray2[index], value3, value4);
+        }
+
+        public unsafe ValueTuple<T, V, U, U> GetQuad22DataPoint(int index)
+        {
+            return (inArray1[index], inArray2[index], outArray[index], checkArray[index]);
+        }
+
+        public ValueTuple<T, T, V, V, U, U> GetHexa42DataPoint(int index)
+        {
+            return (inArray1[index], inArray1[index + 1], inArray2[index], inArray2[index + 1], outArray[index], checkArray[index]);
+        }
+
+        public ValueTuple<T, T, U, U, U, U> GetHexa24DataPoint(int index)
+        {
+            return (inArray1[index], inArray1[index + 1], outArray[index], outArray[index + 1], checkArray[index], checkArray[index + 1]);
+        }
+
+        public ValueTuple<T, T, V, V, U, U, U, ValueTuple<U>> GetOcta44DataPoint(int index)
+        {
+            return new ValueTuple<T, T, V, V, U, U, U, ValueTuple<U>>(inArray1[index], inArray1[index + 2], inArray2[index], inArray2[index + 2],
+                outArray[index], outArray[index + 1], checkArray[index], new ValueTuple<U>(checkArray[index + 1]));
+        }
+
+        public ValueTuple<ValueTuple<T, T, T, T>, ValueTuple<V, V, V, V>, ValueTuple<U, U, U, U, U, U, U, ValueTuple<U>>, ValueTuple<U, U, U, U, U, U, U, ValueTuple<U>>> GetCheckMethodSix4DataPoint(int index)
+        {
+            return ((inArray1[index], inArray1[index + 1], inArray1[index + 2], inArray1[index + 3]),
+                (inArray2[index], inArray2[index + 1], inArray2[index + 2], inArray2[index + 3]),
+                (outArray[index], outArray[index + 1], outArray[index + 2], outArray[index + 3],
+                outArray[index + 4], outArray[index + 5], outArray[index + 6], (outArray[index + 7])),
+                (checkArray[index], checkArray[index + 1], checkArray[index + 2], checkArray[index + 3],
+                checkArray[index + 4], checkArray[index + 5], checkArray[index + 6], (checkArray[index + 7])));
+        }
+
+        public ValueTuple<ValueTuple<T, T, T, T, T, T, T, ValueTuple<T>>, ValueTuple<V, V, V, V, V, V, V, ValueTuple<V>>, ValueTuple<U, U, U, U, U, U, U, ValueTuple<U>>, ValueTuple<U, U, U, U, U, U, U, ValueTuple<U>>, ValueTuple<U, U, U, U, U, U, U, ValueTuple<U>>, ValueTuple<U, U, U, U, U, U, U, ValueTuple<U>>> GetCheckMethodSixteen4DataPoint(int index)
+        {
+            return ((inArray1[index], inArray1[index + 1], inArray1[index + 2], inArray1[index + 3], inArray1[index + 4], inArray1[index + 5], inArray1[index + 6], inArray1[index + 7]),
+                    (inArray2[index], inArray2[index + 1], inArray2[index + 2], inArray2[index + 3], inArray2[index + 4], inArray2[index + 5], inArray2[index + 6], inArray2[index + 7]),
+                    (outArray[index], outArray[index + 1], outArray[index + 2], outArray[index + 3], outArray[index + 4], outArray[index + 5], outArray[index + 6], outArray[index + 7]),
+                    (outArray[index + 8], outArray[index + 9], outArray[index + 10], outArray[index + 11], outArray[index + 12], outArray[index + 13], outArray[index + 14], outArray[index + 15]),
+                    (checkArray[index], checkArray[index + 1], checkArray[index + 2], checkArray[index + 3], checkArray[index + 4], checkArray[index + 5], checkArray[index + 6], checkArray[index + 7]),
+                    (checkArray[index + 8], checkArray[index + 9], checkArray[index + 10], checkArray[index + 11], checkArray[index + 12], checkArray[index + 13], checkArray[index + 14], checkArray[index + 15]));
+        }
+
+        public ValueTuple<ValueTuple<T, T, T, T>, ValueTuple<V, V, V, V>, ValueTuple<U, U, U, U>, ValueTuple<U, U, U, U>> GetQuad44DataPoint(int index)
+        {
+            return ((inArray1[index], inArray1[index + 1], inArray1[index + 2], inArray1[index + 3]),
+                    (inArray2[index], inArray2[index + 1], inArray2[index + 2], inArray2[index + 3]),
+                    (outArray[index], outArray[index + 1], outArray[index + 2], outArray[index + 3]),
+                    (checkArray[index], checkArray[index + 1], checkArray[index + 2], checkArray[index + 3]));
+        }
+
+        public ((T, T, T, T, T, T, T, T), (V, V, V, V, V, V, V, V), (U, U, U, U, U, U, U, U), (U, U, U, U, U, U, U, U)) GetOcta88DataPoint(int index)
+        {
+            return ((inArray1[index], inArray1[index + 1], inArray1[index + 2], inArray1[index + 3], inArray1[index + 4], inArray1[index + 5], inArray1[index + 6], inArray1[index + 7]),
+                    (inArray2[index], inArray2[index + 1], inArray2[index + 2], inArray2[index + 3], inArray2[index + 4], inArray2[index + 5], inArray2[index + 6], inArray2[index + 7]),
+                    (outArray[index], outArray[index + 1], outArray[index + 2], outArray[index + 3], outArray[index + 4], outArray[index + 5], outArray[index + 6], outArray[index + 7]),
+                    (checkArray[index], checkArray[index + 1], checkArray[index + 2], checkArray[index + 3], checkArray[index + 4], checkArray[index + 5], checkArray[index + 6], checkArray[index + 7]));
+        }
+
+        public ((T, T, T, T, T, T, T, T), (T, T, T, T, T, T, T, T), (V, V, V, V, V, V, V, V), (V, V, V, V, V, V, V, V), (U, U, U, U, U, U, U, U), (U, U, U, U, U, U, U, U), (U, U, U, U, U, U, U, U), (U, U, U, U, U, U, U, U)) GetHexadecaDataPoint(int index)
+        {
+            return ((inArray1[index], inArray1[index + 1], inArray1[index + 2], inArray1[index + 3], inArray1[index + 4], inArray1[index + 5], inArray1[index + 6], inArray1[index + 7]),
+                    (inArray1[index + 8], inArray1[index + 9], inArray1[index + 10], inArray1[index + 11], inArray1[index + 12], inArray1[index + 13], inArray1[index + 14], inArray1[index + 15]),
+                    (inArray2[index], inArray2[index + 1], inArray2[index + 2], inArray2[index + 3], inArray2[index + 4], inArray2[index + 5], inArray2[index + 6], inArray2[index + 7]),
+                    (inArray2[index + 8], inArray2[index + 9], inArray2[index + 10], inArray2[index + 11], inArray2[index + 12], inArray2[index + 13], inArray2[index + 14], inArray2[index + 15]),
+                    (outArray[index], outArray[index + 1], outArray[index + 2], outArray[index + 3], outArray[index + 4], outArray[index + 5], outArray[index + 6], outArray[index + 7]),
+                    (outArray[index + 8], outArray[index + 9], outArray[index + 10], outArray[index + 11], outArray[index + 12], outArray[index + 13], outArray[index + 14], outArray[index + 15]),
+                    (checkArray[index], checkArray[index + 1], checkArray[index + 2], checkArray[index + 3], checkArray[index + 4], checkArray[index + 5], checkArray[index + 6], checkArray[index + 7]),
+                    (checkArray[index + 8], checkArray[index + 9], checkArray[index + 10], checkArray[index + 11], checkArray[index + 12], checkArray[index + 13], checkArray[index + 14], checkArray[index + 15]));
+        }
+
+        public static TestTableTuvSse2<T, U, V> Create(int lengthInVectors, double tSizeMultiplier = 1.0)
+        {
+            return new TestTableTuvSse2<T, U, V>(lengthInVectors, tSizeMultiplier);
+        }
+
+        public TestTableTuvSse2(int lengthInVectors, double tSizeMultiplier = 1.0, double uSizeMultiplier = 1.0, bool initialize = true)
+        {
+            _tSize = Marshal.SizeOf<T>();
+            int length = _stepSize / _tSize * lengthInVectors;
+            inArray1 = new T[(int)(length * (1 / uSizeMultiplier))];
+            inArray2 = new V[(int)(length * (1 / uSizeMultiplier))];
+            outArray = new U[(int)(length * (1 / tSizeMultiplier))];
+            checkArray = new U[(int)(length * (1 / tSizeMultiplier))];
+            _index = 0;
+            _inHandle1 = GCHandle.Alloc(inArray1, GCHandleType.Pinned);
+            _inHandle2 = GCHandle.Alloc(inArray2, GCHandleType.Pinned);
+            _outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned);
+            _checkHandle = GCHandle.Alloc(checkArray, GCHandleType.Pinned);
+            if (initialize)
+            {
+                Initialize();
+            }
+        }
+
+        public void Initialize()
+        {
+            Initialize(InitMode.Undefined);
+        }
+
+        public void Initialize(InitMode mode = InitMode.Undefined)
+        {
+            if (mode == InitMode.Undefined)
+            {
+                Random random = new Random(unchecked((int)(DateTime.UtcNow.Ticks & 0x00000000ffffffffl)));
+                if (inArray1 is double[])
+                {
+                    var array1 = inArray1 as double[];
+                    for (int i = 0; i < array1.Length; i++)
+                    {
+                        array1[i] = random.NextDouble() * random.Next();
+                    }
+                }
+                else if (inArray1 is float[])
+                {
+                    var arrayFloat1 = inArray1 as float[];
+                    for (int i = 0; i < arrayFloat1.Length; i++)
+                    {
+                        arrayFloat1[i] = (float)(random.NextDouble() * random.Next(ushort.MaxValue));
+                    }
+                }
+                else
+                {
+                    random.NextBytes(new Span<byte>(((byte*)InArray1Ptr), inArray1.Length * _tSize));
+                }
+            }
+            else if (mode == InitMode.NumberFirstVectors)
+            {
+                InitializeWithVectorNumbering();
+            }
+        }
+
+        private void InitializeWithVectorNumbering()
+        {
+            Type baseType = typeof(T);
+            if (inArray1 is double[] doubleArray1)
+            {
+                for (double i = 0.0, j = 10000.0; i < doubleArray1.Length; i++, j++)
+                {
+                    doubleArray1[(int)i] = i;
+                }
+            }
+            else if (inArray1 is float[] floatArray1)
+            {
+                for (float i = 0.0f, j = 10000.0f; i < floatArray1.Length; i++, j++)
+                {
+                    floatArray1[(int)i] = i;
+                }
+            }
+            else if (inArray1 is byte[] byteArray1)
+            {
+                for (byte i = 0, j = 100; i < byteArray1.Length; i++, j++)
+                {
+                    byteArray1[i] = i;
+                }
+            }
+            else if (inArray1 is sbyte[] sbyteArray1)
+            {
+                for (sbyte i = 0, j = 100; i < sbyteArray1.Length; i++, j++)
+                {
+                    sbyteArray1[i] = i;
+                }
+            }
+            else if (inArray1 is short[] shortArray1)
+            {
+                for (short i = 0, j = 10000; i < shortArray1.Length; i++, j++)
+                {
+                    shortArray1[i] = i;
+                }
+
+            }
+            else if (inArray1 is ushort[] ushortArray1)
+            {
+                for (ushort i = 0, j = 10000; i < ushortArray1.Length; i++, j++)
+                {
+                    ushortArray1[i] = i;
+                }
+            }
+            else if (inArray1 is int[] intArray1)
+            {
+                for (int i = 0, j = 10000; i < intArray1.Length; i++, j++)
+                {
+                    intArray1[i] = i;
+                }
+            }
+            else if (inArray1 is uint[] uintArray1)
+            {
+                for (uint i = 0, j = 10000; i < uintArray1.Length; i++, j++)
+                {
+                    uintArray1[i] = i;
+                }
+            }
+            else if (inArray1 is long[] longArray1)
+            {
+                for (long i = 0, j = 10000; i < longArray1.Length; i++, j++)
+                {
+                    longArray1[i] = i;
+                }
+            }
+            else if (inArray1 is ulong[] ulongArray1)
+            {
+                for (uint i = 0, j = 10000; i < ulongArray1.Length; i++, j++)
+                {
+                    ulongArray1[i] = i;
+                }
+            }
+        }
+
+        public bool CheckResult(CheckMethodTwo<T, U, V> check)
+        {
+            bool result = true;
+            for (int i = 0; i < inArray1.Length; i++)
+            {
+                if (!check(inArray1[i], inArray2[i], outArray[i], ref checkArray[i]))
+                {
+                    result = false;
+                }
+            }
+            return result;
+        }
+
+        public void Dispose()
+        {
+            _inHandle1.Free();
+            _inHandle2.Free();
+            _outHandle.Free();
+            _checkHandle.Free();
+        }
+    }
+
+    public unsafe struct TestTableImmSse2<T, U, V> : IDisposable where T : struct where U : struct where V : struct
+    {
+        private const int _stepSize = 16;
+        private int _tSize;
+
+        private GCHandle _inHandle1;
+        private GCHandle _inHandle2;
+        private GCHandle _immHandle;
+        private GCHandle _outHandle;
+        private GCHandle _checkHandle;
+
+        private int _index;
+
+        public T[] inArray1;
+        public T[] inArray2;
+        public V[] immArray;
+        public U[] outArray;
+        public U[] checkArray;
+
+        public void* InArray1Ptr => _inHandle1.AddrOfPinnedObject().ToPointer();
+        public void* InArray2Ptr => _inHandle2.AddrOfPinnedObject().ToPointer();
+        public void* ImmArrayPtr => _inHandle2.AddrOfPinnedObject().ToPointer();
+        public void* OutArrayPtr => _outHandle.AddrOfPinnedObject().ToPointer();
+        public void* CheckArrayPtr => _checkHandle.AddrOfPinnedObject().ToPointer();
+
+        public Vector128<T> Vector1 => Unsafe.Read<Vector128<T>>((byte*)InArray1Ptr + (_index * _stepSize));
+        public T Value => Unsafe.Read<T>((byte*)InArray2Ptr + (_index));
+        public V Immediate => Unsafe.Read<V>((byte*)ImmArrayPtr + (_index));
+        public Vector128<U> Vector3 => Unsafe.Read<Vector128<U>>((byte*)OutArrayPtr + (_index * _stepSize));
+        public Vector128<U> Vector4 => Unsafe.Read<Vector128<U>>((byte*)CheckArrayPtr + (_index * _stepSize));
+
+        public int Index { get => _index; set => _index = value; }
+
+        public void SetOutArray(Vector128<T> value, int index = -1)
+        {
+            index = index < 0 ? _index : index;
+            Unsafe.Write((byte*)OutArrayPtr + (_index * _stepSize), value);
+        }
+
+        public (Vector128<T>, T) this[int index]
+        {
+            get
+            {
+                _index = index;
+                return (Vector1, Value);
+            }
+        }
+
+        public ((T, T, T, T, T, T, T, T), T, V, (U, U, U, U, U, U, U, U), (U, U, U, U, U, U, U, U)) GetOctaImmDataPoint(int index)
+        {
+            return ((inArray1[index], inArray1[index + 1], inArray1[index + 2], inArray1[index + 3], inArray1[index + 4], inArray1[index + 5], inArray1[index + 6], inArray1[index + 7]),
+                    inArray2[index/8], immArray[index/8],
+                    (outArray[index], outArray[index + 1], outArray[index + 2], outArray[index + 3], outArray[index + 4], outArray[index + 5], outArray[index + 6], outArray[index + 7]),
+                    (checkArray[index], checkArray[index + 1], checkArray[index + 2], checkArray[index + 3], checkArray[index + 4], checkArray[index + 5], checkArray[index + 6], checkArray[index + 7]));
+        }
+
+        public static TestTableImmSse2<T, U, V> Create(int lengthInVectors, double tSizeMultiplier = 1.0)
+        {
+            return new TestTableImmSse2<T, U, V>(lengthInVectors, tSizeMultiplier);
+        }
+
+        public TestTableImmSse2(int lengthInVectors, double tSizeMultiplier = 1.0, bool initialize = true)
+        {
+            _tSize = Marshal.SizeOf<T>();
+            int length = _stepSize / _tSize * lengthInVectors;
+            inArray1 = new T[length];
+            inArray2 = new T[lengthInVectors];
+            immArray = new V[lengthInVectors];
+            outArray = new U[(int)(length * (1 / tSizeMultiplier))];
+            checkArray = new U[(int)(length * (1 / tSizeMultiplier))];
+            _index = 0;
+            _inHandle1 = GCHandle.Alloc(inArray1, GCHandleType.Pinned);
+            _inHandle2 = GCHandle.Alloc(inArray2, GCHandleType.Pinned);
+            _immHandle = GCHandle.Alloc(inArray2, GCHandleType.Pinned);
+            _outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned);
+            _checkHandle = GCHandle.Alloc(checkArray, GCHandleType.Pinned);
+            if (initialize)
+            {
+                Initialize();
+            }
+        }
+
+        public void Initialize()
+        {
+            Initialize(InitMode.Undefined);
+        }
+
+        public void Initialize(InitMode mode = InitMode.Undefined)
+        {
+            if (mode == InitMode.Undefined)
+            {
+                Random random = new Random(unchecked((int)(DateTime.UtcNow.Ticks & 0x00000000ffffffffl)));
+                if (inArray1 is double[])
+                {
+                    var array1 = inArray1 as double[];
+                    for (int i = 0; i < array1.Length; i++)
+                    {
+                        array1[i] = random.NextDouble() * random.Next();
+                    }
+                }
+                else if (inArray1 is float[])
+                {
+                    var arrayFloat1 = inArray1 as float[];
+                    for (int i = 0; i < arrayFloat1.Length; i++)
+                    {
+                        arrayFloat1[i] = (float)(random.NextDouble() * random.Next(ushort.MaxValue));
+                    }
+                }
+                else
+                {
+                    random.NextBytes(new Span<byte>(((byte*)InArray1Ptr), inArray1.Length * _tSize));
+                }
+            }
+            else if (mode == InitMode.NumberFirstVectors)
+            {
+                InitializeWithVectorNumbering();
+            }
+        }
+
+        private void InitializeWithVectorNumbering()
+        {
+            Type baseType = typeof(T);
+            if (inArray1 is double[] doubleArray1)
+            {
+                for (double i = 0.0, j = 10000.0; i < doubleArray1.Length; i++, j++)
+                {
+                    doubleArray1[(int)i] = i;
+                }
+            }
+            else if (inArray1 is float[] floatArray1)
+            {
+                for (float i = 0.0f, j = 10000.0f; i < floatArray1.Length; i++, j++)
+                {
+                    floatArray1[(int)i] = i;
+                }
+            }
+            else if (inArray1 is byte[] byteArray1)
+            {
+                for (byte i = 0, j = 100; i < byteArray1.Length; i++, j++)
+                {
+                    byteArray1[i] = i;
+                }
+            }
+            else if (inArray1 is sbyte[] sbyteArray1)
+            {
+                for (sbyte i = 0, j = 100; i < sbyteArray1.Length; i++, j++)
+                {
+                    sbyteArray1[i] = i;
+                }
+            }
+            else if (inArray1 is short[] shortArray1)
+            {
+                for (short i = 0, j = 10000; i < shortArray1.Length; i++, j++)
+                {
+                    shortArray1[i] = i;
+                }
+
+            }
+            else if (inArray1 is ushort[] ushortArray1)
+            {
+                for (ushort i = 0, j = 10000; i < ushortArray1.Length; i++, j++)
+                {
+                    ushortArray1[i] = i;
+                }
+            }
+            else if (inArray1 is int[] intArray1)
+            {
+                for (int i = 0, j = 10000; i < intArray1.Length; i++, j++)
+                {
+                    intArray1[i] = i;
+                }
+            }
+            else if (inArray1 is uint[] uintArray1)
+            {
+                for (uint i = 0, j = 10000; i < uintArray1.Length; i++, j++)
+                {
+                    uintArray1[i] = i;
+                }
+            }
+            else if (inArray1 is long[] longArray1)
+            {
+                for (long i = 0, j = 10000; i < longArray1.Length; i++, j++)
+                {
+                    longArray1[i] = i;
+                }
+            }
+            else if (inArray1 is ulong[] ulongArray1)
+            {
+                for (uint i = 0, j = 10000; i < ulongArray1.Length; i++, j++)
+                {
+                    ulongArray1[i] = i;
+                }
+            }
+        }
+
+        public bool CheckResultImm(CheckMethodEightImm<T, U, V> check)
+        {
+            bool result = true;
+            for (int i = 0; i < inArray1.Length; i++)
+            {
+                int elNo = _stepSize / _tSize;
+                if (!check(
+                    new Span<T>(inArray1, Index * elNo, elNo),
+                    inArray2[i], immArray[i],
+                    new Span<U>(outArray, Index * elNo, elNo),
+                    new Span<U>(checkArray, Index * elNo, elNo)))
+                {
+                    result = false;
+                }
+            }
+            return result;
+        }
+
+        public void Dispose()
+        {
+            _inHandle1.Free();
+            _inHandle2.Free();
+            _immHandle.Free();
+            _outHandle.Free();
+            _checkHandle.Free();
+        }
+    }
+
+    public enum SpecialCheck
+    {
+        Undefined = 0,
+        Sse2MultiplyHorizontalAdd = 1,
+    }
+
+    internal static partial class Program
+    {
+        private static void PrintErrorHeaderTu<T>(string functionName, string testFuncString) where T : struct
+        {
+            Console.WriteLine($"{typeof(Sse2)}.{functionName} failed on {typeof(T)}:");
+            Console.WriteLine($"Test function: {testFuncString}");
+            Console.WriteLine($"{ typeof(Sse2)}.{functionName} test tuples:");
+        }
+
+        private static void PrintErrorHeaderTuv<T, V>(string functionName, string testFuncString) where T : struct where V : struct
+        {
+            Console.WriteLine($"{typeof(Sse2)}.{functionName} failed on {typeof(T)}.{typeof(V)}:");
+            Console.WriteLine($"Test function: {testFuncString}");
+            Console.WriteLine($"{ typeof(Sse2)}.{functionName} test tuples:");
+        }
+
+        private static void PrintError<T>(TestTableSse2<T> testTable, string functionName = "", string testFuncString = "",
+            CheckMethod<T> check = null) where T : struct
+        {
+            PrintErrorHeaderTu<T>(functionName, testFuncString);
+            for (int i = 0; i < testTable.outArray.Length; i++)
+            {
+                (T, T, T, T) item = testTable.GetDataPoint(i);
+                Console.Write(
+                    $"({(item)})" +
+                    (check != null ? $"->{check(item.Item1, item.Item2, item.Item3, ref item.Item4)}, " : ", "));
+            }
+            Console.WriteLine("\n");
+        }
+
+        private static void PrintError<T, U>(TestTableSse2<T, U> testTable, string functionName = "", string testFuncString = "",
+            CheckMethodTwo<T, U> check = null) where T : struct where U : struct
+        {
+            PrintErrorHeaderTu<T>(functionName, testFuncString);
+            for (int i = 0; i < testTable.outArray.Length; i++)
+            {
+                (T, T, U, U) item = testTable.GetQuad22DataPoint(i);
+                Console.Write($"({(item)})" + (check != null ? $"->{check(item.Item1, item.Item2, item.Item3, ref item.Item4)}, " : ", "));
+            }
+            Console.WriteLine();
+        }
+
+        private static void PrintError<T, U, V>(TestTableTuvSse2<T, U, V> testTable, string functionName = "", string testFuncString = "",
+            CheckMethodTwo<T, U, V> check = null) where T : struct where U : struct where V : struct
+        {
+            PrintErrorHeaderTuv<T,V>(functionName, testFuncString);
+            for (int i = 0; i < testTable.outArray.Length; i++)
+            {
+                (T, V, U, U) item = testTable.GetQuad22DataPoint(i);
+                Console.Write( $"({item})" + (check != null ? $"->{check(item.Item1, item.Item2, item.Item3, ref item.Item4)}, " : ", "));
+            }
+            Console.WriteLine();
+        }
+
+        private static void PrintError<T, U>(TestTableSse2<T, U> testTable, string functionName = "", string testFuncString = "",
+            CheckMethodThree<T, U> check = null) where T : struct where U : struct
+        {
+            PrintErrorHeaderTu<T>(functionName, testFuncString);
+            for (int i = 0; i < testTable.inArray1.Length - 1; i += 2)
+            {
+                (T, T, T, T, U, U) item = testTable.GetHexa42DataPoint(i);
+                Console.Write(
+                    $"({(item)})" +
+                    (check != null ? $"->{check(item.Item1, item.Item2, item.Item3, item.Item4, item.Item5, ref item.Item6)}, " : ", "));
+            }
+            Console.WriteLine();
+        }
+
+        private static void PrintError<T, U>(TestTableSse2<T, U> testTable, string functionName = "", string testFuncString = "",
+            CheckMethodFour<T, U> check = null) where T : struct where U : struct
+        {
+            PrintErrorHeaderTu<T>(functionName, testFuncString);
+            for (int i = 0; i < testTable.inArray1.Length - 1; i += 2)
+            {
+                (T, T, U, U, U, U) item = testTable.GetHexa24DataPoint(i);
+                Console.Write(
+                    $"({(item)})" +
+                    (check != null ? $"->{check(item.Item1, item.Item2, item.Item3, item.Item4, ref item.Item5, ref item.Item6)}, " : ", "));
+            }
+            Console.WriteLine();
+        }
+
+        private static void PrintError<T, U>(TestTableSse2<T, U> testTable, string functionName = "", string testFuncString = "",
+            CheckMethodFourTFourU<T, U> check = null) where T : struct where U : struct
+        {
+            PrintErrorHeaderTu<T>(functionName, testFuncString);
+            for (int i = 0; i < testTable.inArray1.Length - 1; i += 2)
+            {
+                // ((T, T, T, T), (T, T, T, T), (U, U, U, U), (U, U, U, U))
+                var item = testTable.GetQuad44DataPoint(i);
+                Console.Write(
+                    $"(x{item.Item1}, y{item.Item2}, z{item.Item3}, a{item.Item4} " +
+                    (check != null ? (string) $"->{check(item.Item1, item.Item2, item.Item3, ref item.Item4.Item1, ref item.Item4.Item1, ref item.Item4.Item1, ref item.Item4.Item1)}, " : ", "));
+            }
+            Console.WriteLine();
+        }
+
+        private static void PrintError<T, U>(TestTableSse2<T, U> testTable, string functionName = "", string testFuncString = "",
+            CheckMethodFive<T, U> check = null) where T : struct where U : struct
+        {
+            PrintErrorHeaderTu<T>(functionName, testFuncString);
+            for (int i = 0, j = 0; i < testTable.inArray1.Length - 4 && j < testTable.outArray.Length - 2; i += 4, j += 2)
+            {
+                // (T, T, T, T, U, U, U, U)
+                var item = testTable.GetOcta44DataPoint(i);
+                Console.Write(
+                    $"({(item)})" +
+                    (check != null ? $"->{check(item.Item1, item.Item2, item.Item3, item.Item4, item.Item5, item.Item6, ref item.Item7, ref item.Item8)}, " : ", "));
+            }
+            Console.WriteLine();
+        }
+
+        private static void PrintError<T, U>(TestTableSse2<T, U> testTable, string functionName = "", string testFuncString = "",
+            CheckMethodSix<T, U> check = null) where T : struct where U : struct
+        {
+            PrintErrorHeaderTu<T>(functionName, testFuncString);
+            for (int i = 0, j = 0; i < testTable.inArray1.Length - 4 && j < testTable.outArray.Length - 2; i += 4, j += 2)
+            {
+                // ((T, T, T, T), (T, T, T, T), (U, U, U, U, U, U, U, U), (U, U, U, U, U, U, U, U))
+                var item = testTable.GetCheckMethodSix4DataPoint(i);
+                Console.Write($"( x({item.Item1}), y({item.Item2}), z({item.Item3}), a({item.Item4}))");
+            }
+            Console.WriteLine();
+        }
+
+        private static void PrintError<T, U>(TestTableSse2<T, U> testTable, string functionName = "", string testFuncString = "",
+            CheckMethodEightOne<T, U> check = null) where T : struct where U : struct
+        {
+            PrintErrorHeaderTu<T>(functionName, testFuncString);
+            for (int i = 0, j = 0; i < testTable.inArray1.Length - 4 && j < testTable.outArray.Length - 2; i += 4, j += 2)
+            {
+                // ((T, T, T, T, T, T, T, T), (T, T, T, T, T, T, T, T), U, U)
+                var item = testTable.GetCheckMethodSix4DataPoint(i);
+                Console.Write($"( x({item.Item1}), y({item.Item2}), z({item.Item3}), a({item.Item4}))");
+            }
+            Console.WriteLine();
+        }
+
+        private static void PrintError<T, U, V>(TestTableImmSse2<T, U, V> testTable, string functionName = "", string testFuncString = "",
+            CheckMethodEightImm<T, U, V> check = null) where T : struct where U : struct where V : struct
+        {
+            PrintErrorHeaderTu<T>(functionName, testFuncString);
+            for (int i = 0, j = 0; i < testTable.inArray1.Length - 7 && j < testTable.inArray2.Length; i += 8, j += 1)
+            {
+                // ((T, T, T, T, T, T, T, T), T, V, (U, U, U, U, U, U, U, U), (U, U, U, U, U, U, U, U))
+                var item = testTable.GetOctaImmDataPoint(i);
+                Console.Write($"({item})");
+            }
+            Console.WriteLine();
+        }
+
+        private static void PrintError<T, U>(TestTableSse2<T, U> testTable, string functionName = "", string testFuncString = "",
+            CheckMethodEightOfTEightOfU<T, U> check = null) where T : struct where U : struct
+        {
+            PrintErrorHeaderTu<T>(functionName, testFuncString);
+            for (int i = 0, j = 0; i < testTable.inArray1.Length - 4 && j < testTable.outArray.Length - 2; i += 4, j += 2)
+            {
+                // ((T, T, T, T, T, T, T, T), (T, T, T, T, T, T, T, T), (U, U, U, U, U, U, U, U), (U, U, U, U, U, U, U, U))
+                var item = testTable.GetOcta88DataPoint(i);
+                Console.Write($"( x({item.Item1}), y({item.Item2}), z({item.Item3}), a({item.Item4})))");
+            }
+            Console.WriteLine();
+        }
+
+        private static void PrintError<T, U>(TestTableSse2<T, U> testTable, string functionName = "", string testFuncString = "",
+            CheckMethodSixteen<T, U> check = null) where T : struct where U : struct
+        {
+            PrintErrorHeaderTu<T>(functionName, testFuncString);
+            for (int i = 0, j = 0; i < testTable.inArray1.Length - 4 && j < testTable.outArray.Length - 2; i += 4, j += 2)
+            {
+                // ((T, T, T, T), (T, T, T, T), (U, U, U, U, U, U, U, U), (U, U, U, U, U, U, U, U))
+                var item = testTable.GetCheckMethodSixteen4DataPoint(i);
+                Console.Write($"( x({item.Item1}), y({item.Item2}), z1({item.Item3}), z2({item.Item4}), a1({item.Item5}), a2({item.Item6}))");
+            }
+            Console.WriteLine();
+        }
+
+        private static void PrintError<T, U>(TestTableSse2<T, U> testTable, string functionName = "", string testFuncString = "",
+            CheckMethodSixteenOfAll<T, U> check = null) where T : struct where U : struct
+        {
+            PrintErrorHeaderTu<T>(functionName, testFuncString);
+            for (int i = 0, j = 0; i < testTable.inArray1.Length - 4 && j < testTable.outArray.Length - 2; i += 4, j += 2)
+            {
+                // ((T, T, T, T, T, T, T, T), (T, T, T, T, T, T, T, T), (T, T, T, T, T, T, T, T), (T, T, T, T, T, T, T, T),
+                // (U, U, U, U, U, U, U, U), (U, U, U, U, U, U, U, U), (U, U, U, U, U, U, U, U), (U, U, U, U, U, U, U, U))
+                var item = testTable.GetHexadecaDataPoint(i);
+                Console.Write($"( x({item.Item1}), y({item.Item2}), z({item.Item3}), a({item.Item4})))");
+            }
+            Console.WriteLine();
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/UnpackHigh.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/UnpackHigh.cs
new file mode 100644 (file)
index 0000000..768299f
--- /dev/null
@@ -0,0 +1,302 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.UnpackHigh);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double, double>.Create(testsCount, 1.0))
+                using (var longTable = TestTableSse2<long, long>.Create(testsCount, 1.0))
+                using (var ulongTable = TestTableSse2<ulong, ulong>.Create(testsCount, 1.0))
+                using (var intTable = TestTableSse2<int, int>.Create(testsCount, 1.0))
+                using (var uintTable = TestTableSse2<uint, uint>.Create(testsCount, 1.0))
+                using (var shortTable = TestTableSse2<short, short>.Create(testsCount, 1.0))
+                using (var ushortTable = TestTableSse2<ushort, ushort>.Create(testsCount, 1.0))
+                using (var sbyteTable = TestTableSse2<sbyte, sbyte>.Create(testsCount, 1.0))
+                using (var byteTable = TestTableSse2<byte, byte>.Create(testsCount, 1.0))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        Vector128<double> result = Sse2.UnpackHigh(value.Item1, value.Item2);
+                        doubleTable.SetOutArray(result, i);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<long>, Vector128<long>) value = longTable[i];
+                        Vector128<long> result = Sse2.UnpackHigh(value.Item1, value.Item2);
+                        longTable.SetOutArray(result, i);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<ulong>, Vector128<ulong>) value = ulongTable[i];
+                        Vector128<ulong> result = Sse2.UnpackHigh(value.Item1, value.Item2);
+                        ulongTable.SetOutArray(result, i);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<int>, Vector128<int>) value = intTable[i];
+                        Vector128<int> result = Sse2.UnpackHigh(value.Item1, value.Item2);
+                        intTable.SetOutArray(result, i);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<uint>, Vector128<uint>) value = uintTable[i];
+                        Vector128<uint> result = Sse2.UnpackHigh(value.Item1, value.Item2);
+                        uintTable.SetOutArray(result, i);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<short>, Vector128<short>) value = shortTable[i];
+                        Vector128<short> result = Sse2.UnpackHigh(value.Item1, value.Item2);
+                        shortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<ushort>, Vector128<ushort>) value = ushortTable[i];
+                        Vector128<ushort> result = Sse2.UnpackHigh(value.Item1, value.Item2);
+                        ushortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<sbyte>, Vector128<sbyte>) value = sbyteTable[i];
+                        Vector128<sbyte> result = Sse2.UnpackHigh(value.Item1, value.Item2);
+                        sbyteTable.SetOutArray(result, i);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<byte>, Vector128<byte>) value = byteTable[i];
+                        Vector128<byte> result = Sse2.UnpackHigh(value.Item1, value.Item2);
+                        byteTable.SetOutArray(result, i);
+                    }
+
+                    CheckMethodFive<double, double> checkDouble = (double x1, double x2, double y1, double y2, double z1, double z2, ref double a1, ref double a2) =>
+                    {
+                        return (a1 = x2) == z1 && (a2 = y2) == z2;
+                    };
+
+                    if (!doubleTable.CheckUnpackHiDouble(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(double x, double y, double z, ref double a) => (a = BitwiseXor(x, y)) == z", checkDouble);
+                        testResult = Fail;
+                    }
+
+                    CheckMethodFive<long, long> checkLong = (long x1, long x2, long y1, long y2, long z1, long z2, ref long a1, ref long a2) =>
+                    {
+                        return (a1 = x2) == z1 && (a2 = y2) == z2;
+                    };
+
+                    if (!longTable.CheckUnpackHiDouble(checkLong))
+                    {
+                        PrintError(longTable, methodUnderTestName, "(long x, long y, long z, ref long a) => (a = x ^ y) == z", checkLong);
+                        testResult = Fail;
+                    }
+
+                    CheckMethodFive<ulong, ulong> checkUlong = (ulong x1, ulong x2, ulong y1, ulong y2, ulong z1, ulong z2, ref ulong a1, ref ulong a2) =>
+                    {
+                        return (a1 = x2) == z1 && (a2 = y2) == z2;
+                    };
+
+                    if (!longTable.CheckUnpackHiDouble(checkLong))
+                    {
+                        PrintError(ulongTable, methodUnderTestName, "(ulong x1, ulong x2, ulong y1, ulong y2, ulong z1, ulong z2, ref ulong a1, ref ulong a2) => (a1 = x2) == z1 && (a2 = y2) == z2", checkUlong);
+                        testResult = Fail;
+                    }
+
+                    CheckMethodFourTFourU<int, int> checkInt32 =
+                        (ValueTuple<int, int, int, int> x, ValueTuple<int, int, int, int> y,
+                        ValueTuple<int, int, int, int> z,
+                        ref int a1, ref int a2, ref int a3, ref int a4) =>
+                    {
+                        a1 = x.Item3;
+                        a2 = y.Item3;
+                        a3 = x.Item4;
+                        a4 = y.Item4;
+                        return a1 == z.Item1 && a2 == z.Item2 && a3 == z.Item3 && a4 == z.Item4;
+                    };
+
+                    if (!intTable.CheckUnpack(checkInt32))
+                    {
+                        PrintError(intTable, methodUnderTestName, "(int x, int y, int z, ref int a) => (a = x ^ y) == z", checkInt32);
+                        testResult = Fail;
+                    }
+
+                    CheckMethodFourTFourU<uint, uint> checkUInt32 =
+                        (ValueTuple<uint, uint, uint, uint> x, ValueTuple<uint, uint, uint, uint> y,
+                        ValueTuple<uint, uint, uint, uint> z,
+                        ref uint a1, ref uint a2, ref uint a3, ref uint a4) =>
+                        {
+                            a1 = x.Item3;
+                            a2 = y.Item3;
+                            a3 = x.Item4;
+                            a4 = y.Item4;
+                            return a1 == z.Item1 && a2 == z.Item2 && a3 == z.Item3 && a4 == z.Item4;
+                        };
+
+                    if (!uintTable.CheckUnpack(checkUInt32))
+                    {
+                        PrintError(uintTable, methodUnderTestName, "(uint x, uint y, uint z, ref uint a) => (a = x ^ y) == z", checkUInt32);
+                        testResult = Fail;
+                    }
+
+                    CheckMethodEightOfTEightOfU<short, short> checkInt16 =
+                        (ValueTuple<short, short, short, short, short, short, short, ValueTuple<short>> x,
+                        ValueTuple<short, short, short, short, short, short, short, ValueTuple<short>> y,
+                        ValueTuple<short, short, short, short, short, short, short, ValueTuple<short>> z,
+                        ref short a1, ref short a2, ref short a3, ref short a4, ref short a5, ref short a6, ref short a7, ref short a8) =>
+                    {
+                        a1 = x.Item5;
+                        a2 = y.Item5;
+                        a3 = x.Item6;
+                        a4 = y.Item6;
+                        a5 = x.Item7;
+                        a6 = y.Item7;
+                        a7 = x.Item8;
+                        a8 = y.Item8;
+                        return a1 == z.Item1 && a2 == z.Item2 && a3 == z.Item3 && a4 == z.Item4 &&
+                            a5 == z.Item5 && a6 == z.Item6 && a7 == z.Item7 && a8 == z.Item8;
+                    };
+
+                    if (!shortTable.CheckUnpack(checkInt16))
+                    {
+                        PrintError(shortTable, methodUnderTestName, "CheckUnpack(CheckMethodEightOfTEightOfU<short, short>)", checkInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethodEightOfTEightOfU<ushort, ushort> checkUInt16 =
+                        (ValueTuple<ushort, ushort, ushort, ushort, ushort, ushort, ushort, ValueTuple<ushort>> x,
+                        ValueTuple<ushort, ushort, ushort, ushort, ushort, ushort, ushort, ValueTuple<ushort>> y,
+                        ValueTuple<ushort, ushort, ushort, ushort, ushort, ushort, ushort, ValueTuple<ushort>> z,
+                        ref ushort a1, ref ushort a2, ref ushort a3, ref ushort a4, ref ushort a5, ref ushort a6, ref ushort a7, ref ushort a8) =>
+                    {
+                        a1 = x.Item5;
+                        a2 = y.Item5;
+                        a3 = x.Item6;
+                        a4 = y.Item6;
+                        a5 = x.Item7;
+                        a6 = y.Item7;
+                        a7 = x.Item8;
+                        a8 = y.Item8;
+                        return a1 == z.Item1 && a2 == z.Item2 && a3 == z.Item3 && a4 == z.Item4 &&
+                            a5 == z.Item5 && a6 == z.Item6 && a7 == z.Item7 && a8 == z.Item8;
+                    };
+
+                    if (!ushortTable.CheckUnpack(checkUInt16))
+                    {
+                        PrintError(ushortTable, methodUnderTestName, "(ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)(x ^ y)) == z", checkUInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethodSixteenOfAll<sbyte, sbyte> checkSByte =
+                        (ValueTuple<sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, ValueTuple<sbyte>> x1,
+                        ValueTuple<sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, ValueTuple<sbyte>> x,
+                        ValueTuple<sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, ValueTuple<sbyte>> y1,
+                        ValueTuple<sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, ValueTuple<sbyte>> y,
+                        ValueTuple<sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, ValueTuple<sbyte>> z1,
+                        ValueTuple<sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, ValueTuple<sbyte>> z2,
+                        ref sbyte a1, ref sbyte a2, ref sbyte a3, ref sbyte a4, ref sbyte a5, ref sbyte a6, ref sbyte a7, ref sbyte a8,
+                        ref sbyte a9, ref sbyte a10, ref sbyte a11, ref sbyte a12, ref sbyte a13, ref sbyte a14, ref sbyte a15, ref sbyte a16) =>
+                    {
+                        a1 = x.Item1;
+                        a2 = y.Item1;
+                        a3 = x.Item2;
+                        a4 = y.Item2;
+                        a5 = x.Item3;
+                        a6 = y.Item3;
+                        a7 = x.Item4;
+                        a8 = y.Item4;
+                        a9 = x.Item5;
+                        a10 = y.Item5;
+                        a11 = x.Item6;
+                        a12 = y.Item6;
+                        a13 = x.Item7;
+                        a14 = y.Item7;
+                        a15 = x.Item8;
+                        a16 = y.Item8;
+
+                        return a1 == z1.Item1 && a2 == z1.Item2 && a3 == z1.Item3 && a4 == z1.Item4 &&
+                            a5 == z1.Item5 && a6 == z1.Item6 && a7 == z1.Item7 && a8 == z1.Item8 &&
+                            a9 == z2.Item1 && a10 == z2.Item2 && a11 == z2.Item3 && a12 == z2.Item4 &&
+                            a13 == z2.Item5 && a14 == z2.Item6 && a15 == z2.Item7 && a16 == z2.Item8;
+                    };
+
+                    if (!sbyteTable.CheckUnpack(checkSByte))
+                    {
+                        PrintError(sbyteTable, methodUnderTestName, "(sbyte x, sbyte y, sbyte z, ref sbyte a) => (a = (sbyte)(x ^ y)) == z", checkSByte);
+                        testResult = Fail;
+                    }
+
+                    CheckMethodSixteenOfAll<byte, byte> checkByte =
+                        (ValueTuple<byte, byte, byte, byte, byte, byte, byte, ValueTuple<byte>> x1,
+                        ValueTuple<byte, byte, byte, byte, byte, byte, byte, ValueTuple<byte>> x,
+                        ValueTuple<byte, byte, byte, byte, byte, byte, byte, ValueTuple<byte>> y1,
+                        ValueTuple<byte, byte, byte, byte, byte, byte, byte, ValueTuple<byte>> y,
+                        ValueTuple<byte, byte, byte, byte, byte, byte, byte, ValueTuple<byte>> z1,
+                        ValueTuple<byte, byte, byte, byte, byte, byte, byte, ValueTuple<byte>> z2,
+                        ref byte a1, ref byte a2, ref byte a3, ref byte a4, ref byte a5, ref byte a6, ref byte a7, ref byte a8,
+                        ref byte a9, ref byte a10, ref byte a11, ref byte a12, ref byte a13, ref byte a14, ref byte a15, ref byte a16) =>
+                        {
+                            a1 = x.Item1;
+                            a2 = y.Item1;
+                            a3 = x.Item2;
+                            a4 = y.Item2;
+                            a5 = x.Item3;
+                            a6 = y.Item3;
+                            a7 = x.Item4;
+                            a8 = y.Item4;
+                            a9 = x.Item5;
+                            a10 = y.Item5;
+                            a11 = x.Item6;
+                            a12 = y.Item6;
+                            a13 = x.Item7;
+                            a14 = y.Item7;
+                            a15 = x.Item8;
+                            a16 = y.Item8;
+
+                            return a1 == z1.Item1 && a2 == z1.Item2 && a3 == z1.Item3 && a4 == z1.Item4 &&
+                                a5 == z1.Item5 && a6 == z1.Item6 && a7 == z1.Item7 && a8 == z1.Item8 &&
+                                a9 == z2.Item1 && a10 == z2.Item2 && a11 == z2.Item3 && a12 == z2.Item4 &&
+                                a13 == z2.Item5 && a14 == z2.Item6 && a15 == z2.Item7 && a16 == z2.Item8;
+                        };
+
+                    if (!byteTable.CheckUnpack(checkByte))
+                    {
+                        PrintError(byteTable, methodUnderTestName, "(byte x, byte y, byte z, ref byte a) => (a = (byte)(x ^ y)) == z", checkByte);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/UnpackHigh_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/UnpackHigh_r.csproj
new file mode 100644 (file)
index 0000000..634fe52
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{1D430B7E-0A5B-4D0F-8F6F-7138D12FD57E}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="TestTableSse2.cs" />
+    <Compile Include="UnpackHigh.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/UnpackHigh_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/UnpackHigh_ro.csproj
new file mode 100644 (file)
index 0000000..2e94d2a
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{D72FD8F6-CCE9-4026-ABA8-67862FE5ECB8}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="TestTableSse2.cs" />
+    <Compile Include="UnpackHigh.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/UnpackLow.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/UnpackLow.cs
new file mode 100644 (file)
index 0000000..91a716c
--- /dev/null
@@ -0,0 +1,302 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.UnpackLow);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double, double>.Create(testsCount, 1.0))
+                using (var longTable = TestTableSse2<long, long>.Create(testsCount, 1.0))
+                using (var ulongTable = TestTableSse2<ulong, ulong>.Create(testsCount, 1.0))
+                using (var intTable = TestTableSse2<int, int>.Create(testsCount, 1.0))
+                using (var uintTable = TestTableSse2<uint, uint>.Create(testsCount, 1.0))
+                using (var shortTable = TestTableSse2<short, short>.Create(testsCount, 1.0))
+                using (var ushortTable = TestTableSse2<ushort, ushort>.Create(testsCount, 1.0))
+                using (var sbyteTable = TestTableSse2<sbyte, sbyte>.Create(testsCount, 1.0))
+                using (var byteTable = TestTableSse2<byte, byte>.Create(testsCount, 1.0))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        Vector128<double> result = Sse2.UnpackLow(value.Item1, value.Item2);
+                        doubleTable.SetOutArray(result, i);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<long>, Vector128<long>) value = longTable[i];
+                        Vector128<long> result = Sse2.UnpackLow(value.Item1, value.Item2);
+                        longTable.SetOutArray(result, i);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<ulong>, Vector128<ulong>) value = ulongTable[i];
+                        Vector128<ulong> result = Sse2.UnpackLow(value.Item1, value.Item2);
+                        ulongTable.SetOutArray(result, i);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<int>, Vector128<int>) value = intTable[i];
+                        Vector128<int> result = Sse2.UnpackLow(value.Item1, value.Item2);
+                        intTable.SetOutArray(result, i);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<uint>, Vector128<uint>) value = uintTable[i];
+                        Vector128<uint> result = Sse2.UnpackLow(value.Item1, value.Item2);
+                        uintTable.SetOutArray(result, i);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<short>, Vector128<short>) value = shortTable[i];
+                        Vector128<short> result = Sse2.UnpackLow(value.Item1, value.Item2);
+                        shortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<ushort>, Vector128<ushort>) value = ushortTable[i];
+                        Vector128<ushort> result = Sse2.UnpackLow(value.Item1, value.Item2);
+                        ushortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<sbyte>, Vector128<sbyte>) value = sbyteTable[i];
+                        Vector128<sbyte> result = Sse2.UnpackLow(value.Item1, value.Item2);
+                        sbyteTable.SetOutArray(result, i);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<byte>, Vector128<byte>) value = byteTable[i];
+                        Vector128<byte> result = Sse2.UnpackLow(value.Item1, value.Item2);
+                        byteTable.SetOutArray(result, i);
+                    }
+
+                    CheckMethodFive<double, double> checkDouble = (double x1, double x2, double y1, double y2, double z1, double z2, ref double a1, ref double a2) =>
+                    {
+                        return (a1 = x1) == z1 && (a2 = y1) == z2;
+                    };
+
+                    if (!doubleTable.CheckUnpackHiDouble(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(double x, double y, double z, ref double a) => (a = BitwiseXor(x, y)) == z", checkDouble);
+                        testResult = Fail;
+                    }
+
+                    CheckMethodFive<long, long> checkLong = (long x1, long x2, long y1, long y2, long z1, long z2, ref long a1, ref long a2) =>
+                    {
+                        return (a1 = x1) == z1 && (a2 = y1) == z2;
+                    };
+
+                    if (!longTable.CheckUnpackHiDouble(checkLong))
+                    {
+                        PrintError(longTable, methodUnderTestName, "(long x, long y, long z, ref long a) => (a = x ^ y) == z", checkLong);
+                        testResult = Fail;
+                    }
+
+                    CheckMethodFive<ulong, ulong> checkUlong = (ulong x1, ulong x2, ulong y1, ulong y2, ulong z1, ulong z2, ref ulong a1, ref ulong a2) =>
+                    {
+                        return (a1 = x1) == z1 && (a2 = y1) == z2;
+                    };
+
+                    if (!longTable.CheckUnpackHiDouble(checkLong))
+                    {
+                        PrintError(ulongTable, methodUnderTestName, "(ulong x1, ulong x2, ulong y1, ulong y2, ulong z1, ulong z2, ref ulong a1, ref ulong a2) => (a1 = x2) == z1 && (a2 = y2) == z2", checkUlong);
+                        testResult = Fail;
+                    }
+
+                    CheckMethodFourTFourU<int, int> checkInt32 =
+                        (ValueTuple<int, int, int, int> x, ValueTuple<int, int, int, int> y,
+                        ValueTuple<int, int, int, int> z,
+                        ref int a1, ref int a2, ref int a3, ref int a4) =>
+                        {
+                            a1 = x.Item1;
+                            a2 = y.Item1;
+                            a3 = x.Item2;
+                            a4 = y.Item2;
+                            return a1 == z.Item1 && a2 == z.Item2 && a3 == z.Item3 && a4 == z.Item4;
+                        };
+
+                    if (!intTable.CheckUnpack(checkInt32))
+                    {
+                        PrintError(intTable, methodUnderTestName, "(int x, int y, int z, ref int a) => (a = x ^ y) == z", checkInt32);
+                        testResult = Fail;
+                    }
+
+                    CheckMethodFourTFourU<uint, uint> checkUInt32 =
+                        (ValueTuple<uint, uint, uint, uint> x, ValueTuple<uint, uint, uint, uint> y,
+                        ValueTuple<uint, uint, uint, uint> z,
+                        ref uint a1, ref uint a2, ref uint a3, ref uint a4) =>
+                        {
+                            a1 = x.Item1;
+                            a2 = y.Item1;
+                            a3 = x.Item2;
+                            a4 = y.Item2;
+                            return a1 == z.Item1 && a2 == z.Item2 && a3 == z.Item3 && a4 == z.Item4;
+                        };
+
+                    if (!uintTable.CheckUnpack(checkUInt32))
+                    {
+                        PrintError(uintTable, methodUnderTestName, "(uint x, uint y, uint z, ref uint a) => (a = x ^ y) == z", checkUInt32);
+                        testResult = Fail;
+                    }
+
+                    CheckMethodEightOfTEightOfU<short, short> checkInt16 =
+                        (ValueTuple<short, short, short, short, short, short, short, ValueTuple<short>> x,
+                        ValueTuple<short, short, short, short, short, short, short, ValueTuple<short>> y,
+                        ValueTuple<short, short, short, short, short, short, short, ValueTuple<short>> z,
+                        ref short a1, ref short a2, ref short a3, ref short a4, ref short a5, ref short a6, ref short a7, ref short a8) =>
+                        {
+                            a1 = x.Item1;
+                            a2 = y.Item1;
+                            a3 = x.Item2;
+                            a4 = y.Item2;
+                            a5 = x.Item3;
+                            a6 = y.Item3;
+                            a7 = x.Item4;
+                            a8 = y.Item4;
+                            return a1 == z.Item1 && a2 == z.Item2 && a3 == z.Item3 && a4 == z.Item4 &&
+                                a5 == z.Item5 && a6 == z.Item6 && a7 == z.Item7 && a8 == z.Item8;
+                        };
+
+                    if (!shortTable.CheckUnpack(checkInt16))
+                    {
+                        PrintError(shortTable, methodUnderTestName, "CheckUnpack(CheckMethodEightOfTEightOfU<short, short>)", checkInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethodEightOfTEightOfU<ushort, ushort> checkUInt16 =
+                        (ValueTuple<ushort, ushort, ushort, ushort, ushort, ushort, ushort, ValueTuple<ushort>> x,
+                        ValueTuple<ushort, ushort, ushort, ushort, ushort, ushort, ushort, ValueTuple<ushort>> y,
+                        ValueTuple<ushort, ushort, ushort, ushort, ushort, ushort, ushort, ValueTuple<ushort>> z,
+                        ref ushort a1, ref ushort a2, ref ushort a3, ref ushort a4, ref ushort a5, ref ushort a6, ref ushort a7, ref ushort a8) =>
+                        {
+                            a1 = x.Item1;
+                            a2 = y.Item1;
+                            a3 = x.Item2;
+                            a4 = y.Item2;
+                            a5 = x.Item3;
+                            a6 = y.Item3;
+                            a7 = x.Item4;
+                            a8 = y.Item4;
+                            return a1 == z.Item1 && a2 == z.Item2 && a3 == z.Item3 && a4 == z.Item4 &&
+                                a5 == z.Item5 && a6 == z.Item6 && a7 == z.Item7 && a8 == z.Item8;
+                        };
+
+                    if (!ushortTable.CheckUnpack(checkUInt16))
+                    {
+                        PrintError(ushortTable, methodUnderTestName, "(ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)(x ^ y)) == z", checkUInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethodSixteenOfAll<sbyte, sbyte> checkSByte =
+                        (ValueTuple<sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, ValueTuple<sbyte>> x,
+                        ValueTuple<sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, ValueTuple<sbyte>> x1,
+                        ValueTuple<sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, ValueTuple<sbyte>> y,
+                        ValueTuple<sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, ValueTuple<sbyte>> y1,
+                        ValueTuple<sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, ValueTuple<sbyte>> z1,
+                        ValueTuple<sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, sbyte, ValueTuple<sbyte>> z2,
+                        ref sbyte a1, ref sbyte a2, ref sbyte a3, ref sbyte a4, ref sbyte a5, ref sbyte a6, ref sbyte a7, ref sbyte a8,
+                        ref sbyte a9, ref sbyte a10, ref sbyte a11, ref sbyte a12, ref sbyte a13, ref sbyte a14, ref sbyte a15, ref sbyte a16) =>
+                        {
+                            a1 = x.Item1;
+                            a2 = y.Item1;
+                            a3 = x.Item2;
+                            a4 = y.Item2;
+                            a5 = x.Item3;
+                            a6 = y.Item3;
+                            a7 = x.Item4;
+                            a8 = y.Item4;
+                            a9 = x.Item5;
+                            a10 = y.Item5;
+                            a11 = x.Item6;
+                            a12 = y.Item6;
+                            a13 = x.Item7;
+                            a14 = y.Item7;
+                            a15 = x.Item8;
+                            a16 = y.Item8;
+
+                            return a1 == z1.Item1 && a2 == z1.Item2 && a3 == z1.Item3 && a4 == z1.Item4 &&
+                                a5 == z1.Item5 && a6 == z1.Item6 && a7 == z1.Item7 && a8 == z1.Item8 &&
+                                a9 == z2.Item1 && a10 == z2.Item2 && a11 == z2.Item3 && a12 == z2.Item4 &&
+                                a13 == z2.Item5 && a14 == z2.Item6 && a15 == z2.Item7 && a16 == z2.Item8;
+                        };
+
+                    if (!sbyteTable.CheckUnpack(checkSByte))
+                    {
+                        PrintError(sbyteTable, methodUnderTestName, "(sbyte x, sbyte y, sbyte z, ref sbyte a) => (a = (sbyte)(x ^ y)) == z", checkSByte);
+                        testResult = Fail;
+                    }
+
+                    CheckMethodSixteenOfAll<byte, byte> checkByte =
+                        (ValueTuple<byte, byte, byte, byte, byte, byte, byte, ValueTuple<byte>> x,
+                        ValueTuple<byte, byte, byte, byte, byte, byte, byte, ValueTuple<byte>> x1,
+                        ValueTuple<byte, byte, byte, byte, byte, byte, byte, ValueTuple<byte>> y,
+                        ValueTuple<byte, byte, byte, byte, byte, byte, byte, ValueTuple<byte>> y1,
+                        ValueTuple<byte, byte, byte, byte, byte, byte, byte, ValueTuple<byte>> z1,
+                        ValueTuple<byte, byte, byte, byte, byte, byte, byte, ValueTuple<byte>> z2,
+                        ref byte a1, ref byte a2, ref byte a3, ref byte a4, ref byte a5, ref byte a6, ref byte a7, ref byte a8,
+                        ref byte a9, ref byte a10, ref byte a11, ref byte a12, ref byte a13, ref byte a14, ref byte a15, ref byte a16) =>
+                        {
+                            a1 = x.Item1;
+                            a2 = y.Item1;
+                            a3 = x.Item2;
+                            a4 = y.Item2;
+                            a5 = x.Item3;
+                            a6 = y.Item3;
+                            a7 = x.Item4;
+                            a8 = y.Item4;
+                            a9 = x.Item5;
+                            a10 = y.Item5;
+                            a11 = x.Item6;
+                            a12 = y.Item6;
+                            a13 = x.Item7;
+                            a14 = y.Item7;
+                            a15 = x.Item8;
+                            a16 = y.Item8;
+
+                            return a1 == z1.Item1 && a2 == z1.Item2 && a3 == z1.Item3 && a4 == z1.Item4 &&
+                                a5 == z1.Item5 && a6 == z1.Item6 && a7 == z1.Item7 && a8 == z1.Item8 &&
+                                a9 == z2.Item1 && a10 == z2.Item2 && a11 == z2.Item3 && a12 == z2.Item4 &&
+                                a13 == z2.Item5 && a14 == z2.Item6 && a15 == z2.Item7 && a16 == z2.Item8;
+                        };
+
+                    if (!byteTable.CheckUnpack(checkByte))
+                    {
+                        PrintError(byteTable, methodUnderTestName, "(byte x, byte y, byte z, ref byte a) => (a = (byte)(x ^ y)) == z", checkByte);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/UnpackLow_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/UnpackLow_r.csproj
new file mode 100644 (file)
index 0000000..18b3a21
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{FC28F10A-3F47-43E8-AEE5-DFCE881F19EF}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="TestTableSse2.cs" />
+    <Compile Include="UnpackLow.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/UnpackLow_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/UnpackLow_ro.csproj
new file mode 100644 (file)
index 0000000..494f244
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{929ECE5C-8D63-4677-B5A6-C52543F41798}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="TestTableSse2.cs" />
+    <Compile Include="UnpackLow.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.cs
new file mode 100644 (file)
index 0000000..d2788b5
--- /dev/null
@@ -0,0 +1,187 @@
+// 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.
+//
+
+using System;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace IntelHardwareIntrinsicTest
+{
+    internal static partial class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+            int testsCount = 21;
+            string methodUnderTestName = nameof(Sse2.Xor);
+
+            if (Sse2.IsSupported)
+            {
+                using (var doubleTable = TestTableSse2<double>.Create(testsCount))
+                using (var longTable = TestTableSse2<long>.Create(testsCount))
+                using (var ulongTable = TestTableSse2<ulong>.Create(testsCount))
+                using (var intTable = TestTableSse2<int>.Create(testsCount))
+                using (var uintTable = TestTableSse2<uint>.Create(testsCount))
+                using (var shortTable = TestTableSse2<short>.Create(testsCount))
+                using (var ushortTable = TestTableSse2<ushort>.Create(testsCount))
+                using (var sbyteTable = TestTableSse2<sbyte>.Create(testsCount))
+                using (var byteTable = TestTableSse2<byte>.Create(testsCount))
+                {
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<double>, Vector128<double>, Vector128<double>) value = doubleTable[i];
+                        var result = Sse2.Xor(value.Item1, value.Item2);
+                        doubleTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<long>, Vector128<long>, Vector128<long>) value = longTable[i];
+                        var result = Sse2.Xor(value.Item1, value.Item2);
+                        longTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<ulong>, Vector128<ulong>, Vector128<ulong>) value = ulongTable[i];
+                        var result = Sse2.Xor(value.Item1, value.Item2);
+                        ulongTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<int>, Vector128<int>, Vector128<int>) value = intTable[i];
+                        var result = Sse2.Xor(value.Item1, value.Item2);
+                        intTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<uint>, Vector128<uint>, Vector128<uint>) value = uintTable[i];
+                        var result = Sse2.Xor(value.Item1, value.Item2);
+                        uintTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<short>, Vector128<short>, Vector128<short>) value = shortTable[i];
+                        var result = Sse2.Xor(value.Item1, value.Item2);
+                        shortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<ushort>, Vector128<ushort>, Vector128<ushort>) value = ushortTable[i];
+                        var result = Sse2.Xor(value.Item1, value.Item2);
+                        ushortTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<sbyte>, Vector128<sbyte>, Vector128<sbyte>) value = sbyteTable[i];
+                        var result = Sse2.Xor(value.Item1, value.Item2);
+                        sbyteTable.SetOutArray(result);
+                    }
+
+                    for (int i = 0; i < testsCount; i++)
+                    {
+                        (Vector128<byte>, Vector128<byte>, Vector128<byte>) value = byteTable[i];
+                        var result = Sse2.Xor(value.Item1, value.Item2);
+                        byteTable.SetOutArray(result);
+                    }
+
+                    CheckMethod<double> checkDouble = (double x, double y, double z, ref double a) => (a = BitwiseXor(x, y)) == z;
+
+                    if (!doubleTable.CheckResult(checkDouble))
+                    {
+                        PrintError(doubleTable, methodUnderTestName, "(double x, double y, double z, ref double a) => (a = BitwiseXor(x, y)) == z", checkDouble);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<long> checkLong = (long x, long y, long z, ref long a) => (a = x ^ y) == z;
+
+                    if (!longTable.CheckResult(checkLong))
+                    {
+                        PrintError(longTable, methodUnderTestName, "(long x, long y, long z, ref long a) => (a = x ^ y) == z", checkLong);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<ulong> checkUlong = (ulong x, ulong y, ulong z, ref ulong a) => (a = x ^ y) == z;
+
+                    if (!longTable.CheckResult(checkLong))
+                    {
+                        PrintError(ulongTable, methodUnderTestName, "(ulong x, ulong y, ulong z, ref ulong a) => (a = x ^ y) == z", checkUlong);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<int> checkInt32 = (int x, int y, int z, ref int a) => (a = x ^ y) == z;
+
+                    if (!intTable.CheckResult(checkInt32))
+                    {
+                        PrintError(intTable, methodUnderTestName, "(int x, int y, int z, ref int a) => (a = x ^ y) == z", checkInt32);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<uint> checkUInt32 = (uint x, uint y, uint z, ref uint a) => (a = x ^ y) == z;
+
+                    if (!uintTable.CheckResult(checkUInt32))
+                    {
+                        PrintError(uintTable, methodUnderTestName, "(uint x, uint y, uint z, ref uint a) => (a = x ^ y) == z", checkUInt32);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<short> checkInt16 = (short x, short y, short z, ref short a) => (a = (short)(x ^ y)) == z;
+
+                    if (!shortTable.CheckResult(checkInt16))
+                    {
+                        PrintError(shortTable, methodUnderTestName, "(short x, short y, short z, ref short a) => (a = (short)(x ^ y)) == z", checkInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<ushort> checkUInt16 = (ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)(x ^ y)) == z;
+
+                    if (!ushortTable.CheckResult(checkUInt16))
+                    {
+                        PrintError(ushortTable, methodUnderTestName, "(ushort x, ushort y, ushort z, ref ushort a) => (a = (ushort)(x ^ y)) == z", checkUInt16);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<sbyte> checkSByte = (sbyte x, sbyte y, sbyte z, ref sbyte a) => (a = (sbyte)(x ^ y)) == z;
+
+                    if (!sbyteTable.CheckResult(checkSByte))
+                    {
+                        PrintError(sbyteTable, methodUnderTestName, "(sbyte x, sbyte y, sbyte z, ref sbyte a) => (a = (sbyte)(x ^ y)) == z", checkSByte);
+                        testResult = Fail;
+                    }
+
+                    CheckMethod<byte> checkByte = (byte x, byte y, byte z, ref byte a) => (a = (byte)(x ^ y)) == z;
+
+                    if (!byteTable.CheckResult(checkByte))
+                    {
+                        PrintError(byteTable, methodUnderTestName, "(byte x, byte y, byte z, ref byte a) => (a = (byte)(x ^ y)) == z", checkByte);
+                        testResult = Fail;
+                    }
+                }
+            }
+            else
+            {
+                Console.WriteLine($"Sse2.IsSupported: {Sse2.IsSupported}, skipped tests of {typeof(Sse2)}.{methodUnderTestName}");
+            }
+
+            return testResult;
+        }
+
+        public static unsafe double BitwiseXor(double x, double y)
+        {
+            var xUlong = BitConverter.ToUInt64(BitConverter.GetBytes(x));
+            var yUlong = BitConverter.ToUInt64(BitConverter.GetBytes(y));
+            var longAnd = xUlong ^ yUlong;
+            return BitConverter.ToDouble(BitConverter.GetBytes(longAnd));
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor_r.csproj
new file mode 100644 (file)
index 0000000..e354b97
--- /dev/null
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{C2DA0767-1509-4FFE-BC4C-F58FC761413C}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>
+    </Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Xor.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor_ro.csproj
new file mode 100644 (file)
index 0000000..8af5c63
--- /dev/null
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{D926F753-0262-4EE2-BFA2-F0FDA0F51899}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " />
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Xor.cs" />
+    <Compile Include="TestTableSse2.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' ">
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/dir.props b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/dir.props
new file mode 100644 (file)
index 0000000..c2cc135
--- /dev/null
@@ -0,0 +1,6 @@
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Condition="Exists('..\dir.props')" Project="..\dir.props"/>
+  <PropertyGroup>
+    <LangVersion>latest</LangVersion>
+  </PropertyGroup>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/dir.props b/tests/src/JIT/HardwareIntrinsics/X86/dir.props
new file mode 100644 (file)
index 0000000..91c442a
--- /dev/null
@@ -0,0 +1,3 @@
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Condition="Exists('..\dir.props')" Project="..\dir.props"/>
+</Project>
\ No newline at end of file
diff --git a/tests/src/JIT/HardwareIntrinsics/dir.props b/tests/src/JIT/HardwareIntrinsics/dir.props
new file mode 100644 (file)
index 0000000..91c442a
--- /dev/null
@@ -0,0 +1,3 @@
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Condition="Exists('..\dir.props')" Project="..\dir.props"/>
+</Project>
\ No newline at end of file