Merge pull request #16668 from briansull/simd-ins-opt
authorBrian Sullivan <briansul@microsoft.com>
Thu, 1 Mar 2018 23:39:12 +0000 (15:39 -0800)
committerGitHub <noreply@github.com>
Thu, 1 Mar 2018 23:39:12 +0000 (15:39 -0800)
Refactor the signature of genGetSimdInsOpt to use emitAttr

177 files changed:
BuildToolsVersion.txt
Documentation/building/debugging-instructions.md
ILAsmVersion.txt
dependencies.props
src/inc/jithelpers.h
src/jit/hwintrinsiccodegenxarch.cpp
src/jit/hwintrinsiclistxarch.h
src/jit/hwintrinsicxarch.cpp
src/jit/instrsxarch.h
src/mscorlib/shared/System.Private.CoreLib.Shared.projitems
src/mscorlib/shared/System/Collections/Generic/Dictionary.cs
src/mscorlib/shared/System/IO/FileStream.Unix.cs
src/mscorlib/shared/System/IO/FileStream.Windows.cs
src/mscorlib/shared/System/IO/FileStream.cs
src/mscorlib/shared/System/IO/MemoryStream.cs
src/mscorlib/shared/System/IO/PathHelper.Windows.cs
src/mscorlib/shared/System/IO/PathInternal.Unix.cs
src/mscorlib/shared/System/IO/PathInternal.Windows.cs
src/mscorlib/shared/System/IO/PathInternal.cs
src/mscorlib/shared/System/IO/StreamReader.cs
src/mscorlib/shared/System/IO/StreamWriter.cs
src/mscorlib/shared/System/IO/TextReader.cs
src/mscorlib/shared/System/IO/UnmanagedMemoryStream.cs
src/mscorlib/shared/System/IO/UnmanagedMemoryStreamWrapper.cs
src/mscorlib/shared/System/Memory.cs
src/mscorlib/shared/System/MemoryDebugView.cs
src/mscorlib/shared/System/MemoryExtensions.Fast.cs
src/mscorlib/shared/System/MemoryExtensions.cs
src/mscorlib/shared/System/Numerics/Vector.tt
src/mscorlib/shared/System/Runtime/CompilerServices/AsyncValueTaskMethodBuilder.cs
src/mscorlib/shared/System/Runtime/CompilerServices/ConfiguredValueTaskAwaitable.cs
src/mscorlib/shared/System/Runtime/CompilerServices/TypeForwardedFromAttribute.cs
src/mscorlib/shared/System/Runtime/CompilerServices/ValueTaskAwaiter.cs
src/mscorlib/shared/System/Runtime/InteropServices/MemoryMarshal.Fast.cs
src/mscorlib/shared/System/Runtime/InteropServices/MemoryMarshal.cs
src/mscorlib/shared/System/Span.NonGeneric.cs [deleted file]
src/mscorlib/shared/System/Threading/Tasks/Sources/IValueTaskSource.cs [new file with mode: 0644]
src/mscorlib/shared/System/Threading/Tasks/ValueTask.cs
src/mscorlib/src/System/Delegate.cs
src/mscorlib/src/System/IO/Stream.cs
src/mscorlib/src/System/Reflection/Assembly.CoreCLR.cs
src/mscorlib/src/System/Reflection/CustomAttribute.cs
src/mscorlib/src/System/Reflection/RuntimeConstructorInfo.cs
src/mscorlib/src/System/Reflection/RuntimeMethodInfo.cs
src/mscorlib/src/System/Runtime/CompilerServices/AsyncMethodBuilder.cs
src/mscorlib/src/System/Runtime/InteropServices/WindowsRuntime/CustomPropertyImpl.cs
src/mscorlib/src/System/Threading/Thread.cs
src/mscorlib/src/System/Threading/ThreadPool.cs
src/mscorlib/src/System/ThrowHelper.cs
src/vm/array.cpp
src/vm/ceeload.cpp
src/vm/class.cpp
src/vm/codeman.cpp
src/vm/codeman.h
src/vm/comcallablewrapper.cpp
src/vm/compile.cpp
src/vm/comsynchronizable.cpp
src/vm/comsynchronizable.h
src/vm/comthreadpool.cpp
src/vm/comthreadpool.h
src/vm/dataimage.h
src/vm/delegateinfo.h
src/vm/dllimport.cpp
src/vm/ecalllist.h
src/vm/fieldmarshaler.cpp
src/vm/methodtablebuilder.cpp
src/vm/mscorlib.h
src/vm/object.h
src/vm/pefile.cpp
src/vm/peimagelayout.cpp
src/vm/peimagelayout.h
src/vm/stubhelpers.cpp
src/vm/stubhelpers.h
src/zap/zapimage.cpp
src/zap/zapimage.h
src/zap/zaprelocs.h
src/zap/zapwriter.cpp
src/zap/zapwriter.h
tests/issues.targets
tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj
tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj
tests/src/JIT/HardwareIntrinsics/X86/Avx/Blend.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/Blend_r.csproj [moved from tests/src/tracing/eventsourcesmoke/eventsourcesmoke.csproj with 70% similarity]
tests/src/JIT/HardwareIntrinsics/X86/Avx/Blend_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/Ceiling.Double.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/Ceiling.Single.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/DotProduct.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/DotProduct_r.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/DotProduct_ro.csproj [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/Floor.Double.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/Floor.Single.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/Program.Avx.cs
tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundCurrentDirection.Double.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundCurrentDirection.Single.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNearestInteger.Double.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNearestInteger.Single.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNegativeInfinity.Double.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNegativeInfinity.Single.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToPositiveInfinity.Double.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToPositiveInfinity.Single.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToZero.Double.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToZero.Single.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Byte.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Int16.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Int32.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Int64.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.SByte.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.UInt16.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.UInt32.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.UInt64.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Byte.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Int16.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Int32.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Int64.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.SByte.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.UInt16.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.UInt32.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.UInt64.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Byte.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Int16.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Int32.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Int64.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.SByte.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.UInt16.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.UInt32.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.UInt64.cs [new file with mode: 0644]
tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanBinOpTest.template
tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanTwoCmpOpTest.template
tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.Byte.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.Int16.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.Int32.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.Int64.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.SByte.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.UInt16.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.UInt32.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestAllZeros.UInt64.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.Byte.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.Int16.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.Int32.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.Int64.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.SByte.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.UInt16.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.UInt32.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestC.UInt64.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.Byte.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.Int16.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.Int32.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.Int64.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.SByte.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.UInt16.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.UInt32.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestMixOnesZeros.UInt64.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.Byte.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.Int16.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.Int32.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.Int64.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.SByte.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.UInt16.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.UInt32.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestNotZAndNotC.UInt64.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.Byte.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.Int16.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.Int32.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.Int64.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.SByte.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.UInt16.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.UInt32.cs
tests/src/JIT/HardwareIntrinsics/X86/Sse41/TestZ.UInt64.cs
tests/src/dirs.proj
tests/src/tracing/common/Assert.cs
tests/src/tracing/eventpipesmoke/EventPipeSmoke.cs [deleted file]
tests/src/tracing/eventsourcesmoke/EventSourceSmoke.cs [deleted file]
tests/src/tracing/eventsourcetrace/EventSourceTrace.cs
tests/src/tracing/eventsourcetrace/eventsourcetrace.csproj
tests/src/tracing/tracevalidation/rundown/Rundown.cs [new file with mode: 0644]
tests/src/tracing/tracevalidation/rundown/rundown.csproj [moved from tests/src/tracing/eventpipesmoke/eventpipesmoke.csproj with 90% similarity]

index c672ea1..f615e64 100644 (file)
@@ -1 +1 @@
-2.1.0-preview2-02522-03
+2.1.0-preview2-02528-07
index 86ab0f4..84059df 100644 (file)
@@ -1,13 +1,13 @@
 Debugging CoreCLR
 =================
 
-These instructions will lead you through debugging CoreCLR on Windows and Linux. They will be expanded to support OS X when we have good instructions for that.
+These instructions will lead you through debugging CoreCLR on Windows and Linux. They will be expanded to support macOS when we have good instructions for that.
 
 Debugging CoreCLR on Windows
 ============================
 
 1. Perform a build of the repo.
-2. Open Solution \<reporoot\>\bin\obj\Windows_NT.\<platform\>.\<configuration\>\CoreCLR.sln in VS. \<platform\> and \<configuration\> are based
+2. Open solution \<reporoot\>\bin\obj\Windows_NT.\<platform\>.\<configuration\>\CoreCLR.sln in Visual Studio. \<platform\> and \<configuration\> are based
     on type of build you did. By default they are 'x64' and 'Debug'.
 3. Right click the INSTALL project and choose â€˜Set as StartUp Project’
 4. Bring up the properties page for the INSTALL project
index 519d6d5..fb97783 100644 (file)
@@ -1 +1 @@
-2.1.0-preview2-26222-07
+2.1.0-preview2-26228-08
index 3b34fed..1500b48 100644 (file)
 
   <!-- Source of truth for dependency tooling: the commit hash of the dotnet/versions master branch as of the last auto-upgrade. -->
   <PropertyGroup>
-    <CoreFxCurrentRef>327292411fdf51d221596f4ed55f42df7efd6108</CoreFxCurrentRef>
-    <CoreClrCurrentRef>bd49c8985dc365d502ae636cace03708e57b0667</CoreClrCurrentRef>
-    <BuildToolsCurrentRef>4c8b64e5a75c84378f6203d4a40421bd8d5f575b</BuildToolsCurrentRef>
-    <PgoDataCurrentRef>d308636a775b853ed2916ac229d425489f3417b6</PgoDataCurrentRef>
+    <CoreFxCurrentRef>553f30357d08df4ed6d32f70f3478a76f5db79c2</CoreFxCurrentRef>
+    <CoreClrCurrentRef>553f30357d08df4ed6d32f70f3478a76f5db79c2</CoreClrCurrentRef>
+    <BuildToolsCurrentRef>553f30357d08df4ed6d32f70f3478a76f5db79c2</BuildToolsCurrentRef>
+    <PgoDataCurrentRef>553f30357d08df4ed6d32f70f3478a76f5db79c2</PgoDataCurrentRef>
   </PropertyGroup>
 
   <!-- Tests/infrastructure dependency versions. -->
   <PropertyGroup>
-    <MicrosoftPrivateCoreFxNETCoreAppPackageVersion>4.5.0-preview2-26225-02</MicrosoftPrivateCoreFxNETCoreAppPackageVersion>
-    <MicrosoftNETCorePlatformsPackageVersion>2.1.0-preview2-26225-02</MicrosoftNETCorePlatformsPackageVersion>
-    <PgoDataPackageVersion>99.99.99-master-20180226-0052</PgoDataPackageVersion>
-    <MicrosoftNETCoreRuntimeCoreCLRPackageVersion>2.1.0-preview2-26222-07</MicrosoftNETCoreRuntimeCoreCLRPackageVersion>
+    <MicrosoftPrivateCoreFxNETCoreAppPackageVersion>4.5.0-preview2-26228-03</MicrosoftPrivateCoreFxNETCoreAppPackageVersion>
+    <MicrosoftNETCorePlatformsPackageVersion>2.1.0-preview2-26228-03</MicrosoftNETCorePlatformsPackageVersion>
+    <PgoDataPackageVersion>99.99.99-master-20180228-0037</PgoDataPackageVersion>
+    <MicrosoftNETCoreRuntimeCoreCLRPackageVersion>2.1.0-preview2-26228-08</MicrosoftNETCoreRuntimeCoreCLRPackageVersion>
     <XunitPackageVersion>2.2.0-beta2-build3300</XunitPackageVersion>
     <XunitConsoleNetcorePackageVersion>1.0.2-prerelease-00177</XunitConsoleNetcorePackageVersion>
     <XunitPerformanceApiPackageVersion>1.0.0-beta-build0015</XunitPerformanceApiPackageVersion>
@@ -51,7 +51,7 @@
   <!-- Package versions used as toolsets -->
   <PropertyGroup>
     <FeedTasksPackage>Microsoft.DotNet.Build.Tasks.Feed</FeedTasksPackage>
-    <FeedTasksPackageVersion>2.1.0-preview2-02522-03</FeedTasksPackageVersion>
+    <FeedTasksPackageVersion>2.1.0-preview2-02528-07</FeedTasksPackageVersion>
   </PropertyGroup>
 
   <!-- Package dependency verification/auto-upgrade configuration. -->
index 2238aa8..140badf 100644 (file)
 
     // CORINFO_HELP_DBL2INT, CORINFO_HELP_DBL2UINT, and CORINFO_HELP_DBL2LONG get
     // patched for CPUs that support SSE2 (P4 and above).
-#ifndef BIT64
+#ifndef _TARGET_64BIT_
     JITHELPER(CORINFO_HELP_LLSH,                JIT_LLsh,           CORINFO_HELP_SIG_REG_ONLY)
     JITHELPER(CORINFO_HELP_LRSH,                JIT_LRsh,           CORINFO_HELP_SIG_REG_ONLY)
     JITHELPER(CORINFO_HELP_LRSZ,                JIT_LRsz,           CORINFO_HELP_SIG_REG_ONLY)
-#else // !BIT64
+#else // !_TARGET_64BIT_
     JITHELPER(CORINFO_HELP_LLSH,                NULL,               CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB)
     JITHELPER(CORINFO_HELP_LRSH,                NULL,               CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB)
     JITHELPER(CORINFO_HELP_LRSZ,                NULL,               CORINFO_HELP_SIG_CANNOT_USE_ALIGN_STUB)
-#endif // BIT64
+#endif // _TARGET_64BIT_
     JITHELPER(CORINFO_HELP_LMUL,                JIT_LMul,           CORINFO_HELP_SIG_16_STACK)
     JITHELPER(CORINFO_HELP_LMUL_OVF,            JIT_LMulOvf,        CORINFO_HELP_SIG_16_STACK)
     JITHELPER(CORINFO_HELP_ULMUL_OVF,           JIT_ULMulOvf,       CORINFO_HELP_SIG_16_STACK)
index 24829ea..7fda952 100644 (file)
@@ -1226,6 +1226,31 @@ void CodeGen::genAVXIntrinsic(GenTreeHWIntrinsic* node)
             }
             break;
         }
+
+        case NI_AVX_TestC:
+        {
+            emit->emitIns_R_R(INS_xor, EA_4BYTE, targetReg, targetReg);
+            emit->emitIns_R_R(ins, attr, op1->gtRegNum, op2->gtRegNum);
+            emit->emitIns_R(INS_setb, EA_1BYTE, targetReg);
+            break;
+        }
+
+        case NI_AVX_TestNotZAndNotC:
+        {
+            emit->emitIns_R_R(INS_xor, EA_4BYTE, targetReg, targetReg);
+            emit->emitIns_R_R(ins, attr, op1->gtRegNum, op2->gtRegNum);
+            emit->emitIns_R(INS_seta, EA_1BYTE, targetReg);
+            break;
+        }
+
+        case NI_AVX_TestZ:
+        {
+            emit->emitIns_R_R(INS_xor, EA_4BYTE, targetReg, targetReg);
+            emit->emitIns_R_R(ins, attr, op1->gtRegNum, op2->gtRegNum);
+            emit->emitIns_R(INS_sete, EA_1BYTE, targetReg);
+            break;
+        }
+
         default:
             unreached();
             break;
index cc4710a..e14bbd1 100644 (file)
@@ -313,18 +313,22 @@ HARDWARE_INTRINSIC(SSE42_CompareGreaterThan,                         "CompareGre
 //                                                                                                                                                                            {TYP_BYTE,      TYP_UBYTE,     TYP_SHORT,     TYP_USHORT,    TYP_INT,       TYP_UINT,      TYP_LONG,      TYP_ULONG,     TYP_FLOAT,     TYP_DOUBLE}
 // ************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************
 //  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_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_AddSubtract,                                  "AddSubtract",                                      AVX,        -1,           32,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_addsubps,  INS_addsubpd},          HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)                 
 HARDWARE_INTRINSIC(AVX_And,                                          "And",                                              AVX,        -1,           32,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_andps,     INS_andpd},             HW_Category_SimpleSIMD,                        HW_Flag_Commutative)
 HARDWARE_INTRINSIC(AVX_AndNot,                                       "AndNot",                                           AVX,        -1,           32,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_andnps,    INS_andnpd},            HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
-HARDWARE_INTRINSIC(AVX_AddSubtract,                                  "AddSubtract",                                      AVX,        -1,           32,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_addsubps,  INS_addsubpd},          HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)                 
+HARDWARE_INTRINSIC(AVX_Blend,                                        "Blend",                                            AVX,        -1,           32,           3,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_blendps,   INS_blendpd},           HW_Category_IMM,                               HW_Flag_FullRangeIMM)
 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)
+HARDWARE_INTRINSIC(AVX_Ceiling,                                      "Ceiling",                                          AVX,        10,           32,           1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_roundps,   INS_roundpd},           HW_Category_SimpleSIMD,                        HW_Flag_NoRMWSemantics)
 HARDWARE_INTRINSIC(AVX_Compare,                                      "Compare",                                          AVX,        -1,           32,           3,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_cmpps,     INS_cmppd},             HW_Category_IMM,                               HW_Flag_NoFlag)
 HARDWARE_INTRINSIC(AVX_CompareScalar,                                "CompareScalar",                                    AVX,        -1,           16,           3,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_cmpss,     INS_cmpsd},             HW_Category_IMM,                               HW_Flag_CopyUpperBits)
 HARDWARE_INTRINSIC(AVX_ConvertToSingle,                              "ConvertToSingle",                                  AVX,        -1,           32,           1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_movss,     INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_NoRMWSemantics)
 HARDWARE_INTRINSIC(AVX_Divide,                                       "Divide",                                           AVX,        -1,           32,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_divps,     INS_divpd},             HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(AVX_DotProduct,                                   "DotProduct",                                       AVX,        -1,           32,           3,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_dpps,      INS_invalid},           HW_Category_IMM,                               HW_Flag_FullRangeIMM)
 HARDWARE_INTRINSIC(AVX_DuplicateEvenIndexed,                         "DuplicateEvenIndexed",                             AVX,        -1,           32,           1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_movsldup,  INS_movddup},           HW_Category_SimpleSIMD,                        HW_Flag_NoRMWSemantics)
 HARDWARE_INTRINSIC(AVX_DuplicateOddIndexed,                          "DuplicateOddIndexed",                              AVX,        -1,           32,           1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_movshdup,  INS_invalid},           HW_Category_SimpleSIMD,                        HW_Flag_NoRMWSemantics)
+HARDWARE_INTRINSIC(AVX_Floor,                                        "Floor",                                            AVX,         9,           32,           1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_roundps,   INS_roundpd},           HW_Category_SimpleSIMD,                        HW_Flag_NoRMWSemantics)
 HARDWARE_INTRINSIC(AVX_HorizontalAdd,                                "HorizontalAdd",                                    AVX,        -1,           32,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_haddps,    INS_haddpd},            HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
 HARDWARE_INTRINSIC(AVX_HorizontalSubtract,                           "HorizontalSubtract",                               AVX,        -1,           32,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_hsubps,    INS_hsubpd},            HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
 HARDWARE_INTRINSIC(AVX_LoadAlignedVector256,                         "LoadAlignedVector256",                             AVX,        -1,           32,           1,           {INS_movdqa,    INS_movdqa,    INS_movdqa,    INS_movdqa,    INS_movdqa,    INS_movdqa,    INS_movdqa,    INS_movdqa,    INS_movaps,    INS_movapd},            HW_Category_MemoryLoad,                        HW_Flag_NoRMWSemantics)
@@ -336,12 +340,20 @@ HARDWARE_INTRINSIC(AVX_Multiply,                                     "Multiply",
 HARDWARE_INTRINSIC(AVX_Or,                                           "Or",                                               AVX,        -1,           32,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_orps,      INS_orpd},              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_NoRMWSemantics)
 HARDWARE_INTRINSIC(AVX_ReciprocalSqrt,                               "ReciprocalSqrt",                                   AVX,        -1,           32,           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_NoRMWSemantics)
+HARDWARE_INTRINSIC(AVX_RoundCurrentDirection,                        "RoundCurrentDirection",                            AVX,         4,           32,           1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_roundps,   INS_roundpd},           HW_Category_SimpleSIMD,                        HW_Flag_NoRMWSemantics)
+HARDWARE_INTRINSIC(AVX_RoundToNearestInteger,                        "RoundToNearestInteger",                            AVX,         8,           32,           1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_roundps,   INS_roundpd},           HW_Category_SimpleSIMD,                        HW_Flag_NoRMWSemantics)
+HARDWARE_INTRINSIC(AVX_RoundToNegativeInfinity,                      "RoundToNegativeInfinity",                          AVX,         9,           32,           1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_roundps,   INS_roundpd},           HW_Category_SimpleSIMD,                        HW_Flag_NoRMWSemantics)
+HARDWARE_INTRINSIC(AVX_RoundToPositiveInfinity,                      "RoundToPositiveInfinity",                          AVX,        10,           32,           1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_roundps,   INS_roundpd},           HW_Category_SimpleSIMD,                        HW_Flag_NoRMWSemantics)
+HARDWARE_INTRINSIC(AVX_RoundToZero,                                  "RoundToZero",                                      AVX,        11,           32,           1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_roundps,   INS_roundpd},           HW_Category_SimpleSIMD,                        HW_Flag_NoRMWSemantics)
 HARDWARE_INTRINSIC(AVX_SetZeroVector256,                             "SetZeroVector256",                                 AVX,        -1,           32,           0,           {INS_pxor,      INS_pxor,      INS_pxor,      INS_pxor,      INS_pxor,      INS_pxor,      INS_pxor,      INS_pxor,      INS_xorps,     INS_xorpd},             HW_Category_Helper,                            HW_Flag_OneTypeGeneric|HW_Flag_NoRMWSemantics)
 HARDWARE_INTRINSIC(AVX_Sqrt,                                         "Sqrt",                                             AVX,        -1,           32,           1,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_sqrtps,    INS_sqrtpd},            HW_Category_SimpleSIMD,                        HW_Flag_NoRMWSemantics)
 HARDWARE_INTRINSIC(AVX_Store,                                        "Store",                                            AVX,        -1,           32,           2,           {INS_movdqu,    INS_movdqu,    INS_movdqu,    INS_movdqu,    INS_movdqu,    INS_movdqu,    INS_movdqu,    INS_movdqu,    INS_movups,    INS_movupd},            HW_Category_MemoryStore,                       HW_Flag_NoRMWSemantics)
 HARDWARE_INTRINSIC(AVX_StoreAligned,                                 "StoreAligned",                                     AVX,        -1,           32,           2,           {INS_movdqa,    INS_movdqa,    INS_movdqa,    INS_movdqa,    INS_movdqa,    INS_movdqa,    INS_movdqa,    INS_movdqa,    INS_movaps,    INS_movapd},            HW_Category_MemoryStore,                       HW_Flag_NoRMWSemantics)
 HARDWARE_INTRINSIC(AVX_StoreAlignedNonTemporal,                      "StoreAlignedNonTemporal",                          AVX,        -1,           32,           2,           {INS_movntdq,   INS_movntdq,   INS_movntdq,   INS_movntdq,   INS_movntdq,   INS_movntdq,   INS_movntdq,   INS_movntdq,   INS_movntps,   INS_movntpd},           HW_Category_MemoryStore,                       HW_Flag_NoRMWSemantics)
 HARDWARE_INTRINSIC(AVX_Subtract,                                     "Subtract",                                         AVX,        -1,           32,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_subps,     INS_subpd},             HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
+HARDWARE_INTRINSIC(AVX_TestC,                                        "TestC",                                            AVX,        -1,            0,           2,           {INS_ptest,     INS_ptest,     INS_ptest,     INS_ptest,     INS_ptest,     INS_ptest,     INS_ptest,     INS_ptest,     INS_vtestps,   INS_vtestpd},           HW_Category_SimpleSIMD,                        HW_Flag_OneTypeGeneric|HW_Flag_UnfixedSIMDSize|HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromArg)
+HARDWARE_INTRINSIC(AVX_TestNotZAndNotC,                              "TestNotZAndNotC",                                  AVX,        -1,            0,           2,           {INS_ptest,     INS_ptest,     INS_ptest,     INS_ptest,     INS_ptest,     INS_ptest,     INS_ptest,     INS_ptest,     INS_vtestps,   INS_vtestpd},           HW_Category_SimpleSIMD,                        HW_Flag_OneTypeGeneric|HW_Flag_UnfixedSIMDSize|HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromArg)
+HARDWARE_INTRINSIC(AVX_TestZ,                                        "TestZ",                                            AVX,        -1,            0,           2,           {INS_ptest,     INS_ptest,     INS_ptest,     INS_ptest,     INS_ptest,     INS_ptest,     INS_ptest,     INS_ptest,     INS_vtestps,   INS_vtestpd},           HW_Category_SimpleSIMD,                        HW_Flag_OneTypeGeneric|HW_Flag_UnfixedSIMDSize|HW_Flag_MultiIns|HW_Flag_NoContainment|HW_Flag_BaseTypeFromArg)
 HARDWARE_INTRINSIC(AVX_UnpackHigh,                                   "UnpackHigh",                                       AVX,        -1,           32,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_unpckhps,  INS_unpckhpd},          HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
 HARDWARE_INTRINSIC(AVX_UnpackLow,                                    "UnpackLow",                                        AVX,        -1,           32,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_unpcklps,  INS_unpcklpd},          HW_Category_SimpleSIMD,                        HW_Flag_NoFlag)
 HARDWARE_INTRINSIC(AVX_Xor,                                          "Xor",                                              AVX,        -1,           32,           2,           {INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_invalid,   INS_xorps,     INS_xorpd},             HW_Category_SimpleSIMD,                        HW_Flag_Commutative)
index c4b4823..36f48ba 100644 (file)
@@ -192,12 +192,18 @@ int Compiler::ivalOfHWIntrinsic(NamedIntrinsic intrinsic)
 unsigned Compiler::simdSizeOfHWIntrinsic(NamedIntrinsic intrinsic, CORINFO_SIG_INFO* sig)
 {
     assert(intrinsic > NI_HW_INTRINSIC_START && intrinsic < NI_HW_INTRINSIC_END);
-    if ((Compiler::flagsOfHWIntrinsic(intrinsic) & HW_Flag_UnfixedSIMDSize) == 0)
+
+    HWIntrinsicFlag flags = flagsOfHWIntrinsic(intrinsic);
+
+    if ((flags & HW_Flag_UnfixedSIMDSize) == 0)
     {
         return hwIntrinsicInfoArray[intrinsic - NI_HW_INTRINSIC_START - 1].simdSize;
     }
 
-    int simdSize = getSIMDTypeSizeInBytes(sig->retTypeSigClass);
+    CORINFO_CLASS_HANDLE typeHnd =
+        ((flags & HW_Flag_BaseTypeFromArg) == 0) ? sig->retTypeSigClass : info.compCompHnd->getArgClass(sig, sig->args);
+
+    int simdSize = getSIMDTypeSizeInBytes(typeHnd);
     assert(simdSize > 0);
     return (unsigned)simdSize;
 }
@@ -592,7 +598,7 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic        intrinsic,
     var_types           retType  = JITtype2varType(sig->retType);
     var_types           baseType = TYP_UNKNOWN;
 
-    if (retType == TYP_STRUCT && featureSIMD)
+    if ((retType == TYP_STRUCT) && featureSIMD)
     {
         unsigned int sizeBytes;
         baseType = getBaseTypeAndSizeOfSIMDType(sig->retTypeSigClass, &sizeBytes);
@@ -648,6 +654,24 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic        intrinsic,
         }
     }
 
+    bool isTableDriven = impIsTableDrivenHWIntrinsic(category, flags);
+
+    if (isTableDriven && (!varTypeIsSIMD(retType) || ((flags & HW_Flag_BaseTypeFromArg) != 0)))
+    {
+        if (retType != TYP_VOID)
+        {
+            baseType = getBaseTypeOfSIMDType(info.compCompHnd->getArgClass(sig, sig->args));
+        }
+        else
+        {
+            assert(category == HW_Category_MemoryStore);
+            baseType =
+                getBaseTypeOfSIMDType(info.compCompHnd->getArgClass(sig, info.compCompHnd->getArgNext(sig->args)));
+        }
+
+        assert(baseType != TYP_UNKNOWN);
+    }
+
     if ((flags & (HW_Flag_OneTypeGeneric | HW_Flag_TwoTypeGeneric)) != 0)
     {
         if (!varTypeIsArithmetic(baseType))
@@ -675,24 +699,8 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic        intrinsic,
     }
 
     // table-driven importer of simple intrinsics
-    if (impIsTableDrivenHWIntrinsic(category, flags))
+    if (isTableDriven)
     {
-        if (!varTypeIsSIMD(retType) || ((flags & HW_Flag_BaseTypeFromArg) != 0))
-        {
-            if (retType != TYP_VOID)
-            {
-                baseType = getBaseTypeOfSIMDType(info.compCompHnd->getArgClass(sig, sig->args));
-            }
-            else
-            {
-                assert(category == HW_Category_MemoryStore);
-                baseType =
-                    getBaseTypeOfSIMDType(info.compCompHnd->getArgClass(sig, info.compCompHnd->getArgNext(sig->args)));
-            }
-
-            assert(baseType != TYP_UNKNOWN);
-        }
-
         unsigned                simdSize = simdSizeOfHWIntrinsic(intrinsic, sig);
         CORINFO_ARG_LIST_HANDLE argList  = sig->args;
         CORINFO_CLASS_HANDLE    argClass;
index ae8adff..7dcaf93 100644 (file)
@@ -472,7 +472,8 @@ INST3( vpermq,       "permq"       , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE, SS
 INST3( vblendvps,    "blendvps"    , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE, SSE3A(0x4A))   // Variable Blend Packed Singles
 INST3( vblendvpd,    "blendvpd"    , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE, SSE3A(0x4B))   // Variable Blend Packed Doubles
 INST3( vpblendvb,    "pblendvb"    , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE, SSE3A(0x4C))   // Variable Blend Packed Bytes
-
+INST3( vtestps,      "testps"      , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE, SSE38(0x0E))   // Packed Bit Test
+INST3( vtestpd,      "testpd"      , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE, SSE38(0x0F))   // Packed Bit Test
 INST3( vpsrlvd,      "psrlvd"      , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE, SSE38(0x45))   // Variable Bit Shift Right Logical
 INST3( vpsrlvq,      "psrlvq"      , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE, SSE38(0x45))   // Variable Bit Shift Right Logical
 INST3( vpsravd,      "psravd"      , 0, IUM_WR, 0, 0, BAD_CODE,     BAD_CODE, SSE38(0x46))   // Variable Bit Shift Right Arithmetic
index b864121..0b3f971 100644 (file)
     <Compile Include="$(MSBuildThisFileDirectory)System\Single.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Span.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Span.Fast.cs" />
-    <Compile Include="$(MSBuildThisFileDirectory)System\Span.NonGeneric.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\SpanDebugView.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\SpanHelpers.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\SpanHelpers.BinarySearch.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\TaskToApm.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\TaskSchedulerException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\ValueTask.cs" />
+    <Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\Sources\IValueTaskSource.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadAbortException.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadPriority.cs" />
     <Compile Include="$(MSBuildThisFileDirectory)System\Threading\ThreadStart.cs" />
index 1b89158..77d3055 100644 (file)
@@ -72,10 +72,14 @@ namespace System.Collections.Generic
         {
             if (capacity < 0) ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.capacity);
             if (capacity > 0) Initialize(capacity);
-            _comparer = comparer ?? EqualityComparer<TKey>.Default;
+            if (comparer != EqualityComparer<TKey>.Default)
+            {
+                _comparer = comparer;
+            }
 
-            if (_comparer == EqualityComparer<string>.Default)
+            if (typeof(TKey) == typeof(string) && _comparer == null)
             {
+                // To start, move off default comparer for string which is randomised
                 _comparer = (IEqualityComparer<TKey>)NonRandomizedStringEqualityComparer.Default;
             }
         }
@@ -143,7 +147,7 @@ namespace System.Collections.Generic
         {
             get
             {
-                return (_comparer is NonRandomizedStringEqualityComparer) ? (IEqualityComparer<TKey>)EqualityComparer<string>.Default : _comparer;
+                return (_comparer == null || _comparer is NonRandomizedStringEqualityComparer) ? EqualityComparer<TKey>.Default : _comparer;
             }
         }
 
@@ -259,11 +263,7 @@ namespace System.Collections.Generic
             int count = _count;
             if (count > 0)
             {
-                int[] buckets = _buckets;
-                for (int i = 0; i < buckets.Length; i++)
-                {
-                    buckets[i] = -1;
-                }
+                Array.Clear(_buckets, 0, _buckets.Length);
 
                 _count = 0;
                 _freeList = -1;
@@ -289,10 +289,9 @@ namespace System.Collections.Generic
             }
             else
             {
-                EqualityComparer<TValue> c = EqualityComparer<TValue>.Default;
                 for (int i = 0; i < _count; i++)
                 {
-                    if (_entries[i].hashCode >= 0 && c.Equals(_entries[i].value, value)) return true;
+                    if (_entries[i].hashCode >= 0 && EqualityComparer<TValue>.Default.Equals(_entries[i].value, value)) return true;
                 }
             }
             return false;
@@ -344,7 +343,7 @@ namespace System.Collections.Generic
             }
 
             info.AddValue(VersionName, _version);
-            info.AddValue(ComparerName, _comparer, typeof(IEqualityComparer<TKey>));
+            info.AddValue(ComparerName, _comparer ?? EqualityComparer<TKey>.Default, typeof(IEqualityComparer<TKey>));
             info.AddValue(HashSizeName, _buckets == null ? 0 : _buckets.Length); // This is the length of the bucket array
 
             if (_buckets != null)
@@ -362,28 +361,58 @@ namespace System.Collections.Generic
                 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
             }
 
-            if (_buckets != null)
+            int i = -1;
+            int[] buckets = _buckets;
+            Entry[] entries = _entries;
+            if (buckets != null)
             {
-                int hashCode = _comparer.GetHashCode(key) & 0x7FFFFFFF;
-                for (int i = _buckets[hashCode % _buckets.Length]; i >= 0; i = _entries[i].next)
+                IEqualityComparer<TKey> comparer = _comparer;
+                if (comparer == null)
                 {
-                    if (_entries[i].hashCode == hashCode && _comparer.Equals(_entries[i].key, key)) return i;
+                    int hashCode = key.GetHashCode() & 0x7FFFFFFF;
+                    // Value in _buckets is 1-based
+                    i = buckets[hashCode % buckets.Length] - 1;
+                    do
+                    {
+                        // Should be a while loop https://github.com/dotnet/coreclr/issues/15476
+                        // Test in if to drop range check for following array access
+                        if ((uint)i >= (uint)entries.Length || (entries[i].hashCode == hashCode && EqualityComparer<TKey>.Default.Equals(entries[i].key, key)))
+                        {
+                            break;
+                        }
+
+                        i = entries[i].next;
+                    } while (true);
+                }
+                else
+                {
+                    int hashCode = comparer.GetHashCode(key) & 0x7FFFFFFF;
+                    // Value in _buckets is 1-based
+                    i = buckets[hashCode % buckets.Length] - 1;
+                    do
+                    {
+                        // Should be a while loop https://github.com/dotnet/coreclr/issues/15476
+                        // Test in if to drop range check for following array access
+                        if ((uint)i >= (uint)entries.Length ||
+                            (entries[i].hashCode == hashCode && comparer.Equals(entries[i].key, key)))
+                        {
+                            break;
+                        }
+
+                        i = entries[i].next;
+                    } while (true);
                 }
             }
-            return -1;
+
+            return i;
         }
 
         private int Initialize(int capacity)
         {
             int size = HashHelpers.GetPrime(capacity);
-            int[] buckets = new int[size];
-            for (int i = 0; i < buckets.Length; i++)
-            {
-                buckets[i] = -1;
-            }
 
             _freeList = -1;
-            _buckets = buckets;
+            _buckets = new int[size];
             _entries = new Entry[size];
 
             return size;
@@ -396,64 +425,134 @@ namespace System.Collections.Generic
                 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
             }
 
-            if (_buckets == null) Initialize(0);
-            int hashCode = _comparer.GetHashCode(key) & 0x7FFFFFFF;
-            int targetBucket = hashCode % _buckets.Length;
+            if (_buckets == null)
+            {
+                Initialize(0);
+            }
+
+            Entry[] entries = _entries;
+            IEqualityComparer<TKey> comparer = _comparer;
+
+            int hashCode = ((comparer == null) ? key.GetHashCode() : comparer.GetHashCode(key)) & 0x7FFFFFFF;
+
             int collisionCount = 0;
+            ref int bucket = ref _buckets[hashCode % _buckets.Length];
+            // Value in _buckets is 1-based
+            int i = bucket - 1;
 
-            for (int i = _buckets[targetBucket]; i >= 0; i = _entries[i].next)
+            if (comparer == null)
             {
-                if (_entries[i].hashCode == hashCode && _comparer.Equals(_entries[i].key, key))
+                do
                 {
-                    if (behavior == InsertionBehavior.OverwriteExisting)
+                    // Should be a while loop https://github.com/dotnet/coreclr/issues/15476
+                    // Test uint in if rather than loop condition to drop range check for following array access
+                    if ((uint)i >= (uint)entries.Length)
                     {
-                        _entries[i].value = value;
-                        _version++;
-                        return true;
+                        break;
                     }
 
-                    if (behavior == InsertionBehavior.ThrowOnExisting)
+                    if (entries[i].hashCode == hashCode && EqualityComparer<TKey>.Default.Equals(entries[i].key, key))
                     {
-                        ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException(key);
+                        if (behavior == InsertionBehavior.OverwriteExisting)
+                        {
+                            entries[i].value = value;
+                            _version++;
+                            return true;
+                        }
+
+                        if (behavior == InsertionBehavior.ThrowOnExisting)
+                        {
+                            ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException(key);
+                        }
+
+                        return false;
                     }
 
-                    return false;
-                }
-                collisionCount++;
+                    i = entries[i].next;
+                    collisionCount++;
+                } while (true);
+            }
+            else
+            {
+                do
+                {
+                    // Should be a while loop https://github.com/dotnet/coreclr/issues/15476
+                    // Test uint in if rather than loop condition to drop range check for following array access
+                    if ((uint)i >= (uint)entries.Length)
+                    {
+                        break;
+                    }
+
+                    if (entries[i].hashCode == hashCode && comparer.Equals(entries[i].key, key))
+                    {
+                        if (behavior == InsertionBehavior.OverwriteExisting)
+                        {
+                            entries[i].value = value;
+                            _version++;
+                            return true;
+                        }
+
+                        if (behavior == InsertionBehavior.ThrowOnExisting)
+                        {
+                            ThrowHelper.ThrowAddingDuplicateWithKeyArgumentException(key);
+                        }
+
+                        return false;
+                    }
+
+                    i = entries[i].next;
+                    collisionCount++;
+                } while (true);
+
             }
 
+            // Can be improved with "Ref Local Reassignment"
+            // https://github.com/dotnet/csharplang/blob/master/proposals/ref-local-reassignment.md
+            bool resized = false;
+            bool updateFreeList = false;
             int index;
             if (_freeCount > 0)
             {
                 index = _freeList;
-                _freeList = _entries[index].next;
+                updateFreeList = true;
                 _freeCount--;
             }
             else
             {
-                if (_count == _entries.Length)
+                int count = _count;
+                if (count == entries.Length)
                 {
                     Resize();
-                    targetBucket = hashCode % _buckets.Length;
+                    resized = true;
                 }
-                index = _count;
-                _count++;
+                index = count;
+                _count = count + 1;
+                entries = _entries;
             }
 
-            _entries[index].hashCode = hashCode;
-            _entries[index].next = _buckets[targetBucket];
-            _entries[index].key = key;
-            _entries[index].value = value;
-            _buckets[targetBucket] = index;
-            _version++;
+            ref int targetBucket = ref resized ? ref _buckets[hashCode % _buckets.Length] : ref bucket;
+            ref Entry entry = ref entries[index];
 
-            // If we hit the collision threshold we'll need to switch to the comparer which is using randomized string hashing
-            // i.e. EqualityComparer<string>.Default.
+            if (updateFreeList)
+            {
+                _freeList = entry.next;
+            }
+            entry.hashCode = hashCode;
+            // Value in _buckets is 1-based
+            entry.next = targetBucket - 1;
+            entry.key = key;
+            entry.value = value;
+            // Value in _buckets is 1-based
+            targetBucket = index + 1;
+            _version++;
 
-            if (collisionCount > HashHelpers.HashCollisionThreshold && _comparer is NonRandomizedStringEqualityComparer)
+            // Value types never rehash
+            if (default(TKey) == null && collisionCount > HashHelpers.HashCollisionThreshold && comparer is NonRandomizedStringEqualityComparer)
             {
-                _comparer = (IEqualityComparer<TKey>)EqualityComparer<string>.Default;
-                Resize(_entries.Length, true);
+                // If we hit the collision threshold we'll need to switch to the comparer which is using randomized string hashing
+                // i.e. EqualityComparer<string>.Default.
+                _comparer = null;
+                Resize(entries.Length, true);
             }
 
             return true;
@@ -512,25 +611,24 @@ namespace System.Collections.Generic
 
         private void Resize(int newSize, bool forceNewHashCodes)
         {
+            // Value types never rehash
+            Debug.Assert(!forceNewHashCodes || default(TKey) == null);
             Debug.Assert(newSize >= _entries.Length);
 
             int[] buckets = new int[newSize];
-            for (int i = 0; i < buckets.Length; i++)
-            {
-                buckets[i] = -1;
-            }
             Entry[] entries = new Entry[newSize];
 
             int count = _count;
             Array.Copy(_entries, 0, entries, 0, count);
 
-            if (forceNewHashCodes)
+            if (default(TKey) == null && forceNewHashCodes)
             {
                 for (int i = 0; i < count; i++)
                 {
-                    if (entries[i].hashCode != -1)
+                    if (entries[i].hashCode >= 0)
                     {
-                        entries[i].hashCode = (_comparer.GetHashCode(entries[i].key) & 0x7FFFFFFF);
+                        Debug.Assert(_comparer == null);
+                        entries[i].hashCode = (entries[i].key.GetHashCode() & 0x7FFFFFFF);
                     }
                 }
             }
@@ -540,8 +638,10 @@ namespace System.Collections.Generic
                 if (entries[i].hashCode >= 0)
                 {
                     int bucket = entries[i].hashCode % newSize;
-                    entries[i].next = buckets[bucket];
-                    buckets[bucket] = i;
+                    // Value in _buckets is 1-based
+                    entries[i].next = buckets[bucket] - 1;
+                    // Value in _buckets is 1-based
+                    buckets[bucket] = i + 1;
                 }
             }
 
@@ -561,19 +661,21 @@ namespace System.Collections.Generic
 
             if (_buckets != null)
             {
-                int hashCode = _comparer.GetHashCode(key) & 0x7FFFFFFF;
+                int hashCode = (_comparer?.GetHashCode(key) ?? key.GetHashCode()) & 0x7FFFFFFF;
                 int bucket = hashCode % _buckets.Length;
                 int last = -1;
-                int i = _buckets[bucket];
+                // Value in _buckets is 1-based
+                int i = _buckets[bucket] - 1;
                 while (i >= 0)
                 {
                     ref Entry entry = ref _entries[i];
 
-                    if (entry.hashCode == hashCode && _comparer.Equals(entry.key, key))
+                    if (entry.hashCode == hashCode && (_comparer?.Equals(entry.key, key) ?? EqualityComparer<TKey>.Default.Equals(entry.key, key)))
                     {
                         if (last < 0)
                         {
-                            _buckets[bucket] = entry.next;
+                            // Value in _buckets is 1-based
+                            _buckets[bucket] = entry.next + 1;
                         }
                         else
                         {
@@ -615,19 +717,21 @@ namespace System.Collections.Generic
 
             if (_buckets != null)
             {
-                int hashCode = _comparer.GetHashCode(key) & 0x7FFFFFFF;
+                int hashCode = (_comparer?.GetHashCode(key) ?? key.GetHashCode()) & 0x7FFFFFFF;
                 int bucket = hashCode % _buckets.Length;
                 int last = -1;
-                int i = _buckets[bucket];
+                // Value in _buckets is 1-based
+                int i = _buckets[bucket] - 1;
                 while (i >= 0)
                 {
                     ref Entry entry = ref _entries[i];
 
-                    if (entry.hashCode == hashCode && _comparer.Equals(entry.key, key))
+                    if (entry.hashCode == hashCode && (_comparer?.Equals(entry.key, key) ?? EqualityComparer<TKey>.Default.Equals(entry.key, key)))
                     {
                         if (last < 0)
                         {
-                            _buckets[bucket] = entry.next;
+                            // Value in _buckets is 1-based
+                            _buckets[bucket] = entry.next + 1;
                         }
                         else
                         {
@@ -824,8 +928,10 @@ namespace System.Collections.Generic
                     ref Entry entry = ref entries[count];
                     entry = oldEntries[i];
                     int bucket = hashCode % newSize;
-                    entry.next = buckets[bucket];
-                    buckets[bucket] = count;
+                    // Value in _buckets is 1-based
+                    entry.next = buckets[bucket] - 1;
+                    // Value in _buckets is 1-based
+                    buckets[bucket] = count + 1;
                     count++;
                 }
             }
index 31b9ac5..d9fcf65 100644 (file)
@@ -635,12 +635,12 @@ namespace System.IO
         /// <param name="source">The buffer to write data from.</param>
         /// <param name="cancellationToken">The token to monitor for cancellation requests.</param>
         /// <returns>A task that represents the asynchronous write operation.</returns>
-        private Task WriteAsyncInternal(ReadOnlyMemory<byte> source, CancellationToken cancellationToken)
+        private ValueTask WriteAsyncInternal(ReadOnlyMemory<byte> source, CancellationToken cancellationToken)
         {
             Debug.Assert(_useAsyncIO);
 
             if (cancellationToken.IsCancellationRequested)
-                return Task.FromCanceled(cancellationToken);
+                return new ValueTask(Task.FromCanceled(cancellationToken));
 
             if (_fileHandle.IsClosed)
                 throw Error.GetFileNotOpen();
@@ -667,11 +667,11 @@ namespace System.IO
                         source.Span.CopyTo(new Span<byte>(GetBuffer(), _writePos, source.Length));
                         _writePos += source.Length;
 
-                        return Task.CompletedTask;
+                        return default;
                     }
                     catch (Exception exc)
                     {
-                        return Task.FromException(exc);
+                        return new ValueTask(Task.FromException(exc));
                     }
                     finally
                     {
@@ -682,7 +682,7 @@ namespace System.IO
 
             // Otherwise, issue the whole request asynchronously.
             _asyncState.ReadOnlyMemory = source;
-            return waitTask.ContinueWith((t, s) =>
+            return new ValueTask(waitTask.ContinueWith((t, s) =>
             {
                 // The options available on Unix for writing asynchronously to an arbitrary file 
                 // handle typically amount to just using another thread to do the synchronous write, 
@@ -702,7 +702,7 @@ namespace System.IO
                     thisRef.WriteSpan(readOnlyMemory.Span);
                 }
                 finally { thisRef._asyncState.Release(); }
-            }, this, CancellationToken.None, TaskContinuationOptions.DenyChildAttach, TaskScheduler.Default);
+            }, this, CancellationToken.None, TaskContinuationOptions.DenyChildAttach, TaskScheduler.Default));
         }
 
         /// <summary>Sets the current position of this stream to the given value.</summary>
index 85f0454..291a30b 100644 (file)
@@ -961,7 +961,7 @@ namespace System.IO
             return completionSource.Task;
         }
 
-        private Task WriteAsyncInternal(ReadOnlyMemory<byte> source, CancellationToken cancellationToken)
+        private ValueTask WriteAsyncInternal(ReadOnlyMemory<byte> source, CancellationToken cancellationToken)
         {
             Debug.Assert(_useAsyncIO);
             Debug.Assert((_readPos == 0 && _readLength == 0 && _writePos >= 0) || (_writePos == 0 && _readPos <= _readLength), "We're either reading or writing, but not both.");
@@ -1005,7 +1005,7 @@ namespace System.IO
                     // completely, we want to do the asynchronous flush/write as part of this operation 
                     // rather than waiting until the next write that fills the buffer.
                     if (source.Length != remainingBuffer)
-                        return Task.CompletedTask;
+                        return default;
 
                     Debug.Assert(_writePos == _bufferLength);
                 }
@@ -1051,7 +1051,7 @@ namespace System.IO
                     flushTask.IsFaulted ||
                     flushTask.IsCanceled)
                 {
-                    return flushTask;
+                    return new ValueTask(flushTask);
                 }
             }
 
@@ -1061,10 +1061,10 @@ namespace System.IO
             // Finally, issue the write asynchronously, and return a Task that logically
             // represents the write operation, including any flushing done.
             Task writeTask = WriteAsyncInternalCore(source, cancellationToken);
-            return
+            return new ValueTask(
                 (flushTask == null || flushTask.Status == TaskStatus.RanToCompletion) ? writeTask :
                 (writeTask.Status == TaskStatus.RanToCompletion) ? flushTask :
-                Task.WhenAll(flushTask, writeTask);
+                Task.WhenAll(flushTask, writeTask));
         }
 
         private unsafe Task WriteAsyncInternalCore(ReadOnlyMemory<byte> source, CancellationToken cancellationToken)
@@ -1319,7 +1319,7 @@ namespace System.IO
                 int bufferedBytes = _readLength - _readPos;
                 if (bufferedBytes > 0)
                 {
-                    await destination.WriteAsync(GetBuffer(), _readPos, bufferedBytes, cancellationToken).ConfigureAwait(false);
+                    await destination.WriteAsync(new ReadOnlyMemory<byte>(GetBuffer(), _readPos, bufferedBytes), cancellationToken).ConfigureAwait(false);
                     _readPos = _readLength = 0;
                 }
             }
@@ -1345,7 +1345,6 @@ namespace System.IO
             // Further, typically the CopyToAsync buffer size will be larger than that used by the FileStream, such that
             // we'd likely be unable to use it anyway.  Instead, we rent the buffer from a pool.
             byte[] copyBuffer = ArrayPool<byte>.Shared.Rent(bufferSize);
-            bufferSize = 0; // repurpose bufferSize to be the high water mark for the buffer, to avoid an extra field in the state machine
 
             // Allocate an Overlapped we can use repeatedly for all operations
             var awaitableOverlapped = new PreAllocatedOverlapped(AsyncCopyToAwaitable.s_callback, readAwaitable, copyBuffer);
@@ -1452,13 +1451,6 @@ namespace System.IO
                         {
                             readAwaitable._position += numBytesRead;
                         }
-
-                        // (and keep track of the maximum number of bytes in the buffer we used, to avoid excessive and unnecessary
-                        // clearing of the buffer before we return it to the pool)
-                        if (numBytesRead > bufferSize)
-                        {
-                            bufferSize = numBytesRead;
-                        }
                     }
                     finally
                     {
@@ -1479,7 +1471,7 @@ namespace System.IO
                     }
 
                     // Write out the read data.
-                    await destination.WriteAsync(copyBuffer, 0, (int)readAwaitable._numBytes, cancellationToken).ConfigureAwait(false);
+                    await destination.WriteAsync(new ReadOnlyMemory<byte>(copyBuffer, 0, (int)readAwaitable._numBytes), cancellationToken).ConfigureAwait(false);
                 }
             }
             finally
@@ -1488,8 +1480,7 @@ namespace System.IO
                 cancellationReg.Dispose();
                 awaitableOverlapped.Dispose();
 
-                Array.Clear(copyBuffer, 0, bufferSize);
-                ArrayPool<byte>.Shared.Return(copyBuffer, clearArray: false);
+                ArrayPool<byte>.Shared.Return(copyBuffer);
 
                 // Make sure the stream's current position reflects where we ended up
                 if (!_fileHandle.IsClosed && CanSeek)
index 4593768..717b73f 100644 (file)
@@ -458,10 +458,10 @@ namespace System.IO
             if (IsClosed)
                 throw Error.GetFileNotOpen();
 
-            return WriteAsyncInternal(new ReadOnlyMemory<byte>(buffer, offset, count), cancellationToken);
+            return WriteAsyncInternal(new ReadOnlyMemory<byte>(buffer, offset, count), cancellationToken).AsTask();
         }
 
-        public override Task WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default(CancellationToken))
+        public override ValueTask WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default(CancellationToken))
         {
             if (!_useAsyncIO || GetType() != typeof(FileStream))
             {
@@ -473,7 +473,7 @@ namespace System.IO
 
             if (cancellationToken.IsCancellationRequested)
             {
-                return Task.FromCanceled<int>(cancellationToken);
+                return new ValueTask(Task.FromCanceled<int>(cancellationToken));
             }
 
             if (IsClosed)
@@ -853,7 +853,7 @@ namespace System.IO
             if (!IsAsync)
                 return base.BeginWrite(array, offset, numBytes, callback, state);
             else
-                return TaskToApm.Begin(WriteAsyncInternal(new ReadOnlyMemory<byte>(array, offset, numBytes), CancellationToken.None), callback, state);
+                return TaskToApm.Begin(WriteAsyncInternal(new ReadOnlyMemory<byte>(array, offset, numBytes), CancellationToken.None).AsTask(), callback, state);
         }
 
         public override int EndRead(IAsyncResult asyncResult)
index c5e5ea9..ffe7f60 100644 (file)
@@ -448,7 +448,7 @@ namespace System.IO
                 // something other than an array and this is a MemoryStream-derived type that doesn't override Read(Span<byte>) will
                 // it then fall back to doing the ArrayPool/copy behavior.
                 return new ValueTask<int>(
-                    destination.TryGetArray(out ArraySegment<byte> destinationArray) ?
+                    MemoryMarshal.TryGetArray(destination, out ArraySegment<byte> destinationArray) ?
                         Read(destinationArray.Array, destinationArray.Offset, destinationArray.Count) :
                         Read(destination.Span));
             }
@@ -752,11 +752,11 @@ namespace System.IO
             }
         }
 
-        public override Task WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default(CancellationToken))
+        public override ValueTask WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default(CancellationToken))
         {
             if (cancellationToken.IsCancellationRequested)
             {
-                return Task.FromCanceled(cancellationToken);
+                return new ValueTask(Task.FromCanceled(cancellationToken));
             }
 
             try
@@ -771,15 +771,15 @@ namespace System.IO
                 {
                     Write(source.Span);
                 }
-                return Task.CompletedTask;
+                return default;
             }
             catch (OperationCanceledException oce)
             {
-                return Task.FromCancellation<VoidTaskResult>(oce);
+                return new ValueTask(Task.FromCancellation<VoidTaskResult>(oce));
             }
             catch (Exception exception)
             {
-                return Task.FromException(exception);
+                return new ValueTask(Task.FromException(exception));
             }
         }
 
index 039a288..74ceed1 100644 (file)
@@ -35,7 +35,7 @@ namespace System.IO
             // TryExpandShortName does this input identity check.
             string result = builder.AsSpan().Contains('~')
                 ? TryExpandShortFileName(ref builder, originalPath: path)
-                : builder.AsSpan().Equals(path.AsReadOnlySpan()) ? path : builder.ToString();
+                : builder.AsSpan().Equals(path.AsSpan()) ? path : builder.ToString();
 
             // Clear the buffer
             builder.Dispose();
@@ -220,7 +220,7 @@ namespace System.IO
             // Strip out any added characters at the front of the string
             ReadOnlySpan<char> output = builderToUse.AsSpan().Slice(rootDifference);
 
-            string returnValue = output.Equals(originalPath.AsReadOnlySpan())
+            string returnValue = output.Equals(originalPath.AsSpan())
                 ? originalPath : new string(output);
 
             inputBuilder.Dispose();
index 0e31731..fae309b 100644 (file)
@@ -84,11 +84,6 @@ namespace System.IO
             return !Path.IsPathRooted(path);
         }
 
-        internal static string TrimEndingDirectorySeparator(string path) =>
-            path.Length > 1 && IsDirectorySeparator(path[path.Length - 1]) ? // exclude root "/"
-            path.Substring(0, path.Length - 1) :
-            path;
-
         /// <summary>
         /// Returns true if the path is effectively empty for the current OS.
         /// For unix, this is empty or null. For Windows, this is empty, null, or 
index f931380..81d51ba 100644 (file)
@@ -70,7 +70,36 @@ namespace System.IO
             return ((value >= 'A' && value <= 'Z') || (value >= 'a' && value <= 'z'));
         }
 
+        private static bool EndsWithPeriodOrSpace(string path)
+        {
+            if (string.IsNullOrEmpty(path))
+                return false;
+
+            char c = path[path.Length - 1];
+            return c == ' ' || c == '.';
+        }
+
+        /// <summary>
+        /// Adds the extended path prefix (\\?\) if not already a device path, IF the path is not relative,
+        /// AND the path is more than 259 characters. (> MAX_PATH + null). This will also insert the extended
+        /// prefix if the path ends with a period or a space. Trailing periods and spaces are normally eaten
+        /// away from paths during normalization, but if we see such a path at this point it should be
+        /// normalized and has retained the final characters. (Typically from one of the *Info classes)
+        /// </summary>
+        internal static string EnsureExtendedPrefixIfNeeded(string path)
+        {
+            if (path != null && (path.Length >= MaxShortPath || EndsWithPeriodOrSpace(path)))
+            {
+                return EnsureExtendedPrefix(path);
+            }
+            else
+            {
+                return path;
+            }
+        }
+
         /// <summary>
+        /// DO NOT USE- Use EnsureExtendedPrefixIfNeeded. This will be removed shortly.
         /// Adds the extended path prefix (\\?\) if not already a device path, IF the path is not relative,
         /// AND the path is more than 259 characters. (> MAX_PATH + null)
         /// </summary>
@@ -188,64 +217,57 @@ namespace System.IO
         {
             int pathLength = path.Length;
             int i = 0;
-            int volumeSeparatorLength = 2;  // Length to the colon "C:"
-            int uncRootLength = 2;          // Length to the start of the server name "\\"
-            int devicePrefixLength = PathInternal.ExtendedPathPrefix.Length;
 
             bool deviceSyntax = IsDevice(path);
             bool deviceUnc = deviceSyntax && IsDeviceUNC(path);
-            if (deviceSyntax)
-            {
-                // Shift the position we look for the root from to account for the extended prefix
-                if (deviceUnc)
-                {
-                    // "\\" -> "\\?\UNC\"
-                    uncRootLength = UncExtendedPathPrefix.Length;
-                }
-                else if (devicePrefixLength + 1 < pathLength && path[devicePrefixLength + 1] == VolumeSeparatorChar && IsValidDriveChar(path[devicePrefixLength]))
-                {
-                    // "C:" -> "\\?\C:"
-                    volumeSeparatorLength += devicePrefixLength;
-                }
-            }
 
             if ((!deviceSyntax || deviceUnc) && pathLength > 0 && IsDirectorySeparator(path[0]))
             {
                 // UNC or simple rooted path (e.g. "\foo", NOT "\\?\C:\foo")
-
-                i = 1; //  Drive rooted (\foo) is one character
                 if (deviceUnc || (pathLength > 1 && IsDirectorySeparator(path[1])))
                 {
-                    // UNC (\\?\UNC\ or \\), scan past the next two directory separators at most
-                    // (e.g. to \\?\UNC\Server\Share or \\Server\Share\)
-                    i = uncRootLength;
-                    int n = 2; // Maximum separators to skip
+                    // UNC (\\?\UNC\ or \\), scan past server\share
+
+                    // Start past the prefix ("\\" or "\\?\UNC\")
+                    i = deviceUnc ? UncExtendedPrefixLength : UncPrefixLength;
+
+                    // Skip two separators at most
+                    int n = 2;
                     while (i < pathLength && (!IsDirectorySeparator(path[i]) || --n > 0))
                         i++;
                 }
+                else
+                {
+                    // Current drive rooted (e.g. "\foo")
+                    i = 1;
+                }
             }
-            else if (pathLength >= volumeSeparatorLength
-                && path[volumeSeparatorLength - 1] == VolumeSeparatorChar
-                && IsValidDriveChar(path[volumeSeparatorLength - 2]))
+            else if (deviceSyntax)
             {
-                // Path is at least longer than where we expect a colon, and has a colon (\\?\A:, A:)
-                // If the colon is followed by a directory separator, move past it
-                i = volumeSeparatorLength;
-                if (pathLength >= volumeSeparatorLength + 1 && IsDirectorySeparator(path[volumeSeparatorLength]))
+                // Device path (e.g. "\\?\.", "\\.\")
+                // Skip any characters following the prefix that aren't a separator
+                i = DevicePrefixLength;
+                while (i < pathLength && !IsDirectorySeparator(path[i]))
+                    i++;
+
+                // If there is another separator take it, as long as we have had at least one
+                // non-separator after the prefix (e.g. don't take "\\?\\", but take "\\?\a\")
+                if (i < pathLength && i > DevicePrefixLength && IsDirectorySeparator(path[i]))
                     i++;
             }
-            else if (deviceSyntax && ((devicePrefixLength + 1 >= pathLength) || !(path[devicePrefixLength + 1] == VolumeSeparatorChar)))
+            else if (pathLength >= 2
+                && path[1] == VolumeSeparatorChar
+                && IsValidDriveChar(path[0]))
             {
-                i = devicePrefixLength;
-                int n = 1; // Maximum separators to skip
-                while (i < pathLength && (!IsDirectorySeparator(path[i]) || --n > 0))
-                    i++;
+                // Valid drive specified path ("C:", "D:", etc.)
+                i = 2;
 
-                if (i == devicePrefixLength)
-                    i--;
+                // If the colon is followed by a directory separator, move past it (e.g "C:\")
+                if (pathLength > 2 && IsDirectorySeparator(path[2]))
+                    i++;
             }
 
-            return (i < pathLength && IsDirectorySeparator(path[i])) ? i + 1 : i;
+            return i;
         }
 
         private static bool StartsWithOrdinal(ReadOnlySpan<char> source, string value)
index f2f350d..eb06c26 100644 (file)
@@ -10,13 +10,30 @@ namespace System.IO
         /// <summary>
         /// Returns true if the path ends in a directory separator.
         /// </summary>
-        internal static bool EndsInDirectorySeparator(ReadOnlySpan<char> path) => path.Length > 0 && IsDirectorySeparator(path[path.Length - 1]);
+        internal static bool EndsInDirectorySeparator(ReadOnlySpan<char> path)
+            => path.Length > 0 && IsDirectorySeparator(path[path.Length - 1]);
 
         /// <summary>
         /// Returns true if the path starts in a directory separator.
         /// </summary>
         internal static bool StartsWithDirectorySeparator(ReadOnlySpan<char> path) => path.Length > 0 && IsDirectorySeparator(path[0]);
 
+        internal static string EnsureTrailingSeparator(string path)
+            => EndsInDirectorySeparator(path) ? path : path + DirectorySeparatorCharAsString;
+
+        internal static string TrimEndingDirectorySeparator(string path) =>
+            EndsInDirectorySeparator(path) && !IsRoot(path) ?
+                path.Substring(0, path.Length - 1) :
+                path;
+
+        internal static ReadOnlySpan<char> TrimEndingDirectorySeparator(ReadOnlySpan<char> path) =>
+            EndsInDirectorySeparator(path) && !IsRoot(path) ?
+                path.Slice(0, path.Length - 1) :
+                path;
+
+        internal static bool IsRoot(ReadOnlySpan<char> path)
+            => path.Length == GetRootLength(path);
+
         /// <summary>
         /// Get the common path length from the start of the string.
         /// </summary>
index 4e724dd..22ec6e6 100644 (file)
@@ -1091,7 +1091,7 @@ namespace System.IO
                         {
                             Debug.Assert(_bytePos <= _encoding.Preamble.Length, "possible bug in _compressPreamble.  Are two threads using this StreamReader at the same time?");
                             int tmpBytePos = _bytePos;
-                            int len = await tmpStream.ReadAsync(tmpByteBuffer, tmpBytePos, tmpByteBuffer.Length - tmpBytePos, cancellationToken).ConfigureAwait(false);
+                            int len = await tmpStream.ReadAsync(new Memory<byte>(tmpByteBuffer, tmpBytePos, tmpByteBuffer.Length - tmpBytePos), cancellationToken).ConfigureAwait(false);
                             Debug.Assert(len >= 0, "Stream.Read returned a negative number!  This is a bug in your stream class.");
 
                             if (len == 0)
@@ -1127,7 +1127,7 @@ namespace System.IO
                         {
                             Debug.Assert(_bytePos == 0, "_bytePos can be non zero only when we are trying to _checkPreamble.  Are two threads using this StreamReader at the same time?");
 
-                            _byteLen = await tmpStream.ReadAsync(tmpByteBuffer, 0, tmpByteBuffer.Length, cancellationToken).ConfigureAwait(false);
+                            _byteLen = await tmpStream.ReadAsync(new Memory<byte>(tmpByteBuffer), cancellationToken).ConfigureAwait(false);
 
                             Debug.Assert(_byteLen >= 0, "Stream.Read returned a negative number!  This is a bug in your stream class.");
 
@@ -1303,7 +1303,7 @@ namespace System.IO
                 {
                     Debug.Assert(_bytePos <= _encoding.Preamble.Length, "possible bug in _compressPreamble. Are two threads using this StreamReader at the same time?");
                     int tmpBytePos = _bytePos;
-                    int len = await tmpStream.ReadAsync(tmpByteBuffer, tmpBytePos, tmpByteBuffer.Length - tmpBytePos).ConfigureAwait(false);
+                    int len = await tmpStream.ReadAsync(new Memory<byte>(tmpByteBuffer, tmpBytePos, tmpByteBuffer.Length - tmpBytePos)).ConfigureAwait(false);
                     Debug.Assert(len >= 0, "Stream.Read returned a negative number!  This is a bug in your stream class.");
 
                     if (len == 0)
@@ -1325,7 +1325,7 @@ namespace System.IO
                 else
                 {
                     Debug.Assert(_bytePos == 0, "_bytePos can be non zero only when we are trying to _checkPreamble. Are two threads using this StreamReader at the same time?");
-                    _byteLen = await tmpStream.ReadAsync(tmpByteBuffer, 0, tmpByteBuffer.Length).ConfigureAwait(false);
+                    _byteLen = await tmpStream.ReadAsync(new Memory<byte>(tmpByteBuffer)).ConfigureAwait(false);
                     Debug.Assert(_byteLen >= 0, "Stream.Read returned a negative number!  Bug in stream class.");
 
                     if (_byteLen == 0)  // We're at EOF
index 6cdcd69..a376244 100644 (file)
@@ -963,14 +963,14 @@ namespace System.IO
                 byte[] preamble = encoding.GetPreamble();
                 if (preamble.Length > 0)
                 {
-                    await stream.WriteAsync(preamble, 0, preamble.Length, cancellationToken).ConfigureAwait(false);
+                    await stream.WriteAsync(new ReadOnlyMemory<byte>(preamble), cancellationToken).ConfigureAwait(false);
                 }
             }
 
             int count = encoder.GetBytes(charBuffer, 0, charPos, byteBuffer, 0, flushEncoder);
             if (count > 0)
             {
-                await stream.WriteAsync(byteBuffer, 0, count, cancellationToken).ConfigureAwait(false);
+                await stream.WriteAsync(new ReadOnlyMemory<byte>(byteBuffer, 0, count), cancellationToken).ConfigureAwait(false);
             }
 
             // By definition, calling Flush should flush the stream, but this is
index c4727cd..eb94dd7 100644 (file)
@@ -7,6 +7,7 @@ using System.Threading;
 using System.Threading.Tasks;
 using System.Diagnostics;
 using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
 using System.Buffers;
 
 namespace System.IO
@@ -251,7 +252,7 @@ namespace System.IO
         }
 
         public virtual ValueTask<int> ReadAsync(Memory<char> buffer, CancellationToken cancellationToken = default(CancellationToken)) =>
-            new ValueTask<int>(buffer.TryGetArray(out ArraySegment<char> array) ?
+            new ValueTask<int>(MemoryMarshal.TryGetArray(buffer, out ArraySegment<char> array) ?
                 ReadAsync(array.Array, array.Offset, array.Count) :
                 Task<int>.Factory.StartNew(state =>
                 {
@@ -289,7 +290,7 @@ namespace System.IO
         }
 
         public virtual ValueTask<int> ReadBlockAsync(Memory<char> buffer, CancellationToken cancellationToken = default(CancellationToken)) =>
-            new ValueTask<int>(buffer.TryGetArray(out ArraySegment<char> array) ?
+            new ValueTask<int>(MemoryMarshal.TryGetArray(buffer, out ArraySegment<char> array) ?
                 ReadBlockAsync(array.Array, array.Offset, array.Count) :
                 Task<int>.Factory.StartNew(state =>
                 {
index 1711135..d1a1315 100644 (file)
@@ -510,7 +510,7 @@ namespace System.IO
                 // something other than an array and this is an UnmanagedMemoryStream-derived type that doesn't override Read(Span<byte>) will
                 // it then fall back to doing the ArrayPool/copy behavior.
                 return new ValueTask<int>(
-                    destination.TryGetArray(out ArraySegment<byte> destinationArray) ?
+                    MemoryMarshal.TryGetArray(destination, out ArraySegment<byte> destinationArray) ?
                         Read(destinationArray.Array, destinationArray.Offset, destinationArray.Count) :
                         Read(destination.Span));
             }
@@ -783,11 +783,11 @@ namespace System.IO
         /// </summary>
         /// <param name="buffer">Buffer that will be written.</param>
         /// <param name="cancellationToken">Token that can be used to cancel the operation.</param>
-        public override Task WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default(CancellationToken))
+        public override ValueTask WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default(CancellationToken))
         {
             if (cancellationToken.IsCancellationRequested)
             {
-                return Task.FromCanceled(cancellationToken);
+                return new ValueTask(Task.FromCanceled(cancellationToken));
             }
 
             try
@@ -802,11 +802,11 @@ namespace System.IO
                 {
                     Write(source.Span);
                 }
-                return Task.CompletedTask;
+                return default;
             }
             catch (Exception ex)
             {
-                return Task.FromException(ex);
+                return new ValueTask(Task.FromException(ex));
             }
         }
 
index 90bb21a..f34c3c4 100644 (file)
@@ -217,7 +217,7 @@ namespace System.IO
             return _unmanagedStream.WriteAsync(buffer, offset, count, cancellationToken);
         }
 
-        public override Task WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default(CancellationToken))
+        public override ValueTask WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default(CancellationToken))
         {
             return _unmanagedStream.WriteAsync(source, cancellationToken);
         }
index 4a1ce4d..fca015f 100644 (file)
@@ -310,40 +310,6 @@ namespace System
         }
 
         /// <summary>
-        /// Get an array segment from the underlying memory.
-        /// If unable to get the array segment, return false with a default array segment.
-        /// </summary>
-        public bool TryGetArray(out ArraySegment<T> arraySegment)
-        {
-            if (_index < 0)
-            {
-                if (((OwnedMemory<T>)_object).TryGetArray(out var segment))
-                {
-                    arraySegment = new ArraySegment<T>(segment.Array, segment.Offset + (_index & RemoveOwnedFlagBitMask), _length);
-                    return true;
-                }
-            }
-            else if (_object is T[] arr)
-            {
-                arraySegment = new ArraySegment<T>(arr, _index, _length);
-                return true;
-            }
-
-            if (_length == 0)
-            {
-#if FEATURE_PORTABLE_SPAN
-                arraySegment = new ArraySegment<T>(SpanHelpers.PerTypeValues<T>.EmptyArray);
-#else
-                arraySegment = ArraySegment<T>.Empty;
-#endif // FEATURE_PORTABLE_SPAN
-                return true;
-            }
-
-            arraySegment = default(ArraySegment<T>);
-            return false;
-        }
-
-        /// <summary>
         /// Copies the contents from the memory into a new array.  This heap
         /// allocates, so should generally be avoided, however it is sometimes
         /// necessary to bridge the gap with APIs written in terms of arrays.
index fa508b2..b1ed881 100644 (file)
@@ -36,7 +36,7 @@ namespace System
                 }
 
                 if (typeof(T) == typeof(char) &&
-                    ((ReadOnlyMemory<char>)(object)_memory).TryGetString(out string text, out int start, out int length))
+                    MemoryMarshal.TryGetString((ReadOnlyMemory<char>)(object)_memory, out string text, out int start, out int length))
                 {
                     return (T[])(object)text.Substring(start, length).ToCharArray();
                 }
index 4b330b7..56dd203 100644 (file)
@@ -512,29 +512,5 @@ namespace System
 
             return new ReadOnlyMemory<char>(text, start, length);
         }
-
-        /// <summary>Attempts to get the underlying <see cref="string"/> from a <see cref="ReadOnlyMemory{T}"/>.</summary>
-        /// <param name="readOnlyMemory">The memory that may be wrapping a <see cref="string"/> object.</param>
-        /// <param name="text">The string.</param>
-        /// <param name="start">The starting location in <paramref name="text"/>.</param>
-        /// <param name="length">The number of items in <paramref name="text"/>.</param>
-        /// <returns></returns>
-        public static bool TryGetString(this ReadOnlyMemory<char> readOnlyMemory, out string text, out int start, out int length)
-        {
-            if (readOnlyMemory.GetObjectStartLength(out int offset, out int count) is string s)
-            {
-                text = s;
-                start = offset;
-                length = count;
-                return true;
-            }
-            else
-            {
-                text = null;
-                start = 0;
-                length = 0;
-                return false;
-            }
-        }
     }
 }
index 427f05c..b625ece 100644 (file)
@@ -746,10 +746,10 @@ namespace System
         /// Creates a new Span over the portion of the target array beginning
         /// at 'start' index and ending at 'end' index (exclusive).
         /// </summary>
-        /// <param name="array">The target array.</param>
+        /// <param name="segment">The target array.</param>
         /// <param name="start">The index at which to begin the Span.</param>
-        /// <remarks>Returns default when <paramref name="array"/> is null.</remarks>
-        /// <exception cref="System.ArrayTypeMismatchException">Thrown when <paramref name="array"/> is covariant and array's type is not exactly T[].</exception>
+        /// <remarks>Returns default when <paramref name="segment"/> is null.</remarks>
+        /// <exception cref="System.ArrayTypeMismatchException">Thrown when <paramref name="segment"/> is covariant and array's type is not exactly T[].</exception>
         /// <exception cref="System.ArgumentOutOfRangeException">
         /// Thrown when the specified <paramref name="start"/> or end index is not in the range (&lt;0 or &gt;=segment.Count).
         /// </exception>
@@ -766,11 +766,11 @@ namespace System
         /// Creates a new Span over the portion of the target array beginning
         /// at 'start' index and ending at 'end' index (exclusive).
         /// </summary>
-        /// <param name="array">The target array.</param>
+        /// <param name="segment">The target array.</param>
         /// <param name="start">The index at which to begin the Span.</param>
         /// <param name="length">The number of items in the Span.</param>
-        /// <remarks>Returns default when <paramref name="array"/> is null.</remarks>
-        /// <exception cref="System.ArrayTypeMismatchException">Thrown when <paramref name="array"/> is covariant and array's type is not exactly T[].</exception>
+        /// <remarks>Returns default when <paramref name="segment"/> is null.</remarks>
+        /// <exception cref="System.ArrayTypeMismatchException">Thrown when <paramref name="segment"/> is covariant and array's type is not exactly T[].</exception>
         /// <exception cref="System.ArgumentOutOfRangeException">
         /// Thrown when the specified <paramref name="start"/> or end index is not in the range (&lt;0 or &gt;=segment.Count).
         /// </exception>
@@ -854,10 +854,10 @@ namespace System
         /// Creates a new memory over the portion of the target array beginning
         /// at 'start' index and ending at 'end' index (exclusive).
         /// </summary>
-        /// <param name="array">The target array.</param>
+        /// <param name="segment">The target array.</param>
         /// <param name="start">The index at which to begin the memory.</param>
-        /// <remarks>Returns default when <paramref name="array"/> is null.</remarks>
-        /// <exception cref="System.ArrayTypeMismatchException">Thrown when <paramref name="array"/> is covariant and array's type is not exactly T[].</exception>
+        /// <remarks>Returns default when <paramref name="segment"/> is null.</remarks>
+        /// <exception cref="System.ArrayTypeMismatchException">Thrown when <paramref name="segment"/> is covariant and array's type is not exactly T[].</exception>
         /// <exception cref="System.ArgumentOutOfRangeException">
         /// Thrown when the specified <paramref name="start"/> or end index is not in the range (&lt;0 or &gt;=segment.Count).
         /// </exception>
@@ -873,11 +873,11 @@ namespace System
         /// Creates a new memory over the portion of the target array beginning
         /// at 'start' index and ending at 'end' index (exclusive).
         /// </summary>
-        /// <param name="array">The target array.</param>
+        /// <param name="segment">The target array.</param>
         /// <param name="start">The index at which to begin the memory.</param>
         /// <param name="length">The number of items in the memory.</param>
-        /// <remarks>Returns default when <paramref name="array"/> is null.</remarks>
-        /// <exception cref="System.ArrayTypeMismatchException">Thrown when <paramref name="array"/> is covariant and array's type is not exactly T[].</exception>
+        /// <remarks>Returns default when <paramref name="segment"/> is null.</remarks>
+        /// <exception cref="System.ArrayTypeMismatchException">Thrown when <paramref name="segment"/> is covariant and array's type is not exactly T[].</exception>
         /// <exception cref="System.ArgumentOutOfRangeException">
         /// Thrown when the specified <paramref name="start"/> or end index is not in the range (&lt;0 or &gt;=segment.Count).
         /// </exception>
index 82aa73d..275f473 100644 (file)
@@ -68,12 +68,12 @@ namespace System.Numerics
         /// Returns a vector containing all zeroes.
         /// </summary>
         public static Vector<T> Zero
-        { 
+        {
             [Intrinsic]
             get
             {
                 return s_zero;
-            } 
+            }
         }
         private static readonly Vector<T> s_zero = new Vector<T>();
 
@@ -84,7 +84,7 @@ namespace System.Numerics
         {
             [Intrinsic]
             get
-            { 
+            {
                 return s_one;
             }
         }
@@ -999,7 +999,7 @@ namespace System.Numerics
         [MethodImplAttribute(MethodImplOptions.AggressiveInlining)]
         public static Vector<T> operator ~(Vector<T> value)
         {
-            return allOnes ^ value;
+            return s_allOnes ^ value;
         }
         #endregion Bitwise Operators
 
index 49cdacc..0e1220d 100644 (file)
@@ -8,6 +8,108 @@ using System.Threading.Tasks;
 
 namespace System.Runtime.CompilerServices
 {
+    /// <summary>Represents a builder for asynchronous methods that return a <see cref="ValueTask"/>.</summary>
+    [StructLayout(LayoutKind.Auto)]
+    public struct AsyncValueTaskMethodBuilder
+    {
+        /// <summary>The <see cref="AsyncTaskMethodBuilder"/> to which most operations are delegated.</summary>
+        private AsyncTaskMethodBuilder _methodBuilder; // mutable struct; do not make it readonly
+        /// <summary>true if completed synchronously and successfully; otherwise, false.</summary>
+        private bool _haveResult;
+        /// <summary>true if the builder should be used for setting/getting the result; otherwise, false.</summary>
+        private bool _useBuilder;
+
+        /// <summary>Creates an instance of the <see cref="AsyncValueTaskMethodBuilder"/> struct.</summary>
+        /// <returns>The initialized instance.</returns>
+        public static AsyncValueTaskMethodBuilder Create() =>
+#if CORERT
+            // corert's AsyncTaskMethodBuilder.Create() currently does additional debugger-related
+            // work, so we need to delegate to it.
+            new AsyncValueTaskMethodBuilder() { _methodBuilder = AsyncTaskMethodBuilder.Create() };
+#else
+            // _methodBuilder should be initialized to AsyncTaskMethodBuilder.Create(), but on coreclr
+            // that Create() is a nop, so we can just return the default here.
+            default;
+#endif
+
+        /// <summary>Begins running the builder with the associated state machine.</summary>
+        /// <typeparam name="TStateMachine">The type of the state machine.</typeparam>
+        /// <param name="stateMachine">The state machine instance, passed by reference.</param>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        public void Start<TStateMachine>(ref TStateMachine stateMachine) where TStateMachine : IAsyncStateMachine =>
+            // will provide the right ExecutionContext semantics
+#if netstandard
+            _methodBuilder.Start(ref stateMachine);
+#else
+            AsyncMethodBuilderCore.Start(ref stateMachine);
+#endif
+
+        /// <summary>Associates the builder with the specified state machine.</summary>
+        /// <param name="stateMachine">The state machine instance to associate with the builder.</param>
+        public void SetStateMachine(IAsyncStateMachine stateMachine) => _methodBuilder.SetStateMachine(stateMachine);
+
+        /// <summary>Marks the task as successfully completed.</summary>
+        public void SetResult()
+        {
+            if (_useBuilder)
+            {
+                _methodBuilder.SetResult();
+            }
+            else
+            {
+                _haveResult = true;
+            }
+        }
+
+        /// <summary>Marks the task as failed and binds the specified exception to the task.</summary>
+        /// <param name="exception">The exception to bind to the task.</param>
+        public void SetException(Exception exception) => _methodBuilder.SetException(exception);
+
+        /// <summary>Gets the task for this builder.</summary>
+        public ValueTask Task
+        {
+            get
+            {
+                if (_haveResult)
+                {
+                    return default;
+                }
+                else
+                {
+                    _useBuilder = true;
+                    return new ValueTask(_methodBuilder.Task);
+                }
+            }
+        }
+
+        /// <summary>Schedules the state machine to proceed to the next action when the specified awaiter completes.</summary>
+        /// <typeparam name="TAwaiter">The type of the awaiter.</typeparam>
+        /// <typeparam name="TStateMachine">The type of the state machine.</typeparam>
+        /// <param name="awaiter">The awaiter.</param>
+        /// <param name="stateMachine">The state machine.</param>
+        public void AwaitOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine)
+            where TAwaiter : INotifyCompletion
+            where TStateMachine : IAsyncStateMachine
+        {
+            _useBuilder = true;
+            _methodBuilder.AwaitOnCompleted(ref awaiter, ref stateMachine);
+        }
+
+        /// <summary>Schedules the state machine to proceed to the next action when the specified awaiter completes.</summary>
+        /// <typeparam name="TAwaiter">The type of the awaiter.</typeparam>
+        /// <typeparam name="TStateMachine">The type of the state machine.</typeparam>
+        /// <param name="awaiter">The awaiter.</param>
+        /// <param name="stateMachine">The state machine.</param>
+        [SecuritySafeCritical]
+        public void AwaitUnsafeOnCompleted<TAwaiter, TStateMachine>(ref TAwaiter awaiter, ref TStateMachine stateMachine)
+            where TAwaiter : ICriticalNotifyCompletion
+            where TStateMachine : IAsyncStateMachine
+        {
+            _useBuilder = true;
+            _methodBuilder.AwaitUnsafeOnCompleted(ref awaiter, ref stateMachine);
+        }
+    }
+
     /// <summary>Represents a builder for asynchronous methods that returns a <see cref="ValueTask{TResult}"/>.</summary>
     /// <typeparam name="TResult">The type of the result.</typeparam>
     [StructLayout(LayoutKind.Auto)]
@@ -32,7 +134,7 @@ namespace System.Runtime.CompilerServices
 #else
             // _methodBuilder should be initialized to AsyncTaskMethodBuilder<TResult>.Create(), but on coreclr
             // that Create() is a nop, so we can just return the default here.
-            default(AsyncValueTaskMethodBuilder<TResult>);
+            default;
 #endif
 
         /// <summary>Begins running the builder with the associated state machine.</summary>
index f22b9d9..5994531 100644 (file)
@@ -5,9 +5,115 @@
 using System.Diagnostics;
 using System.Runtime.InteropServices;
 using System.Threading.Tasks;
+using System.Threading.Tasks.Sources;
+
+#if !netstandard
+using Internal.Runtime.CompilerServices;
+#endif
 
 namespace System.Runtime.CompilerServices
 {
+    /// <summary>Provides an awaitable type that enables configured awaits on a <see cref="ValueTask"/>.</summary>
+    [StructLayout(LayoutKind.Auto)]
+    public readonly struct ConfiguredValueTaskAwaitable
+    {
+        /// <summary>The wrapped <see cref="Task"/>.</summary>
+        private readonly ValueTask _value;
+
+        /// <summary>Initializes the awaitable.</summary>
+        /// <param name="value">The wrapped <see cref="ValueTask"/>.</param>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        internal ConfiguredValueTaskAwaitable(ValueTask value) => _value = value;
+
+        /// <summary>Returns an awaiter for this <see cref="ConfiguredValueTaskAwaitable"/> instance.</summary>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        public ConfiguredValueTaskAwaiter GetAwaiter() => new ConfiguredValueTaskAwaiter(_value);
+
+        /// <summary>Provides an awaiter for a <see cref="ConfiguredValueTaskAwaitable"/>.</summary>
+        [StructLayout(LayoutKind.Auto)]
+        public readonly struct ConfiguredValueTaskAwaiter : ICriticalNotifyCompletion
+#if CORECLR
+            , IValueTaskAwaiter
+#endif
+        {
+            /// <summary>The value being awaited.</summary>
+            private readonly ValueTask _value;
+
+            /// <summary>Initializes the awaiter.</summary>
+            /// <param name="value">The value to be awaited.</param>
+            [MethodImpl(MethodImplOptions.AggressiveInlining)]
+            internal ConfiguredValueTaskAwaiter(ValueTask value) => _value = value;
+
+            /// <summary>Gets whether the <see cref="ConfiguredValueTaskAwaitable"/> has completed.</summary>
+            public bool IsCompleted
+            {
+                [MethodImpl(MethodImplOptions.AggressiveInlining)]
+                get => _value.IsCompleted;
+            }
+
+            /// <summary>Gets the result of the ValueTask.</summary>
+            [MethodImpl(MethodImplOptions.AggressiveInlining)]
+            [StackTraceHidden]
+            public void GetResult() => _value.ThrowIfCompletedUnsuccessfully();
+
+            /// <summary>Schedules the continuation action for the <see cref="ConfiguredValueTaskAwaitable"/>.</summary>
+            public void OnCompleted(Action continuation)
+            {
+                if (_value.ObjectIsTask)
+                {
+                    _value.UnsafeGetTask().ConfigureAwait(_value.ContinueOnCapturedContext).GetAwaiter().OnCompleted(continuation);
+                }
+                else if (_value._obj != null)
+                {
+                    _value.UnsafeGetValueTaskSource().OnCompleted(ValueTaskAwaiter.s_invokeActionDelegate, continuation, _value._token,
+                        ValueTaskSourceOnCompletedFlags.FlowExecutionContext |
+                            (_value.ContinueOnCapturedContext ? ValueTaskSourceOnCompletedFlags.UseSchedulingContext : ValueTaskSourceOnCompletedFlags.None));
+                }
+                else
+                {
+                    ValueTask.CompletedTask.ConfigureAwait(_value.ContinueOnCapturedContext).GetAwaiter().OnCompleted(continuation);
+                }
+            }
+
+            /// <summary>Schedules the continuation action for the <see cref="ConfiguredValueTaskAwaitable"/>.</summary>
+            public void UnsafeOnCompleted(Action continuation)
+            {
+                if (_value.ObjectIsTask)
+                {
+                    _value.UnsafeGetTask().ConfigureAwait(_value.ContinueOnCapturedContext).GetAwaiter().UnsafeOnCompleted(continuation);
+                }
+                else if (_value._obj != null)
+                {
+                    _value.UnsafeGetValueTaskSource().OnCompleted(ValueTaskAwaiter.s_invokeActionDelegate, continuation, _value._token,
+                        _value.ContinueOnCapturedContext ? ValueTaskSourceOnCompletedFlags.UseSchedulingContext : ValueTaskSourceOnCompletedFlags.None);
+                }
+                else
+                {
+                    ValueTask.CompletedTask.ConfigureAwait(_value.ContinueOnCapturedContext).GetAwaiter().UnsafeOnCompleted(continuation);
+                }
+            }
+
+#if CORECLR
+            void IValueTaskAwaiter.AwaitUnsafeOnCompleted(IAsyncStateMachineBox box)
+            {
+                if (_value.ObjectIsTask)
+                {
+                    TaskAwaiter.UnsafeOnCompletedInternal(_value.UnsafeGetTask(), box, _value.ContinueOnCapturedContext);
+                }
+                else if (_value._obj != null)
+                {
+                    _value.UnsafeGetValueTaskSource().OnCompleted(ValueTaskAwaiter.s_invokeAsyncStateMachineBox, box, _value._token,
+                        _value.ContinueOnCapturedContext ? ValueTaskSourceOnCompletedFlags.UseSchedulingContext : ValueTaskSourceOnCompletedFlags.None);
+                }
+                else
+                {
+                    TaskAwaiter.UnsafeOnCompletedInternal(Task.CompletedTask, box, _value.ContinueOnCapturedContext);
+                }
+            }
+#endif
+        }
+    }
+
     /// <summary>Provides an awaitable type that enables configured awaits on a <see cref="ValueTask{TResult}"/>.</summary>
     /// <typeparam name="TResult">The type of the result produced.</typeparam>
     [StructLayout(LayoutKind.Auto)]
@@ -15,78 +121,98 @@ namespace System.Runtime.CompilerServices
     {
         /// <summary>The wrapped <see cref="ValueTask{TResult}"/>.</summary>
         private readonly ValueTask<TResult> _value;
-        /// <summary>true to attempt to marshal the continuation back to the original context captured; otherwise, false.</summary>
-        private readonly bool _continueOnCapturedContext;
 
         /// <summary>Initializes the awaitable.</summary>
         /// <param name="value">The wrapped <see cref="ValueTask{TResult}"/>.</param>
-        /// <param name="continueOnCapturedContext">
-        /// true to attempt to marshal the continuation back to the original synchronization context captured; otherwise, false.
-        /// </param>
-        internal ConfiguredValueTaskAwaitable(ValueTask<TResult> value, bool continueOnCapturedContext)
-        {
-            _value = value;
-            _continueOnCapturedContext = continueOnCapturedContext;
-        }
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        internal ConfiguredValueTaskAwaitable(ValueTask<TResult> value) => _value = value;
 
         /// <summary>Returns an awaiter for this <see cref="ConfiguredValueTaskAwaitable{TResult}"/> instance.</summary>
-        public ConfiguredValueTaskAwaiter GetAwaiter() =>
-            new ConfiguredValueTaskAwaiter(_value, _continueOnCapturedContext);
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        public ConfiguredValueTaskAwaiter GetAwaiter() => new ConfiguredValueTaskAwaiter(_value);
 
         /// <summary>Provides an awaiter for a <see cref="ConfiguredValueTaskAwaitable{TResult}"/>.</summary>
         [StructLayout(LayoutKind.Auto)]
-        public readonly struct ConfiguredValueTaskAwaiter : ICriticalNotifyCompletion, IConfiguredValueTaskAwaiter
+        public readonly struct ConfiguredValueTaskAwaiter : ICriticalNotifyCompletion
+#if CORECLR
+            , IValueTaskAwaiter
+#endif
         {
             /// <summary>The value being awaited.</summary>
             private readonly ValueTask<TResult> _value;
-            /// <summary>The value to pass to ConfigureAwait.</summary>
-            internal readonly bool _continueOnCapturedContext;
 
             /// <summary>Initializes the awaiter.</summary>
             /// <param name="value">The value to be awaited.</param>
-            /// <param name="continueOnCapturedContext">The value to pass to ConfigureAwait.</param>
-            internal ConfiguredValueTaskAwaiter(ValueTask<TResult> value, bool continueOnCapturedContext)
-            {
-                _value = value;
-                _continueOnCapturedContext = continueOnCapturedContext;
-            }
+            [MethodImpl(MethodImplOptions.AggressiveInlining)]
+            internal ConfiguredValueTaskAwaiter(ValueTask<TResult> value) => _value = value;
 
             /// <summary>Gets whether the <see cref="ConfiguredValueTaskAwaitable{TResult}"/> has completed.</summary>
-            public bool IsCompleted => _value.IsCompleted;
+            public bool IsCompleted
+            {
+                [MethodImpl(MethodImplOptions.AggressiveInlining)]
+                get => _value.IsCompleted;
+            }
 
             /// <summary>Gets the result of the ValueTask.</summary>
+            [MethodImpl(MethodImplOptions.AggressiveInlining)]
             [StackTraceHidden]
-            public TResult GetResult() =>
-                _value._task == null ? 
-                    _value._result : 
-                    _value._task.GetAwaiter().GetResult();
+            public TResult GetResult() => _value.Result;
 
             /// <summary>Schedules the continuation action for the <see cref="ConfiguredValueTaskAwaitable{TResult}"/>.</summary>
-            public void OnCompleted(Action continuation) =>
-                _value.AsTask().ConfigureAwait(_continueOnCapturedContext).GetAwaiter().OnCompleted(continuation);
+            public void OnCompleted(Action continuation)
+            {
+                if (_value.ObjectIsTask)
+                {
+                    _value.UnsafeGetTask().ConfigureAwait(_value.ContinueOnCapturedContext).GetAwaiter().OnCompleted(continuation);
+                }
+                else if (_value._obj != null)
+                {
+                    _value.UnsafeGetValueTaskSource().OnCompleted(ValueTaskAwaiter.s_invokeActionDelegate, continuation, _value._token,
+                        ValueTaskSourceOnCompletedFlags.FlowExecutionContext |
+                            (_value.ContinueOnCapturedContext ? ValueTaskSourceOnCompletedFlags.UseSchedulingContext : ValueTaskSourceOnCompletedFlags.None));
+                }
+                else
+                {
+                    ValueTask.CompletedTask.ConfigureAwait(_value.ContinueOnCapturedContext).GetAwaiter().OnCompleted(continuation);
+                }
+            }
 
             /// <summary>Schedules the continuation action for the <see cref="ConfiguredValueTaskAwaitable{TResult}"/>.</summary>
-            public void UnsafeOnCompleted(Action continuation) =>
-                _value.AsTask().ConfigureAwait(_continueOnCapturedContext).GetAwaiter().UnsafeOnCompleted(continuation);
-
-            /// <summary>Gets the task underlying <see cref="_value"/>.</summary>
-            internal Task<TResult> AsTask() => _value.AsTask();
+            public void UnsafeOnCompleted(Action continuation)
+            {
+                if (_value.ObjectIsTask)
+                {
+                    _value.UnsafeGetTask().ConfigureAwait(_value.ContinueOnCapturedContext).GetAwaiter().UnsafeOnCompleted(continuation);
+                }
+                else if (_value._obj != null)
+                {
+                    _value.UnsafeGetValueTaskSource().OnCompleted(ValueTaskAwaiter.s_invokeActionDelegate, continuation, _value._token,
+                        _value.ContinueOnCapturedContext ? ValueTaskSourceOnCompletedFlags.UseSchedulingContext : ValueTaskSourceOnCompletedFlags.None);
+                }
+                else
+                {
+                    ValueTask.CompletedTask.ConfigureAwait(_value.ContinueOnCapturedContext).GetAwaiter().UnsafeOnCompleted(continuation);
+                }
+            }
 
-            /// <summary>Gets the task underlying the incomplete <see cref="_value"/>.</summary>
-            /// <remarks>This method is used when awaiting and IsCompleted returned false; thus we expect the value task to be wrapping a non-null task.</remarks>
-            Task IConfiguredValueTaskAwaiter.GetTask(out bool continueOnCapturedContext)
+#if CORECLR
+            void IValueTaskAwaiter.AwaitUnsafeOnCompleted(IAsyncStateMachineBox box)
             {
-                continueOnCapturedContext = _continueOnCapturedContext;
-                return _value.AsTaskExpectNonNull();
+                if (_value.ObjectIsTask)
+                {
+                    TaskAwaiter.UnsafeOnCompletedInternal(_value.UnsafeGetTask(), box, _value.ContinueOnCapturedContext);
+                }
+                else if (_value._obj != null)
+                {
+                    _value.UnsafeGetValueTaskSource().OnCompleted(ValueTaskAwaiter.s_invokeAsyncStateMachineBox, box, _value._token,
+                        _value.ContinueOnCapturedContext ? ValueTaskSourceOnCompletedFlags.UseSchedulingContext : ValueTaskSourceOnCompletedFlags.None);
+                }
+                else
+                {
+                    TaskAwaiter.UnsafeOnCompletedInternal(Task.CompletedTask, box, _value.ContinueOnCapturedContext);
+                }
             }
+#endif
         }
     }
-
-    /// <summary>
-    /// Internal interface used to enable extract the Task from arbitrary configured ValueTask awaiters.
-    /// </summary>
-    internal interface IConfiguredValueTaskAwaiter
-    {
-        Task GetTask(out bool continueOnCapturedContext);
-    }
 }
index c4a8558..27dd645 100644 (file)
@@ -9,6 +9,9 @@ namespace System.Runtime.CompilerServices
     {
         public TypeForwardedFromAttribute(string assemblyFullName)
         {
+            if (string.IsNullOrEmpty(assemblyFullName))
+                throw new ArgumentNullException(nameof(assemblyFullName));
+
             AssemblyFullName = assemblyFullName;
         }
 
index 3f212d8..e019f66 100644 (file)
 
 using System.Diagnostics;
 using System.Threading.Tasks;
+using System.Threading.Tasks.Sources;
 
 namespace System.Runtime.CompilerServices
 {
+    /// <summary>Provides an awaiter for a <see cref="ValueTask"/>.</summary>
+    public readonly struct ValueTaskAwaiter : ICriticalNotifyCompletion
+#if CORECLR
+            , IValueTaskAwaiter
+#endif
+    {
+        /// <summary>Shim used to invoke an <see cref="Action"/> passed as the state argument to a <see cref="Action{Object}"/>.</summary>
+        internal static readonly Action<object> s_invokeActionDelegate = state =>
+        {
+            if (!(state is Action action))
+            {
+                ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.state);
+                return;
+            }
+
+            action();
+        };
+        /// <summary>The value being awaited.</summary>
+        private readonly ValueTask _value;
+
+        /// <summary>Initializes the awaiter.</summary>
+        /// <param name="value">The value to be awaited.</param>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        internal ValueTaskAwaiter(ValueTask value) => _value = value;
+
+        /// <summary>Gets whether the <see cref="ValueTask"/> has completed.</summary>
+        public bool IsCompleted
+        {
+            [MethodImpl(MethodImplOptions.AggressiveInlining)]
+            get => _value.IsCompleted;
+        }
+
+        /// <summary>Gets the result of the ValueTask.</summary>
+        [StackTraceHidden]
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        public void GetResult() => _value.ThrowIfCompletedUnsuccessfully();
+
+        /// <summary>Schedules the continuation action for this ValueTask.</summary>
+        public void OnCompleted(Action continuation)
+        {
+            if (_value.ObjectIsTask)
+            {
+                _value.UnsafeGetTask().GetAwaiter().OnCompleted(continuation);
+            }
+            else if (_value._obj != null)
+            {
+                _value.UnsafeGetValueTaskSource().OnCompleted(s_invokeActionDelegate, continuation, _value._token, ValueTaskSourceOnCompletedFlags.UseSchedulingContext | ValueTaskSourceOnCompletedFlags.FlowExecutionContext);
+            }
+            else
+            {
+                ValueTask.CompletedTask.GetAwaiter().OnCompleted(continuation);
+            }
+        }
+
+        /// <summary>Schedules the continuation action for this ValueTask.</summary>
+        public void UnsafeOnCompleted(Action continuation)
+        {
+            if (_value.ObjectIsTask)
+            {
+                _value.UnsafeGetTask().GetAwaiter().UnsafeOnCompleted(continuation);
+            }
+            else if (_value._obj != null)
+            {
+                _value.UnsafeGetValueTaskSource().OnCompleted(s_invokeActionDelegate, continuation, _value._token, ValueTaskSourceOnCompletedFlags.UseSchedulingContext);
+            }
+            else
+            {
+                ValueTask.CompletedTask.GetAwaiter().UnsafeOnCompleted(continuation);
+            }
+        }
+
+#if CORECLR
+        void IValueTaskAwaiter.AwaitUnsafeOnCompleted(IAsyncStateMachineBox box)
+        {
+            if (_value.ObjectIsTask)
+            {
+                TaskAwaiter.UnsafeOnCompletedInternal(_value.UnsafeGetTask(), box, continueOnCapturedContext: true);
+            }
+            else if (_value._obj != null)
+            {
+                _value.UnsafeGetValueTaskSource().OnCompleted(s_invokeAsyncStateMachineBox, box, _value._token, ValueTaskSourceOnCompletedFlags.UseSchedulingContext);
+            }
+            else
+            {
+                TaskAwaiter.UnsafeOnCompletedInternal(Task.CompletedTask, box, continueOnCapturedContext: true);
+            }
+        }
+
+        /// <summary>Shim used to invoke <see cref="ITaskCompletionAction.Invoke"/> of the supplied <see cref="IAsyncStateMachineBox"/>.</summary>
+        internal static readonly Action<object> s_invokeAsyncStateMachineBox = state =>
+        {
+            if (!(state is IAsyncStateMachineBox box))
+            {
+                ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.state);
+                return;
+            }
+
+            box.Invoke(null);
+        };
+#endif
+    }
+
     /// <summary>Provides an awaiter for a <see cref="ValueTask{TResult}"/>.</summary>
-    public readonly struct ValueTaskAwaiter<TResult> : ICriticalNotifyCompletion, IValueTaskAwaiter
+    public readonly struct ValueTaskAwaiter<TResult> : ICriticalNotifyCompletion
+#if CORECLR
+            , IValueTaskAwaiter
+#endif
     {
         /// <summary>The value being awaited.</summary>
         private readonly ValueTask<TResult> _value;
 
         /// <summary>Initializes the awaiter.</summary>
         /// <param name="value">The value to be awaited.</param>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         internal ValueTaskAwaiter(ValueTask<TResult> value) => _value = value;
 
         /// <summary>Gets whether the <see cref="ValueTask{TResult}"/> has completed.</summary>
-        public bool IsCompleted => _value.IsCompleted;
+        public bool IsCompleted
+        {
+            [MethodImpl(MethodImplOptions.AggressiveInlining)]
+            get => _value.IsCompleted;
+        }
 
         /// <summary>Gets the result of the ValueTask.</summary>
         [StackTraceHidden]
-        public TResult GetResult() =>
-            _value._task == null ? 
-                _value._result : 
-                _value._task.GetAwaiter().GetResult();
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        public TResult GetResult() => _value.Result;
 
         /// <summary>Schedules the continuation action for this ValueTask.</summary>
-        public void OnCompleted(Action continuation) =>
-            _value.AsTask().ConfigureAwait(continueOnCapturedContext: true).GetAwaiter().OnCompleted(continuation);
+        public void OnCompleted(Action continuation)
+        {
+            if (_value.ObjectIsTask)
+            {
+                _value.UnsafeGetTask().GetAwaiter().OnCompleted(continuation);
+            }
+            else if (_value._obj != null)
+            {
+                _value.UnsafeGetValueTaskSource().OnCompleted(ValueTaskAwaiter.s_invokeActionDelegate, continuation, _value._token, ValueTaskSourceOnCompletedFlags.UseSchedulingContext | ValueTaskSourceOnCompletedFlags.FlowExecutionContext);
+            }
+            else
+            {
+                ValueTask.CompletedTask.GetAwaiter().OnCompleted(continuation);
+            }
+        }
 
         /// <summary>Schedules the continuation action for this ValueTask.</summary>
-        public void UnsafeOnCompleted(Action continuation) =>
-            _value.AsTask().ConfigureAwait(continueOnCapturedContext: true).GetAwaiter().UnsafeOnCompleted(continuation);
-
-        /// <summary>Gets the task underlying <see cref="_value"/>.</summary>
-        internal Task<TResult> AsTask() => _value.AsTask();
+        public void UnsafeOnCompleted(Action continuation)
+        {
+            if (_value.ObjectIsTask)
+            {
+                _value.UnsafeGetTask().GetAwaiter().UnsafeOnCompleted(continuation);
+            }
+            else if (_value._obj != null)
+            {
+                _value.UnsafeGetValueTaskSource().OnCompleted(ValueTaskAwaiter.s_invokeActionDelegate, continuation, _value._token, ValueTaskSourceOnCompletedFlags.UseSchedulingContext);
+            }
+            else
+            {
+                ValueTask.CompletedTask.GetAwaiter().UnsafeOnCompleted(continuation);
+            }
+        }
 
-        /// <summary>Gets the task underlying the incomplete <see cref="_value"/>.</summary>
-        /// <remarks>This method is used when awaiting and IsCompleted returned false; thus we expect the value task to be wrapping a non-null task.</remarks>
-        Task IValueTaskAwaiter.GetTask() => _value.AsTaskExpectNonNull();
+#if CORECLR
+        void IValueTaskAwaiter.AwaitUnsafeOnCompleted(IAsyncStateMachineBox box)
+        {
+            if (_value.ObjectIsTask)
+            {
+                TaskAwaiter.UnsafeOnCompletedInternal(_value.UnsafeGetTask(), box, continueOnCapturedContext: true);
+            }
+            else if (_value._obj != null)
+            {
+                _value.UnsafeGetValueTaskSource().OnCompleted(ValueTaskAwaiter.s_invokeAsyncStateMachineBox, box, _value._token, ValueTaskSourceOnCompletedFlags.UseSchedulingContext);
+            }
+            else
+            {
+                TaskAwaiter.UnsafeOnCompletedInternal(Task.CompletedTask, box, continueOnCapturedContext: true);
+            }
+        }
+#endif
     }
 
-    /// <summary>
-    /// Internal interface used to enable extract the Task from arbitrary ValueTask awaiters.
-    /// </summary>>
+#if CORECLR
+    /// <summary>Internal interface used to enable optimizations from <see cref="AsyncTaskMethodBuilder"/> on <see cref="ValueTask"/>.</summary>>
     internal interface IValueTaskAwaiter
     {
-        Task GetTask();
+        /// <summary>Invoked to set <see cref="ITaskCompletionAction.Invoke"/> of the <paramref name="box"/> as the awaiter's continuation.</summary>
+        /// <param name="box">The box object.</param>
+        void AwaitUnsafeOnCompleted(IAsyncStateMachineBox box);
     }
+#endif
 }
index 01c98ee..5d2a444 100644 (file)
@@ -60,9 +60,38 @@ namespace System.Runtime.InteropServices
             if (RuntimeHelpers.IsReferenceOrContainsReferences<TTo>())
                 ThrowHelper.ThrowInvalidTypeWithPointersNotSupported(typeof(TTo));
 
+            // Use unsigned integers - unsigned division by constant (especially by power of 2)
+            // and checked casts are faster and smaller.
+            uint fromSize = (uint)Unsafe.SizeOf<TFrom>();
+            uint toSize = (uint)Unsafe.SizeOf<TTo>();
+            uint fromLength = (uint)source.Length;
+            int toLength;
+            if (fromSize == toSize)
+            {
+                // Special case for same size types - `(ulong)fromLength * (ulong)fromSize / (ulong)toSize`
+                // should be optimized to just `length` but the JIT doesn't do that today.
+                toLength = (int)fromLength;
+            }
+            else if (fromSize == 1)
+            {
+                // Special case for byte sized TFrom - `(ulong)fromLength * (ulong)fromSize / (ulong)toSize`
+                // becomes `(ulong)fromLength / (ulong)toSize` but the JIT can't narrow it down to `int`
+                // and can't eliminate the checked cast. This also avoids a 32 bit specific issue,
+                // the JIT can't eliminate long multiply by 1.
+                toLength = (int)(fromLength / toSize);
+            }
+            else
+            {
+                // Ensure that casts are done in such a way that the JIT is able to "see"
+                // the uint->ulong casts and the multiply together so that on 32 bit targets
+                // 32x32to64 multiplication is used.
+                ulong toLengthUInt64 = (ulong)fromLength * (ulong)fromSize / (ulong)toSize;
+                toLength = checked((int)toLengthUInt64);
+            }
+
             return new Span<TTo>(
                 ref Unsafe.As<TFrom, TTo>(ref source._pointer.Value),
-                checked((int)((long)source.Length * Unsafe.SizeOf<TFrom>() / Unsafe.SizeOf<TTo>())));
+                toLength);
         }
 
         /// <summary>
@@ -86,9 +115,38 @@ namespace System.Runtime.InteropServices
             if (RuntimeHelpers.IsReferenceOrContainsReferences<TTo>())
                 ThrowHelper.ThrowInvalidTypeWithPointersNotSupported(typeof(TTo));
 
+            // Use unsigned integers - unsigned division by constant (especially by power of 2)
+            // and checked casts are faster and smaller.
+            uint fromSize = (uint)Unsafe.SizeOf<TFrom>();
+            uint toSize = (uint)Unsafe.SizeOf<TTo>();
+            uint fromLength = (uint)source.Length;
+            int toLength;
+            if (fromSize == toSize)
+            {
+                // Special case for same size types - `(ulong)fromLength * (ulong)fromSize / (ulong)toSize`
+                // should be optimized to just `length` but the JIT doesn't do that today.
+                toLength = (int)fromLength;
+            }
+            else if (fromSize == 1)
+            {
+                // Special case for byte sized TFrom - `(ulong)fromLength * (ulong)fromSize / (ulong)toSize`
+                // becomes `(ulong)fromLength / (ulong)toSize` but the JIT can't narrow it down to `int`
+                // and can't eliminate the checked cast. This also avoids a 32 bit specific issue,
+                // the JIT can't eliminate long multiply by 1.
+                toLength = (int)(fromLength / toSize);
+            }
+            else
+            {
+                // Ensure that casts are done in such a way that the JIT is able to "see"
+                // the uint->ulong casts and the multiply together so that on 32 bit targets
+                // 32x32to64 multiplication is used.
+                ulong toLengthUInt64 = (ulong)fromLength * (ulong)fromSize / (ulong)toSize;
+                toLength = checked((int)toLengthUInt64);
+            }
+
             return new ReadOnlySpan<TTo>(
                 ref Unsafe.As<TFrom, TTo>(ref MemoryMarshal.GetReference(source)),
-                checked((int)((long)source.Length * Unsafe.SizeOf<TFrom>() / Unsafe.SizeOf<TTo>())));
+                toLength);
         }
 
         /// <summary>
index 6544081..316ce12 100644 (file)
@@ -98,5 +98,29 @@ namespace System.Runtime.InteropServices
             for (int i = 0; i < memory.Length; i++)
                 yield return memory.Span[i];
         }
+
+        /// <summary>Attempts to get the underlying <see cref="string"/> from a <see cref="ReadOnlyMemory{T}"/>.</summary>
+        /// <param name="readOnlyMemory">The memory that may be wrapping a <see cref="string"/> object.</param>
+        /// <param name="text">The string.</param>
+        /// <param name="start">The starting location in <paramref name="text"/>.</param>
+        /// <param name="length">The number of items in <paramref name="text"/>.</param>
+        /// <returns></returns>
+        public static bool TryGetString(ReadOnlyMemory<char> readOnlyMemory, out string text, out int start, out int length)
+        {
+            if (readOnlyMemory.GetObjectStartLength(out int offset, out int count) is string s)
+            {
+                text = s;
+                start = offset;
+                length = count;
+                return true;
+            }
+            else
+            {
+                text = null;
+                start = 0;
+                length = 0;
+                return false;
+            }
+        }
     }
 }
diff --git a/src/mscorlib/shared/System/Span.NonGeneric.cs b/src/mscorlib/shared/System/Span.NonGeneric.cs
deleted file mode 100644 (file)
index 4f2892d..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-// Licensed to the .NET Foundation under one or more agreements.
-// The .NET Foundation licenses this file to you under the MIT license.
-// See the LICENSE file in the project root for more information.
-
-using System.Diagnostics;
-using System.Globalization;
-using System.Runtime;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-using Internal.Runtime.CompilerServices;
-
-#if BIT64
-using nuint = System.UInt64;
-#else
-using nuint = System.UInt32;
-#endif
-
-namespace System
-{
-    /// <summary>
-    /// Extension methods and non-generic helpers for Span, ReadOnlySpan, Memory, and ReadOnlyMemory.
-    /// </summary>
-    public static class Span
-    {
-        public static Span<byte> AsBytes<T>(Span<T> source)
-            where T : struct => source.AsBytes();
-
-        public static ReadOnlySpan<byte> AsBytes<T>(ReadOnlySpan<T> source)
-            where T : struct => source.AsBytes();
-
-        // TODO: Delete once the AsReadOnlySpan -> AsSpan rename propages through the system
-        public static ReadOnlySpan<char> AsReadOnlySpan(this string text) => text.AsSpan();
-        public static ReadOnlySpan<char> AsReadOnlySpan(this string text, int start) => text.AsSpan(start);
-        public static ReadOnlySpan<char> AsReadOnlySpan(this string text, int start, int length) => text.AsSpan(start, length);
-
-        public static ReadOnlyMemory<char> AsReadOnlyMemory(this string text) => text.AsMemory();
-        public static ReadOnlyMemory<char> AsReadOnlyMemory(this string text, int start) => text.AsMemory(start);
-        public static ReadOnlyMemory<char> AsReadOnlyMemory(this string text, int start, int length) => text.AsMemory(start, length);
-    }
-}
diff --git a/src/mscorlib/shared/System/Threading/Tasks/Sources/IValueTaskSource.cs b/src/mscorlib/shared/System/Threading/Tasks/Sources/IValueTaskSource.cs
new file mode 100644 (file)
index 0000000..e411146
--- /dev/null
@@ -0,0 +1,82 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+// See the LICENSE file in the project root for more information.
+
+namespace System.Threading.Tasks.Sources
+{
+    /// <summary>
+    /// Flags passed from <see cref="ValueTask"/> and <see cref="ValueTask{TResult}"/> to
+    /// <see cref="IValueTaskSource.OnCompleted"/> and <see cref="IValueTaskSource{TResult}.OnCompleted"/>
+    /// to control behavior.
+    /// </summary>
+    [Flags]
+    public enum ValueTaskSourceOnCompletedFlags
+    {
+        /// <summary>
+        /// No requirements are placed on how the continuation is invoked.
+        /// </summary>
+        None,
+        /// <summary>
+        /// Set if OnCompleted should capture the current scheduling context (e.g. SynchronizationContext)
+        /// and use it when queueing the continuation for execution.  If this is not set, the implementation
+        /// may choose to execute the continuation in an arbitrary location.
+        /// </summary>
+        UseSchedulingContext = 0x1,
+        /// <summary>
+        /// Set if OnCompleted should capture the current ExecutionContext and use it to run the continuation.
+        /// </summary>
+        FlowExecutionContext = 0x2,
+    }
+
+    /// <summary>Indicates the status of an <see cref="IValueTaskSource"/> or <see cref="IValueTaskSource{TResult}"/>.</summary>
+    public enum ValueTaskSourceStatus
+    {
+        /// <summary>The operation has not yet completed.</summary>
+        Pending = 0,
+        /// <summary>The operation completed successfully.</summary>
+        Succeeded = 1,
+        /// <summary>The operation completed with an error.</summary>
+        Faulted = 2,
+        /// <summary>The operation completed due to cancellation.</summary>
+        Canceled = 3
+    }
+
+    /// <summary>Represents an object that can be wrapped by a <see cref="ValueTask"/>.</summary>
+    public interface IValueTaskSource
+    {
+        /// <summary>Gets the status of the current operation.</summary>
+        /// <param name="token">Opaque value that was provided to the <see cref="ValueTask"/>'s constructor.</param>
+        ValueTaskSourceStatus GetStatus(short token);
+
+        /// <summary>Schedules the continuation action for this <see cref="IValueTaskSource"/>.</summary>
+        /// <param name="continuation">The continuation to invoke when the operation has completed.</param>
+        /// <param name="state">The state object to pass to <paramref name="continuation"/> when it's invoked.</param>
+        /// <param name="token">Opaque value that was provided to the <see cref="ValueTask"/>'s constructor.</param>
+        /// <param name="flags">The flags describing the behavior of the continuation.</param>
+        void OnCompleted(Action<object> continuation, object state, short token, ValueTaskSourceOnCompletedFlags flags);
+
+        /// <summary>Gets the result of the <see cref="IValueTaskSource"/>.</summary>
+        /// <param name="token">Opaque value that was provided to the <see cref="ValueTask"/>'s constructor.</param>
+        void GetResult(short token);
+    }
+
+    /// <summary>Represents an object that can be wrapped by a <see cref="ValueTask{TResult}"/>.</summary>
+    /// <typeparam name="TResult">Specifies the type of data returned from the object.</typeparam>
+    public interface IValueTaskSource<out TResult>
+    {
+        /// <summary>Gets the status of the current operation.</summary>
+        /// <param name="token">Opaque value that was provided to the <see cref="ValueTask"/>'s constructor.</param>
+        ValueTaskSourceStatus GetStatus(short token);
+
+        /// <summary>Schedules the continuation action for this <see cref="IValueTaskSource{TResult}"/>.</summary>
+        /// <param name="continuation">The continuation to invoke when the operation has completed.</param>
+        /// <param name="state">The state object to pass to <paramref name="continuation"/> when it's invoked.</param>
+        /// <param name="token">Opaque value that was provided to the <see cref="ValueTask"/>'s constructor.</param>
+        /// <param name="flags">The flags describing the behavior of the continuation.</param>
+        void OnCompleted(Action<object> continuation, object state, short token, ValueTaskSourceOnCompletedFlags flags);
+
+        /// <summary>Gets the result of the <see cref="IValueTaskSource{TResult}"/>.</summary>
+        /// <param name="token">Opaque value that was provided to the <see cref="ValueTask"/>'s constructor.</param>
+        TResult GetResult(short token);
+    }
+}
index 5edd850..331d2bf 100644 (file)
 // See the LICENSE file in the project root for more information.
 
 using System.Collections.Generic;
+using System.Diagnostics;
 using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
+using System.Threading.Tasks.Sources;
+
+#if !netstandard
+using Internal.Runtime.CompilerServices;
+#endif
 
 namespace System.Threading.Tasks
 {
-    /// <summary>
-    /// Provides a value type that wraps a <see cref="Task{TResult}"/> and a <typeparamref name="TResult"/>,
-    /// only one of which is used.
-    /// </summary>
-    /// <typeparam name="TResult">The type of the result.</typeparam>
+    /// <summary>Provides an awaitable result of an asynchronous operation.</summary>
     /// <remarks>
-    /// <para>
-    /// Methods may return an instance of this value type when it's likely that the result of their
-    /// operations will be available synchronously and when the method is expected to be invoked so
-    /// frequently that the cost of allocating a new <see cref="Task{TResult}"/> for each call will
-    /// be prohibitive.
-    /// </para>
-    /// <para>
-    /// There are tradeoffs to using a <see cref="ValueTask{TResult}"/> instead of a <see cref="Task{TResult}"/>.
-    /// For example, while a <see cref="ValueTask{TResult}"/> can help avoid an allocation in the case where the 
-    /// successful result is available synchronously, it also contains two fields whereas a <see cref="Task{TResult}"/>
-    /// as a reference type is a single field.  This means that a method call ends up returning two fields worth of
-    /// data instead of one, which is more data to copy.  It also means that if a method that returns one of these
-    /// is awaited within an async method, the state machine for that async method will be larger due to needing
-    /// to store the struct that's two fields instead of a single reference.
-    /// </para>
-    /// <para>
-    /// Further, for uses other than consuming the result of an asynchronous operation via await, 
-    /// <see cref="ValueTask{TResult}"/> can lead to a more convoluted programming model, which can in turn actually 
-    /// lead to more allocations.  For example, consider a method that could return either a <see cref="Task{TResult}"/> 
-    /// with a cached task as a common result or a <see cref="ValueTask{TResult}"/>.  If the consumer of the result 
-    /// wants to use it as a <see cref="Task{TResult}"/>, such as to use with in methods like Task.WhenAll and Task.WhenAny, 
-    /// the <see cref="ValueTask{TResult}"/> would first need to be converted into a <see cref="Task{TResult}"/> using 
-    /// <see cref="ValueTask{TResult}.AsTask"/>, which leads to an allocation that would have been avoided if a cached 
-    /// <see cref="Task{TResult}"/> had been used in the first place.
-    /// </para>
-    /// <para>
-    /// As such, the default choice for any asynchronous method should be to return a <see cref="Task"/> or 
-    /// <see cref="Task{TResult}"/>. Only if performance analysis proves it worthwhile should a <see cref="ValueTask{TResult}"/> 
-    /// be used instead of <see cref="Task{TResult}"/>.  There is no non-generic version of <see cref="ValueTask{TResult}"/> 
-    /// as the Task.CompletedTask property may be used to hand back a successfully completed singleton in the case where
-    /// a <see cref="Task"/>-returning method completes synchronously and successfully.
-    /// </para>
+    /// <see cref="ValueTask"/>s are meant to be directly awaited.  To do more complicated operations with them, a <see cref="Task"/>
+    /// should be extracted using <see cref="AsTask"/>.  Such operations might include caching an instance to be awaited later,
+    /// registering multiple continuations with a single operation, awaiting the same task multiple times, and using combinators over
+    /// multiple operations.
+    /// </remarks>
+    [AsyncMethodBuilder(typeof(AsyncValueTaskMethodBuilder))]
+    [StructLayout(LayoutKind.Auto)]
+    public readonly struct ValueTask : IEquatable<ValueTask>
+    {
+        internal static Task CompletedTask
+#if netstandard
+            { get; } = Task.Delay(0);
+#else
+            => Task.CompletedTask;
+#endif
+
+        /// <summary>null if representing a successful synchronous completion, otherwise a <see cref="Task"/> or a <see cref="IValueTaskSource"/>.</summary>
+        internal readonly object _obj;
+        /// <summary>Flags providing additional details about the ValueTask's contents and behavior.</summary>
+        internal readonly ValueTaskFlags _flags;
+        /// <summary>Opaque value passed through to the <see cref="IValueTaskSource"/>.</summary>
+        internal readonly short _token;
+
+        // An instance created with the default ctor (a zero init'd struct) represents a synchronously, successfully completed operation.
+
+        /// <summary>Initialize the <see cref="ValueTask"/> with a <see cref="Task"/> that represents the operation.</summary>
+        /// <param name="task">The task.</param>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        public ValueTask(Task task)
+        {
+            if (task == null)
+            {
+                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.task);
+            }
+
+            _obj = task;
+
+            _flags = ValueTaskFlags.ObjectIsTask;
+            _token = 0;
+        }
+
+        /// <summary>Initialize the <see cref="ValueTask"/> with a <see cref="IValueTaskSource"/> object that represents the operation.</summary>
+        /// <param name="source">The source.</param>
+        /// <param name="token">Opaque value passed through to the <see cref="IValueTaskSource"/>.</param>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        public ValueTask(IValueTaskSource source, short token)
+        {
+            if (source == null)
+            {
+                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.source);
+            }
+
+            _obj = source;
+            _token = token;
+
+            _flags = 0;
+        }
+
+        /// <summary>Non-verified initialization of the struct to the specified values.</summary>
+        /// <param name="obj">The object.</param>
+        /// <param name="token">The token.</param>
+        /// <param name="flags">The flags.</param>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        private ValueTask(object obj, short token, ValueTaskFlags flags)
+        {
+            _obj = obj;
+            _token = token;
+            _flags = flags;
+        }
+
+        /// <summary>Gets whether the contination should be scheduled to the current context.</summary>
+        internal bool ContinueOnCapturedContext
+        {
+            [MethodImpl(MethodImplOptions.AggressiveInlining)]
+            get => (_flags & ValueTaskFlags.AvoidCapturedContext) == 0;
+        }
+
+        /// <summary>Gets whether the object in the <see cref="_obj"/> field is a <see cref="Task"/>.</summary>
+        internal bool ObjectIsTask
+        {
+            [MethodImpl(MethodImplOptions.AggressiveInlining)]
+            get => (_flags & ValueTaskFlags.ObjectIsTask) != 0;
+        }
+
+        /// <summary>Returns the <see cref="Task"/> stored in <see cref="_obj"/>.  This uses <see cref="Unsafe"/>.</summary>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        internal Task UnsafeGetTask()
+        {
+            Debug.Assert(ObjectIsTask);
+            Debug.Assert(_obj is Task);
+            return Unsafe.As<Task>(_obj);
+        }
+
+        /// <summary>Returns the <see cref="IValueTaskSource"/> stored in <see cref="_obj"/>.  This uses <see cref="Unsafe"/>.</summary>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        internal IValueTaskSource UnsafeGetValueTaskSource()
+        {
+            Debug.Assert(!ObjectIsTask);
+            Debug.Assert(_obj is IValueTaskSource);
+            return Unsafe.As<IValueTaskSource>(_obj);
+        }
+
+        /// <summary>Returns the hash code for this instance.</summary>
+        public override int GetHashCode() => _obj?.GetHashCode() ?? 0;
+
+        /// <summary>Returns a value indicating whether this value is equal to a specified <see cref="object"/>.</summary>
+        public override bool Equals(object obj) =>
+            obj is ValueTask &&
+            Equals((ValueTask)obj);
+
+        /// <summary>Returns a value indicating whether this value is equal to a specified <see cref="ValueTask"/> value.</summary>
+        public bool Equals(ValueTask other) => _obj == other._obj && _token == other._token;
+
+        /// <summary>Returns a value indicating whether two <see cref="ValueTask"/> values are equal.</summary>
+        public static bool operator ==(ValueTask left, ValueTask right) =>
+            left.Equals(right);
+
+        /// <summary>Returns a value indicating whether two <see cref="ValueTask"/> values are not equal.</summary>
+        public static bool operator !=(ValueTask left, ValueTask right) =>
+            !left.Equals(right);
+
+        /// <summary>
+        /// Gets a <see cref="Task"/> object to represent this ValueTask.
+        /// </summary>
+        /// <remarks>
+        /// It will either return the wrapped task object if one exists, or it'll
+        /// manufacture a new task object to represent the result.
+        /// </remarks>
+        public Task AsTask() =>
+            _obj == null ? ValueTask.CompletedTask :
+            ObjectIsTask ? UnsafeGetTask() :
+            GetTaskForValueTaskSource();
+
+        /// <summary>Gets a <see cref="ValueTask"/> that may be used at any point in the future.</summary>
+        public ValueTask Preserve() => _obj == null ? this : new ValueTask(AsTask());
+
+        /// <summary>Creates a <see cref="Task"/> to represent the <see cref="IValueTaskSource"/>.</summary>
+        private Task GetTaskForValueTaskSource()
+        {
+            IValueTaskSource t = UnsafeGetValueTaskSource();
+            ValueTaskSourceStatus status = t.GetStatus(_token);
+            if (status != ValueTaskSourceStatus.Pending)
+            {
+                try
+                {
+                    // Propagate any exceptions that may have occurred, then return
+                    // an already successfully completed task.
+                    t.GetResult(_token);
+                    return ValueTask.CompletedTask;
+
+                    // If status is Faulted or Canceled, GetResult should throw.  But
+                    // we can't guarantee every implementation will do the "right thing".
+                    // If it doesn't throw, we just treat that as success and ignore
+                    // the status.
+                }
+                catch (Exception exc)
+                {
+                    if (status == ValueTaskSourceStatus.Canceled)
+                    {
+#if netstandard
+                        var tcs = new TaskCompletionSource<bool>();
+                        tcs.TrySetCanceled();
+                        return tcs.Task;
+#else
+                        if (exc is OperationCanceledException oce)
+                        {
+                            var task = new Task<VoidTaskResult>();
+                            task.TrySetCanceled(oce.CancellationToken, oce);
+                            return task;
+                        }
+                        else
+                        {
+                            return Task.FromCanceled(new CancellationToken(true));
+                        }
+#endif
+                    }
+                    else
+                    {
+#if netstandard
+                        var tcs = new TaskCompletionSource<bool>();
+                        tcs.TrySetException(exc);
+                        return tcs.Task;
+#else
+                        return Task.FromException(exc);
+#endif
+                    }
+                }
+            }
+
+            var m = new ValueTaskSourceTask(t, _token);
+            return
+#if netstandard
+                m.Task;
+#else
+                m;
+#endif
+        }
+
+        /// <summary>Type used to create a <see cref="Task"/> to represent a <see cref="IValueTaskSource"/>.</summary>
+        private sealed class ValueTaskSourceTask :
+#if netstandard
+            TaskCompletionSource<bool>
+#else
+            Task<VoidTaskResult>
+#endif
+        {
+            private static readonly Action<object> s_completionAction = state =>
+            {
+                if (!(state is ValueTaskSourceTask vtst) ||
+                    !(vtst._source is IValueTaskSource source))
+                {
+                    // This could only happen if the IValueTaskSource passed the wrong state
+                    // or if this callback were invoked multiple times such that the state
+                    // was previously nulled out.
+                    ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.state);
+                    return;
+                }
+
+                vtst._source = null;
+                ValueTaskSourceStatus status = source.GetStatus(vtst._token);
+                try
+                {
+                    source.GetResult(vtst._token);
+                    vtst.TrySetResult(default);
+                }
+                catch (Exception exc)
+                {
+                    if (status == ValueTaskSourceStatus.Canceled)
+                    {
+#if netstandard
+                        vtst.TrySetCanceled();
+#else
+                        if (exc is OperationCanceledException oce)
+                        {
+                            vtst.TrySetCanceled(oce.CancellationToken, oce);
+                        }
+                        else
+                        {
+                            vtst.TrySetCanceled(new CancellationToken(true));
+                        }
+#endif
+                    }
+                    else
+                    {
+                        vtst.TrySetException(exc);
+                    }
+                }
+            };
+
+            /// <summary>The associated <see cref="IValueTaskSource"/>.</summary>
+            private IValueTaskSource _source;
+            /// <summary>The token to pass through to operations on <see cref="_source"/></summary>
+            private readonly short _token;
+
+            public ValueTaskSourceTask(IValueTaskSource source, short token)
+            {
+                _token = token;
+                _source = source;
+                source.OnCompleted(s_completionAction, this, token, ValueTaskSourceOnCompletedFlags.None);
+            }
+        }
+
+        /// <summary>Gets whether the <see cref="ValueTask"/> represents a completed operation.</summary>
+        public bool IsCompleted
+        {
+            [MethodImpl(MethodImplOptions.AggressiveInlining)]
+            get => _obj == null || (ObjectIsTask ? UnsafeGetTask().IsCompleted : UnsafeGetValueTaskSource().GetStatus(_token) != ValueTaskSourceStatus.Pending);
+        }
+
+        /// <summary>Gets whether the <see cref="ValueTask"/> represents a successfully completed operation.</summary>
+        public bool IsCompletedSuccessfully
+        {
+            [MethodImpl(MethodImplOptions.AggressiveInlining)]
+            get =>
+                _obj == null ||
+                (ObjectIsTask ?
+#if netstandard
+                    UnsafeTask.Status == TaskStatus.RanToCompletion :
+#else
+                    UnsafeGetTask().IsCompletedSuccessfully :
+#endif
+                    UnsafeGetValueTaskSource().GetStatus(_token) == ValueTaskSourceStatus.Succeeded);
+        }
+
+        /// <summary>Gets whether the <see cref="ValueTask"/> represents a failed operation.</summary>
+        public bool IsFaulted
+        {
+            get =>
+                _obj != null &&
+                (ObjectIsTask ? UnsafeGetTask().IsFaulted : UnsafeGetValueTaskSource().GetStatus(_token) == ValueTaskSourceStatus.Faulted);
+        }
+
+        /// <summary>Gets whether the <see cref="ValueTask"/> represents a canceled operation.</summary>
+        /// <remarks>
+        /// If the <see cref="ValueTask"/> is backed by a result or by a <see cref="IValueTaskSource"/>,
+        /// this will always return false.  If it's backed by a <see cref="Task"/>, it'll return the
+        /// value of the task's <see cref="Task.IsCanceled"/> property.
+        /// </remarks>
+        public bool IsCanceled
+        {
+            get =>
+                _obj != null &&
+                (ObjectIsTask ? UnsafeGetTask().IsCanceled : UnsafeGetValueTaskSource().GetStatus(_token) == ValueTaskSourceStatus.Canceled);
+        }
+
+        /// <summary>Throws the exception that caused the <see cref="ValueTask"/> to fail.  If it completed successfully, nothing is thrown.</summary>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        [StackTraceHidden]
+        internal void ThrowIfCompletedUnsuccessfully()
+        {
+            if (_obj != null)
+            {
+                if (ObjectIsTask)
+                {
+#if netstandard
+                    UnsafeTask.GetAwaiter().GetResult();
+#else
+                    TaskAwaiter.ValidateEnd(UnsafeGetTask());
+#endif
+                }
+                else
+                {
+                    UnsafeGetValueTaskSource().GetResult(_token);
+                }
+            }
+        }
+
+        /// <summary>Gets an awaiter for this <see cref="ValueTask"/>.</summary>
+        public ValueTaskAwaiter GetAwaiter() => new ValueTaskAwaiter(this);
+
+        /// <summary>Configures an awaiter for this <see cref="ValueTask"/>.</summary>
+        /// <param name="continueOnCapturedContext">
+        /// true to attempt to marshal the continuation back to the captured context; otherwise, false.
+        /// </param>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        public ConfiguredValueTaskAwaitable ConfigureAwait(bool continueOnCapturedContext)
+        {
+            // TODO: Simplify once https://github.com/dotnet/coreclr/pull/16138 is fixed.
+            bool avoidCapture = !continueOnCapturedContext;
+            return new ConfiguredValueTaskAwaitable(new ValueTask(_obj, _token, _flags | Unsafe.As<bool, ValueTaskFlags>(ref avoidCapture)));
+        }
+    }
+
+    /// <summary>Provides a value type that can represent a synchronously available value or a task object.</summary>
+    /// <typeparam name="TResult">Specifies the type of the result.</typeparam>
+    /// <remarks>
+    /// <see cref="ValueTask{TResult}"/>s are meant to be directly awaited.  To do more complicated operations with them, a <see cref="Task"/>
+    /// should be extracted using <see cref="AsTask"/> or <see cref="Preserve"/>.  Such operations might include caching an instance to
+    /// be awaited later, registering multiple continuations with a single operation, awaiting the same task multiple times, and using
+    /// combinators over multiple operations.
     /// </remarks>
     [AsyncMethodBuilder(typeof(AsyncValueTaskMethodBuilder<>))]
     [StructLayout(LayoutKind.Auto)]
     public readonly struct ValueTask<TResult> : IEquatable<ValueTask<TResult>>
     {
-        /// <summary>The task to be used if the operation completed asynchronously or if it completed synchronously but non-successfully.</summary>
-        internal readonly Task<TResult> _task;
+        /// <summary>null if <see cref="_result"/> has the result, otherwise a <see cref="Task{TResult}"/> or a <see cref="IValueTaskSource{TResult}"/>.</summary>
+        internal readonly object _obj;
         /// <summary>The result to be used if the operation completed successfully synchronously.</summary>
         internal readonly TResult _result;
+        /// <summary>Flags providing additional details about the ValueTask's contents and behavior.</summary>
+        internal readonly ValueTaskFlags _flags;
+        /// <summary>Opaque value passed through to the <see cref="IValueTaskSource{TResult}"/>.</summary>
+        internal readonly short _token;
+
+        // An instance created with the default ctor (a zero init'd struct) represents a synchronously, successfully completed operation
+        // with a result of default(TResult).
 
-        /// <summary>Initialize the <see cref="ValueTask{TResult}"/> with the result of the successful operation.</summary>
+        /// <summary>Initialize the <see cref="ValueTask{TResult}"/> with a <typeparamref name="TResult"/> result value.</summary>
         /// <param name="result">The result.</param>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public ValueTask(TResult result)
         {
-            _task = null;
             _result = result;
+
+            _obj = null;
+            _flags = 0;
+            _token = 0;
         }
 
-        /// <summary>
-        /// Initialize the <see cref="ValueTask{TResult}"/> with a <see cref="Task{TResult}"/> that represents the operation.
-        /// </summary>
+        /// <summary>Initialize the <see cref="ValueTask{TResult}"/> with a <see cref="Task{TResult}"/> that represents the operation.</summary>
         /// <param name="task">The task.</param>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public ValueTask(Task<TResult> task)
         {
             if (task == null)
@@ -75,95 +405,335 @@ namespace System.Threading.Tasks
                 ThrowHelper.ThrowArgumentNullException(ExceptionArgument.task);
             }
 
-            _task = task;
+            _obj = task;
+
             _result = default;
+            _flags = ValueTaskFlags.ObjectIsTask;
+            _token = 0;
+        }
+
+        /// <summary>Initialize the <see cref="ValueTask{TResult}"/> with a <see cref="IValueTaskSource{TResult}"/> object that represents the operation.</summary>
+        /// <param name="source">The source.</param>
+        /// <param name="token">Opaque value passed through to the <see cref="IValueTaskSource"/>.</param>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        public ValueTask(IValueTaskSource<TResult> source, short token)
+        {
+            if (source == null)
+            {
+                ThrowHelper.ThrowArgumentNullException(ExceptionArgument.source);
+            }
+
+            _obj = source;
+            _token = token;
+
+            _result = default;
+            _flags = 0;
+        }
+
+        /// <summary>Non-verified initialization of the struct to the specified values.</summary>
+        /// <param name="obj">The object.</param>
+        /// <param name="result">The result.</param>
+        /// <param name="token">The token.</param>
+        /// <param name="flags">The flags.</param>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        private ValueTask(object obj, TResult result, short token, ValueTaskFlags flags)
+        {
+            _obj = obj;
+            _result = result;
+            _token = token;
+            _flags = flags;
+        }
+
+        /// <summary>Gets whether the contination should be scheduled to the current context.</summary>
+        internal bool ContinueOnCapturedContext
+        {
+            [MethodImpl(MethodImplOptions.AggressiveInlining)]
+            get => (_flags & ValueTaskFlags.AvoidCapturedContext) == 0;
+        }
+
+        /// <summary>Gets whether the object in the <see cref="_obj"/> field is a <see cref="Task{TResult}"/>.</summary>
+        internal bool ObjectIsTask
+        {
+            [MethodImpl(MethodImplOptions.AggressiveInlining)]
+            get => (_flags & ValueTaskFlags.ObjectIsTask) != 0;
+        }
+
+        /// <summary>Returns the <see cref="Task{TResult}"/> stored in <see cref="_obj"/>.  This uses <see cref="Unsafe"/>.</summary>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        internal Task<TResult> UnsafeGetTask()
+        {
+            Debug.Assert(ObjectIsTask);
+            Debug.Assert(_obj is Task<TResult>);
+            return Unsafe.As<Task<TResult>>(_obj);
+        }
+
+        /// <summary>Returns the <see cref="IValueTaskSource{TResult}"/> stored in <see cref="_obj"/>.  This uses <see cref="Unsafe"/>.</summary>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        internal IValueTaskSource<TResult> UnsafeGetValueTaskSource()
+        {
+            Debug.Assert(!ObjectIsTask);
+            Debug.Assert(_obj is IValueTaskSource<TResult>);
+            return Unsafe.As<IValueTaskSource<TResult>>(_obj);
         }
 
         /// <summary>Returns the hash code for this instance.</summary>
         public override int GetHashCode() =>
-            _task != null ? _task.GetHashCode() :
+            _obj != null ? _obj.GetHashCode() :
             _result != null ? _result.GetHashCode() :
             0;
 
         /// <summary>Returns a value indicating whether this value is equal to a specified <see cref="object"/>.</summary>
         public override bool Equals(object obj) =>
-            obj is ValueTask<TResult> && 
+            obj is ValueTask<TResult> &&
             Equals((ValueTask<TResult>)obj);
 
         /// <summary>Returns a value indicating whether this value is equal to a specified <see cref="ValueTask{TResult}"/> value.</summary>
         public bool Equals(ValueTask<TResult> other) =>
-            _task != null || other._task != null ? 
-                _task == other._task :
+            _obj != null || other._obj != null ?
+                _obj == other._obj && _token == other._token :
                 EqualityComparer<TResult>.Default.Equals(_result, other._result);
 
         /// <summary>Returns a value indicating whether two <see cref="ValueTask{TResult}"/> values are equal.</summary>
-        public static bool operator==(ValueTask<TResult> left, ValueTask<TResult> right) =>
+        public static bool operator ==(ValueTask<TResult> left, ValueTask<TResult> right) =>
             left.Equals(right);
 
         /// <summary>Returns a value indicating whether two <see cref="ValueTask{TResult}"/> values are not equal.</summary>
-        public static bool operator!=(ValueTask<TResult> left, ValueTask<TResult> right) =>
+        public static bool operator !=(ValueTask<TResult> left, ValueTask<TResult> right) =>
             !left.Equals(right);
 
         /// <summary>
-        /// Gets a <see cref="Task{TResult}"/> object to represent this ValueTask.  It will
-        /// either return the wrapped task object if one exists, or it'll manufacture a new
-        /// task object to represent the result.
+        /// Gets a <see cref="Task{TResult}"/> object to represent this ValueTask.
         /// </summary>
+        /// <remarks>
+        /// It will either return the wrapped task object if one exists, or it'll
+        /// manufacture a new task object to represent the result.
+        /// </remarks>
         public Task<TResult> AsTask() =>
-            // Return the task if we were constructed from one, otherwise manufacture one.  We don't
-            // cache the generated task into _task as it would end up changing both equality comparison
-            // and the hash code we generate in GetHashCode.
-            _task ??
+            _obj == null ?
 #if netstandard
-                Task.FromResult(_result);
+                Task.FromResult(_result) :
 #else
-                AsyncTaskMethodBuilder<TResult>.GetTaskForResult(_result);
+                AsyncTaskMethodBuilder<TResult>.GetTaskForResult(_result) :
 #endif
+            ObjectIsTask ? UnsafeGetTask() :
+            GetTaskForValueTaskSource();
 
-        internal Task<TResult> AsTaskExpectNonNull() =>
-            // Return the task if we were constructed from one, otherwise manufacture one.
-            // Unlike AsTask(), this method is called only when we expect _task to be non-null,
-            // and thus we don't want GetTaskForResult inlined.
-            _task ?? GetTaskForResultNoInlining();
+        /// <summary>Gets a <see cref="ValueTask{TResult}"/> that may be used at any point in the future.</summary>
+        public ValueTask<TResult> Preserve() => _obj == null ? this : new ValueTask<TResult>(AsTask());
 
-        [MethodImpl(MethodImplOptions.NoInlining)]
-        private Task<TResult> GetTaskForResultNoInlining() =>
+        /// <summary>Creates a <see cref="Task{TResult}"/> to represent the <see cref="IValueTaskSource{TResult}"/>.</summary>
+        private Task<TResult> GetTaskForValueTaskSource()
+        {
+            IValueTaskSource<TResult> t = UnsafeGetValueTaskSource();
+            ValueTaskSourceStatus status = t.GetStatus(_token);
+            if (status != ValueTaskSourceStatus.Pending)
+            {
+                try
+                {
+                    // Get the result of the operation and return a task for it.
+                    // If any exception occurred, propagate it
+                    return
 #if netstandard
-            Task.FromResult(_result);
+                        Task.FromResult(t.GetResult(_token));
 #else
-            AsyncTaskMethodBuilder<TResult>.GetTaskForResult(_result);
+                        AsyncTaskMethodBuilder<TResult>.GetTaskForResult(t.GetResult(_token));
 #endif
 
+                    // If status is Faulted or Canceled, GetResult should throw.  But
+                    // we can't guarantee every implementation will do the "right thing".
+                    // If it doesn't throw, we just treat that as success and ignore
+                    // the status.
+                }
+                catch (Exception exc)
+                {
+                    if (status == ValueTaskSourceStatus.Canceled)
+                    {
+#if netstandard
+                        var tcs = new TaskCompletionSource<TResult>();
+                        tcs.TrySetCanceled();
+                        return tcs.Task;
+#else
+                        if (exc is OperationCanceledException oce)
+                        {
+                            var task = new Task<TResult>();
+                            task.TrySetCanceled(oce.CancellationToken, oce);
+                            return task;
+                        }
+                        else
+                        {
+                            return Task.FromCanceled<TResult>(new CancellationToken(true));
+                        }
+#endif
+                    }
+                    else
+                    {
+#if netstandard
+                        var tcs = new TaskCompletionSource<TResult>();
+                        tcs.TrySetException(exc);
+                        return tcs.Task;
+#else
+                        return Task.FromException<TResult>(exc);
+#endif
+                    }
+                }
+            }
+
+            var m = new ValueTaskSourceTask(t, _token);
+            return
+#if netstandard
+                m.Task;
+#else
+                m;
+#endif
+        }
+
+        /// <summary>Type used to create a <see cref="Task{TResult}"/> to represent a <see cref="IValueTaskSource{TResult}"/>.</summary>
+        private sealed class ValueTaskSourceTask :
+#if netstandard
+            TaskCompletionSource<TResult>
+#else
+            Task<TResult>
+#endif
+        {
+            private static readonly Action<object> s_completionAction = state =>
+            {
+                if (!(state is ValueTaskSourceTask vtst) ||
+                    !(vtst._source is IValueTaskSource<TResult> source))
+                {
+                    // This could only happen if the IValueTaskSource<TResult> passed the wrong state
+                    // or if this callback were invoked multiple times such that the state
+                    // was previously nulled out.
+                    ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.state);
+                    return;
+                }
+
+                vtst._source = null;
+                ValueTaskSourceStatus status = source.GetStatus(vtst._token);
+                try
+                {
+                    vtst.TrySetResult(source.GetResult(vtst._token));
+                }
+                catch (Exception exc)
+                {
+                    if (status == ValueTaskSourceStatus.Canceled)
+                    {
+#if netstandard
+                        vtst.TrySetCanceled();
+#else
+                        if (exc is OperationCanceledException oce)
+                        {
+                            vtst.TrySetCanceled(oce.CancellationToken, oce);
+                        }
+                        else
+                        {
+                            vtst.TrySetCanceled(new CancellationToken(true));
+                        }
+#endif
+                    }
+                    else
+                    {
+                        vtst.TrySetException(exc);
+                    }
+                }
+            };
+
+            /// <summary>The associated <see cref="IValueTaskSource"/>.</summary>
+            private IValueTaskSource<TResult> _source;
+            /// <summary>The token to pass through to operations on <see cref="_source"/></summary>
+            private readonly short _token;
+
+            public ValueTaskSourceTask(IValueTaskSource<TResult> source, short token)
+            {
+                _source = source;
+                _token = token;
+                source.OnCompleted(s_completionAction, this, token, ValueTaskSourceOnCompletedFlags.None);
+            }
+        }
+
         /// <summary>Gets whether the <see cref="ValueTask{TResult}"/> represents a completed operation.</summary>
-        public bool IsCompleted => _task == null || _task.IsCompleted;
+        public bool IsCompleted
+        {
+            [MethodImpl(MethodImplOptions.AggressiveInlining)]
+            get => _obj == null || (ObjectIsTask ? UnsafeGetTask().IsCompleted : UnsafeGetValueTaskSource().GetStatus(_token) != ValueTaskSourceStatus.Pending);
+        }
 
         /// <summary>Gets whether the <see cref="ValueTask{TResult}"/> represents a successfully completed operation.</summary>
-        public bool IsCompletedSuccessfully =>
-            _task == null ||
+        public bool IsCompletedSuccessfully
+        {
+            [MethodImpl(MethodImplOptions.AggressiveInlining)]
+            get =>
+                _obj == null ||
+                (ObjectIsTask ?
 #if netstandard
-            _task.Status == TaskStatus.RanToCompletion;
+                    UnsafeTask.Status == TaskStatus.RanToCompletion :
 #else
-            _task.IsCompletedSuccessfully;
+                    UnsafeGetTask().IsCompletedSuccessfully :
 #endif
+                    UnsafeGetValueTaskSource().GetStatus(_token) == ValueTaskSourceStatus.Succeeded);
+        }
 
         /// <summary>Gets whether the <see cref="ValueTask{TResult}"/> represents a failed operation.</summary>
-        public bool IsFaulted => _task != null && _task.IsFaulted;
+        public bool IsFaulted
+        {
+            get =>
+                _obj != null &&
+                (ObjectIsTask ? UnsafeGetTask().IsFaulted : UnsafeGetValueTaskSource().GetStatus(_token) == ValueTaskSourceStatus.Faulted);
+        }
 
         /// <summary>Gets whether the <see cref="ValueTask{TResult}"/> represents a canceled operation.</summary>
-        public bool IsCanceled => _task != null && _task.IsCanceled;
+        /// <remarks>
+        /// If the <see cref="ValueTask{TResult}"/> is backed by a result or by a <see cref="IValueTaskSource{TResult}"/>,
+        /// this will always return false.  If it's backed by a <see cref="Task"/>, it'll return the
+        /// value of the task's <see cref="Task.IsCanceled"/> property.
+        /// </remarks>
+        public bool IsCanceled
+        {
+            get =>
+                _obj != null &&
+                (ObjectIsTask ? UnsafeGetTask().IsCanceled : UnsafeGetValueTaskSource().GetStatus(_token) == ValueTaskSourceStatus.Canceled);
+        }
 
         /// <summary>Gets the result.</summary>
-        public TResult Result => _task == null ? _result : _task.GetAwaiter().GetResult();
+        public TResult Result
+        {
+            [MethodImpl(MethodImplOptions.AggressiveInlining)]
+            get
+            {
+                if (_obj == null)
+                {
+                    return _result;
+                }
 
-        /// <summary>Gets an awaiter for this value.</summary>
+                if (ObjectIsTask)
+                {
+#if netstandard
+                    return UnsafeTask.GetAwaiter().GetResult();
+#else
+                    Task<TResult> t = UnsafeGetTask();
+                    TaskAwaiter.ValidateEnd(t);
+                    return t.ResultOnSuccess;
+#endif
+                }
+
+                return UnsafeGetValueTaskSource().GetResult(_token);
+            }
+        }
+
+        /// <summary>Gets an awaiter for this <see cref="ValueTask{TResult}"/>.</summary>
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
         public ValueTaskAwaiter<TResult> GetAwaiter() => new ValueTaskAwaiter<TResult>(this);
 
-        /// <summary>Configures an awaiter for this value.</summary>
+        /// <summary>Configures an awaiter for this <see cref="ValueTask{TResult}"/>.</summary>
         /// <param name="continueOnCapturedContext">
         /// true to attempt to marshal the continuation back to the captured context; otherwise, false.
         /// </param>
-        public ConfiguredValueTaskAwaitable<TResult> ConfigureAwait(bool continueOnCapturedContext) =>
-            new ConfiguredValueTaskAwaitable<TResult>(this, continueOnCapturedContext);
+        [MethodImpl(MethodImplOptions.AggressiveInlining)]
+        public ConfiguredValueTaskAwaitable<TResult> ConfigureAwait(bool continueOnCapturedContext)
+        {
+            // TODO: Simplify once https://github.com/dotnet/coreclr/pull/16138 is fixed.
+            bool avoidCapture = !continueOnCapturedContext;
+            return new ConfiguredValueTaskAwaitable<TResult>(new ValueTask<TResult>(_obj, _result, _token, _flags | Unsafe.As<bool, ValueTaskFlags>(ref avoidCapture)));
+        }
 
         /// <summary>Gets a string-representation of this <see cref="ValueTask{TResult}"/>.</summary>
         public override string ToString()
@@ -180,4 +750,26 @@ namespace System.Threading.Tasks
             return string.Empty;
         }
     }
+
+    /// <summary>Internal flags used in the implementation of <see cref="ValueTask"/> and <see cref="ValueTask{TResult}"/>.</summary>
+    [Flags]
+    internal enum ValueTaskFlags : byte
+    {
+        /// <summary>
+        /// Indicates that context (e.g. SynchronizationContext) should not be captured when adding
+        /// a continuation.
+        /// </summary>
+        /// <remarks>
+        /// The value here must be 0x1, to match the value of a true Boolean reinterpreted as a byte.
+        /// This only has meaning when awaiting a ValueTask, with ConfigureAwait creating a new
+        /// ValueTask setting or not setting this flag appropriately.
+        /// </remarks>
+        AvoidCapturedContext = 0x1,
+
+        /// <summary>
+        /// Indicates that the ValueTask's object field stores a Task.  This is used to avoid
+        /// a type check on whatever is stored in the object field.
+        /// </summary>
+        ObjectIsTask = 0x2
+    }
 }
index e822ff6..5cc8bb8 100644 (file)
@@ -109,7 +109,7 @@ namespace System
             RuntimeMethodHandleInternal method = new RuntimeMethodHandleInternal(GetInvokeMethod());
             RuntimeMethodInfo invoke = (RuntimeMethodInfo)RuntimeType.GetMethodBase((RuntimeType)this.GetType(), method);
 
-            return invoke.UnsafeInvoke(this, BindingFlags.Default, null, args, null);
+            return invoke.Invoke(this, BindingFlags.Default, null, args, null);
         }
 
 
@@ -427,7 +427,6 @@ namespace System
         }
 
         // V1 API.
-        [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
         public static Delegate CreateDelegate(Type type, MethodInfo method, bool throwOnBindFailure)
         {
             // Validate the parameters.
@@ -455,13 +454,11 @@ namespace System
             // pass us a static method or a method with a non-exact signature
             // and the only change in behavior from v1.1 there is that we won't
             // fail the call).
-            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
             Delegate d = CreateDelegateInternal(
                 rtType,
                 rmi,
                 null,
-                DelegateBindingFlags.OpenDelegateOnly | DelegateBindingFlags.RelaxedSignature,
-                ref stackMark);
+                DelegateBindingFlags.OpenDelegateOnly | DelegateBindingFlags.RelaxedSignature);
 
             if (d == null && throwOnBindFailure)
                 throw new ArgumentException(SR.Arg_DlgtTargMeth);
@@ -476,7 +473,6 @@ namespace System
         }
 
         // V2 API.
-        [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
         public static Delegate CreateDelegate(Type type, Object firstArgument, MethodInfo method, bool throwOnBindFailure)
         {
             // Validate the parameters.
@@ -501,13 +497,11 @@ namespace System
             // instance methods with relaxed signature checking. The delegate
             // can also be closed over null. There's no ambiguity with all these
             // options since the caller is providing us a specific MethodInfo.
-            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
             Delegate d = CreateDelegateInternal(
                 rtType,
                 rmi,
                 firstArgument,
-                DelegateBindingFlags.RelaxedSignature,
-               ref stackMark);
+                DelegateBindingFlags.RelaxedSignature);
 
             if (d == null && throwOnBindFailure)
                 throw new ArgumentException(SR.Arg_DlgtTargMeth);
@@ -602,7 +596,7 @@ namespace System
             // signature changes). We explicitly skip security checks here --
             // we're not really constructing a delegate, we're cloning an
             // existing instance which already passed its checks.
-            Delegate d = UnsafeCreateDelegate(type, rtMethod, firstArgument,
+            Delegate d = CreateDelegateInternal(type, rtMethod, firstArgument,
                                               DelegateBindingFlags.SkipSecurityChecks |
                                               DelegateBindingFlags.RelaxedSignature);
 
@@ -618,14 +612,7 @@ namespace System
             return CreateDelegate(type, method, true);
         }
 
-        internal static Delegate CreateDelegateInternal(RuntimeType rtType, RuntimeMethodInfo rtMethod, Object firstArgument, DelegateBindingFlags flags, ref StackCrawlMark stackMark)
-        {
-            Debug.Assert((flags & DelegateBindingFlags.SkipSecurityChecks) == 0);
-
-            return UnsafeCreateDelegate(rtType, rtMethod, firstArgument, flags);
-        }
-
-        internal static Delegate UnsafeCreateDelegate(RuntimeType rtType, RuntimeMethodInfo rtMethod, Object firstArgument, DelegateBindingFlags flags)
+        internal static Delegate CreateDelegateInternal(RuntimeType rtType, RuntimeMethodInfo rtMethod, Object firstArgument, DelegateBindingFlags flags)
         {
             Delegate d = InternalAlloc(rtType);
 
index 63cc0c9..ec29dc2 100644 (file)
@@ -137,27 +137,19 @@ namespace System.IO
 
         private async Task CopyToAsyncInternal(Stream destination, Int32 bufferSize, CancellationToken cancellationToken)
         {
-            Debug.Assert(destination != null);
-            Debug.Assert(bufferSize > 0);
-            Debug.Assert(CanRead);
-            Debug.Assert(destination.CanWrite);
-
             byte[] buffer = ArrayPool<byte>.Shared.Rent(bufferSize);
-            bufferSize = 0; // reuse same field for high water mark to avoid needing another field in the state machine
             try
             {
                 while (true)
                 {
-                    int bytesRead = await ReadAsync(buffer, 0, buffer.Length, cancellationToken).ConfigureAwait(false);
+                    int bytesRead = await ReadAsync(new Memory<byte>(buffer), cancellationToken).ConfigureAwait(false);
                     if (bytesRead == 0) break;
-                    if (bytesRead > bufferSize) bufferSize = bytesRead;
-                    await destination.WriteAsync(buffer, 0, bytesRead, cancellationToken).ConfigureAwait(false);
+                    await destination.WriteAsync(new ReadOnlyMemory<byte>(buffer, 0, bytesRead), cancellationToken).ConfigureAwait(false);
                 }
             }
             finally
             {
-                Array.Clear(buffer, 0, bufferSize); // clear only the most we used
-                ArrayPool<byte>.Shared.Return(buffer, clearArray: false);
+                ArrayPool<byte>.Shared.Return(buffer);
             }
         }
 
@@ -176,20 +168,17 @@ namespace System.IO
             StreamHelpers.ValidateCopyToArgs(this, destination, bufferSize);
 
             byte[] buffer = ArrayPool<byte>.Shared.Rent(bufferSize);
-            int highwaterMark = 0;
             try
             {
                 int read;
                 while ((read = Read(buffer, 0, buffer.Length)) != 0)
                 {
-                    if (read > highwaterMark) highwaterMark = read;
                     destination.Write(buffer, 0, read);
                 }
             }
             finally
             {
-                Array.Clear(buffer, 0, highwaterMark); // clear only the most we used
-                ArrayPool<byte>.Shared.Return(buffer, clearArray: false);
+                ArrayPool<byte>.Shared.Return(buffer);
             }
         }
 
@@ -387,7 +376,7 @@ namespace System.IO
 
         public virtual ValueTask<int> ReadAsync(Memory<byte> destination, CancellationToken cancellationToken = default(CancellationToken))
         {
-            if (destination.TryGetArray(out ArraySegment<byte> array))
+            if (MemoryMarshal.TryGetArray(destination, out ArraySegment<byte> array))
             {
                 return new ValueTask<int>(ReadAsync(array.Array, array.Offset, array.Count, cancellationToken));
             }
@@ -694,29 +683,29 @@ namespace System.IO
                         : BeginEndWriteAsync(buffer, offset, count);
         }
 
-        public virtual Task WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default(CancellationToken))
+        public virtual ValueTask WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default(CancellationToken))
         {
             if (MemoryMarshal.TryGetArray(source, out ArraySegment<byte> array))
             {
-                return WriteAsync(array.Array, array.Offset, array.Count, cancellationToken);
+                return new ValueTask(WriteAsync(array.Array, array.Offset, array.Count, cancellationToken));
             }
             else
             {
                 byte[] buffer = ArrayPool<byte>.Shared.Rent(source.Length);
                 source.Span.CopyTo(buffer);
-                return FinishWriteAsync(WriteAsync(buffer, 0, source.Length, cancellationToken), buffer);
+                return new ValueTask(FinishWriteAsync(WriteAsync(buffer, 0, source.Length, cancellationToken), buffer));
+            }
+        }
 
-                async Task FinishWriteAsync(Task writeTask, byte[] localBuffer)
-                {
-                    try
-                    {
-                        await writeTask.ConfigureAwait(false);
-                    }
-                    finally
-                    {
-                        ArrayPool<byte>.Shared.Return(localBuffer);
-                    }
-                }
+        private async Task FinishWriteAsync(Task writeTask, byte[] localBuffer)
+        {
+            try
+            {
+                await writeTask.ConfigureAwait(false);
+            }
+            finally
+            {
+                ArrayPool<byte>.Shared.Return(localBuffer);
             }
         }
 
@@ -1018,11 +1007,11 @@ namespace System.IO
                     Task.CompletedTask;
             }
 
-            public override Task WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default(CancellationToken))
+            public override ValueTask WriteAsync(ReadOnlyMemory<byte> source, CancellationToken cancellationToken = default(CancellationToken))
             {
                 return cancellationToken.IsCancellationRequested ?
-                    Task.FromCanceled(cancellationToken) :
-                    Task.CompletedTask;
+                    new ValueTask(Task.FromCanceled(cancellationToken)) :
+                    default;
             }
 
             public override void WriteByte(byte value)
index 23b4793..0931e3c 100644 (file)
@@ -117,37 +117,6 @@ namespace System.Reflection
             return RuntimeAssembly.InternalLoad(assemblyString, ref stackMark);
         }
 
-        // Returns type from the assembly while keeping compatibility with Assembly.Load(assemblyString).GetType(typeName) for managed types.
-        // Calls Type.GetType for WinRT types.
-        // Note: Type.GetType fails for assembly names that start with weird characters like '['. By calling it for managed types we would 
-        // break AppCompat.
-        [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
-        internal static Type GetType_Compat(String assemblyString, String typeName)
-        {
-            // Normally we would get the stackMark only in public APIs. This is internal API, but it is AppCompat replacement of public API 
-            // call Assembly.Load(assemblyString).GetType(typeName), therefore we take the stackMark here as well, to be fully compatible with 
-            // the call sequence.
-            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-
-            RuntimeAssembly assembly;
-            AssemblyName assemblyName = RuntimeAssembly.CreateAssemblyName(
-                assemblyString,
-                out assembly);
-
-            if (assembly == null)
-            {
-                if (assemblyName.ContentType == AssemblyContentType.WindowsRuntime)
-                {
-                    return Type.GetType(typeName + ", " + assemblyString, true /*throwOnError*/, false /*ignoreCase*/);
-                }
-
-                assembly = RuntimeAssembly.InternalLoadAssemblyName(
-                    assemblyName, null, ref stackMark,
-                    true /*thrownOnFileNotFound*/);
-            }
-            return assembly.GetType(typeName, true /*throwOnError*/, false /*ignoreCase*/);
-        }
-
         // Locate an assembly by its name. The name can be strong or
         // weak. The assembly is loaded into the domain of the caller.
         [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
index afb121a..ab928e4 100644 (file)
@@ -1610,7 +1610,7 @@ namespace System.Reflection
                             if (!setMethod.IsPublic)
                                 continue;
 
-                            setMethod.UnsafeInvoke(attribute, BindingFlags.Default, null, new object[] { value }, null);
+                            setMethod.Invoke(attribute, BindingFlags.Default, null, new object[] { value }, null);
                             #endregion
                         }
                         else
index 7c1b0cf..9f7d79e 100644 (file)
@@ -334,7 +334,6 @@ namespace System.Reflection
 
         [DebuggerStepThroughAttribute]
         [Diagnostics.DebuggerHidden]
-        [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
         public override Object Invoke(
             Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
         {
@@ -403,7 +402,6 @@ namespace System.Reflection
         #region ConstructorInfo Overrides
         [DebuggerStepThroughAttribute]
         [Diagnostics.DebuggerHidden]
-        [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
         public override Object Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
         {
             INVOCATION_FLAGS invocationFlags = InvocationFlags;
index 505838f..0b4f4f2 100644 (file)
@@ -454,27 +454,10 @@ namespace System.Reflection
 
         [DebuggerStepThroughAttribute]
         [Diagnostics.DebuggerHidden]
-        [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
         public override Object Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
         {
             object[] arguments = InvokeArgumentsCheck(obj, invokeAttr, binder, parameters, culture);
 
-            return UnsafeInvokeInternal(obj, invokeAttr, parameters, arguments);
-        }
-
-        [DebuggerStepThroughAttribute]
-        [Diagnostics.DebuggerHidden]
-        internal object UnsafeInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
-        {
-            object[] arguments = InvokeArgumentsCheck(obj, invokeAttr, binder, parameters, culture);
-
-            return UnsafeInvokeInternal(obj, invokeAttr, parameters, arguments);
-        }
-
-        [DebuggerStepThroughAttribute]
-        [Diagnostics.DebuggerHidden]
-        private object UnsafeInvokeInternal(Object obj, BindingFlags invokeAttr, Object[] parameters, Object[] arguments)
-        {
             bool wrapExceptions = (invokeAttr & BindingFlags.DoNotWrapExceptions) == 0;
             if (arguments == null || arguments.Length == 0)
                 return RuntimeMethodHandle.InvokeMethod(obj, null, Signature, false, wrapExceptions);
@@ -570,8 +553,6 @@ namespace System.Reflection
 
         public override Delegate CreateDelegate(Type delegateType)
         {
-            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-
             // This API existed in v1/v1.1 and only expected to create closed
             // instance delegates. Constrain the call to BindToMethodInfo to
             // open delegates only for backwards compatibility. But we'll allow
@@ -583,14 +564,11 @@ namespace System.Reflection
             return CreateDelegateInternal(
                 delegateType,
                 null,
-                DelegateBindingFlags.OpenDelegateOnly | DelegateBindingFlags.RelaxedSignature,
-                ref stackMark);
+                DelegateBindingFlags.OpenDelegateOnly | DelegateBindingFlags.RelaxedSignature);
         }
 
         public override Delegate CreateDelegate(Type delegateType, Object target)
         {
-            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-
             // This API is new in Whidbey and allows the full range of delegate
             // flexability (open or closed delegates binding to static or
             // instance methods with relaxed signature checking). The delegate
@@ -599,11 +577,10 @@ namespace System.Reflection
             return CreateDelegateInternal(
                 delegateType,
                 target,
-                DelegateBindingFlags.RelaxedSignature,
-                ref stackMark);
+                DelegateBindingFlags.RelaxedSignature);
         }
 
-        private Delegate CreateDelegateInternal(Type delegateType, Object firstArgument, DelegateBindingFlags bindingFlags, ref StackCrawlMark stackMark)
+        private Delegate CreateDelegateInternal(Type delegateType, Object firstArgument, DelegateBindingFlags bindingFlags)
         {
             // Validate the parameters.
             if (delegateType == null)
@@ -616,7 +593,7 @@ namespace System.Reflection
             if (!rtType.IsDelegate())
                 throw new ArgumentException(SR.Arg_MustBeDelegate, nameof(delegateType));
 
-            Delegate d = Delegate.CreateDelegateInternal(rtType, this, firstArgument, bindingFlags, ref stackMark);
+            Delegate d = Delegate.CreateDelegateInternal(rtType, this, firstArgument, bindingFlags);
             if (d == null)
             {
                 throw new ArgumentException(SR.Arg_DlgtTargMeth);
index abe324e..4603ee7 100644 (file)
@@ -377,7 +377,8 @@ namespace System.Runtime.CompilerServices
             IAsyncStateMachineBox box = GetStateMachineBox(ref stateMachine);
 
             // The null tests here ensure that the jit can optimize away the interface
-            // tests when TAwaiter is is a ref type.
+            // tests when TAwaiter is a ref type.
+
             if ((null != (object)default(TAwaiter)) && (awaiter is ITaskAwaiter))
             {
                 ref TaskAwaiter ta = ref Unsafe.As<TAwaiter, TaskAwaiter>(ref awaiter); // relies on TaskAwaiter/TaskAwaiter<T> having the same layout
@@ -390,17 +391,25 @@ namespace System.Runtime.CompilerServices
             }
             else if ((null != (object)default(TAwaiter)) && (awaiter is IValueTaskAwaiter))
             {
-                Task t = ((IValueTaskAwaiter)awaiter).GetTask();
-                TaskAwaiter.UnsafeOnCompletedInternal(t, box, continueOnCapturedContext: true);
-            }
-            else if ((null != (object)default(TAwaiter)) && (awaiter is IConfiguredValueTaskAwaiter))
-            {
-                Task t = ((IConfiguredValueTaskAwaiter)awaiter).GetTask(out bool continueOnCapturedContext);
-                TaskAwaiter.UnsafeOnCompletedInternal(t, box, continueOnCapturedContext);
+                try
+                {
+                    ((IValueTaskAwaiter)awaiter).AwaitUnsafeOnCompleted(box);
+                }
+                catch (Exception e)
+                {
+                    // Whereas with Task the code that hooks up and invokes the continuation is all local to corelib,
+                    // with ValueTaskAwaiter we may be calling out to an arbitrary implementation of IValueTaskSource
+                    // wrapped in the ValueTask, and as such we protect against errant exceptions that may emerge.
+                    // We don't want such exceptions propagating back into the async method, which can't handle
+                    // exceptions well at that location in the state machine, especially if the exception may occur
+                    // after the ValueTaskAwaiter already successfully hooked up the callback, in which case it's possible
+                    // two different flows of execution could end up happening in the same async method call.
+                    AsyncMethodBuilderCore.ThrowAsync(e, targetContext: null);
+                }
             }
-            // The awaiter isn't specially known. Fall back to doing a normal await.
             else
             {
+                // The awaiter isn't specially known. Fall back to doing a normal await.
                 try
                 {
                     awaiter.UnsafeOnCompleted(box.MoveNextAction);
@@ -523,13 +532,17 @@ namespace System.Runtime.CompilerServices
             public ExecutionContext Context;
 
             /// <summary>A delegate to the <see cref="MoveNext"/> method.</summary>
-            public Action MoveNextAction =>
-                _moveNextAction ??
-                (_moveNextAction = AsyncCausalityTracer.LoggingOn ? AsyncMethodBuilderCore.OutputAsyncCausalityEvents(this, new Action(MoveNext)) : new Action(MoveNext));
+            public Action MoveNextAction => _moveNextAction ?? (_moveNextAction = new Action(MoveNext));
 
             /// <summary>Calls MoveNext on <see cref="StateMachine"/></summary>
             public void MoveNext()
             {
+                bool loggingOn = AsyncCausalityTracer.LoggingOn;
+                if (loggingOn)
+                {
+                    AsyncCausalityTracer.TraceSynchronousWorkStart(CausalityTraceLevel.Required, Id, CausalitySynchronousWork.Execution);
+                }
+
                 ExecutionContext context = Context;
                 if (context == null)
                 {
@@ -547,6 +560,11 @@ namespace System.Runtime.CompilerServices
                 {
                     GC.SuppressFinalize(this);
                 }
+
+                if (loggingOn)
+                {
+                    AsyncCausalityTracer.TraceSynchronousWorkCompletion(CausalityTraceLevel.Required, CausalitySynchronousWork.Execution);
+                }
             }
 
             /// <summary>
@@ -554,8 +572,8 @@ namespace System.Runtime.CompilerServices
             /// that the state machine object may be queued directly as a continuation into a Task's
             /// continuation slot/list.
             /// </summary>
-            /// <param name="completedTask">The completing task that caused this method to be invoked, if there was one.</param>
-            void ITaskCompletionAction.Invoke(Task completedTask) => MoveNext();
+            /// <param name="ignored">The completing task that caused this method to be invoked, if there was one.</param>
+            void ITaskCompletionAction.Invoke(Task ignored) => MoveNext();
 
             /// <summary>Signals to Task's continuation logic that <see cref="Invoke"/> runs arbitrary user code via MoveNext.</summary>
             bool ITaskCompletionAction.InvokeMayRunArbitraryCode => true;
@@ -973,14 +991,6 @@ namespace System.Runtime.CompilerServices
             return sb.ToString();
         }
 
-        internal static Action OutputAsyncCausalityEvents(Task task, Action continuation) =>
-            CreateContinuationWrapper(continuation, (innerContinuation, innerTask) =>
-            {
-                AsyncCausalityTracer.TraceSynchronousWorkStart(CausalityTraceLevel.Required, innerTask.Id, CausalitySynchronousWork.Execution);
-                innerContinuation.Invoke(); // Invoke the original continuation
-                AsyncCausalityTracer.TraceSynchronousWorkCompletion(CausalityTraceLevel.Required, CausalitySynchronousWork.Execution);
-            }, task);
-
         internal static Action CreateContinuationWrapper(Action continuation, Action<Action,Task> invokeAction, Task innerTask) =>
             new ContinuationWrapper(continuation, invokeAction, innerTask).Invoke;
 
index ae58844..1d7a5df 100644 (file)
@@ -122,7 +122,7 @@ namespace System.Runtime.InteropServices.WindowsRuntime
 
             // We can safely skip access check because this is only used in full trust scenarios.
             // And we have already verified that the property accessor is public.
-            return rtMethod.UnsafeInvoke(target, BindingFlags.Default, null, args, null);
+            return rtMethod.Invoke(target, BindingFlags.Default, null, args, null);
         }
 
         public Type Type
index aea3616..11f754c 100644 (file)
@@ -139,10 +139,6 @@ namespace System.Threading
 #pragma warning restore 414
 #pragma warning restore 169
 
-        private bool m_ExecutionContextBelongsToOuterScope;
-#if DEBUG
-        private bool m_ForbidExecutionContextMutation;
-#endif
 
         // Do not move! Order of above fields needs to be preserved for alignment
         // with native code
@@ -233,14 +229,6 @@ namespace System.Threading
         **
         ** Exceptions: ThreadStateException if the thread has already been started.
         =========================================================================*/
-        [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
-        public new void Start()
-        {
-            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-            Start(ref stackMark);
-        }
-
-        [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
         public new void Start(object parameter)
         {
             //In the case of a null delegate (second call to start on same thread)
@@ -253,11 +241,10 @@ namespace System.Threading
                 throw new InvalidOperationException(SR.InvalidOperation_ThreadWrongThreadStart);
             }
             m_ThreadStartArg = parameter;
-            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-            Start(ref stackMark);
+            Start();
         }
 
-        private void Start(ref StackCrawlMark stackMark)
+        public new void Start()
         {
 #if FEATURE_COMINTEROP_APARTMENT_SUPPORT
             // Eagerly initialize the COM Apartment state of the thread if we're allowed to.
@@ -276,7 +263,7 @@ namespace System.Threading
                 t.SetExecutionContextHelper(ec);
             }
 
-            StartInternal(ref stackMark);
+            StartInternal();
         }
 
         internal ExecutionContext ExecutionContext
@@ -292,7 +279,7 @@ namespace System.Threading
         }
 
         [MethodImplAttribute(MethodImplOptions.InternalCall)]
-        private extern void StartInternal(ref StackCrawlMark stackMark);
+        private extern void StartInternal();
 
 
         // Helper method to get a logical thread ID for StringBuilder (for
@@ -391,7 +378,6 @@ namespace System.Threading
         private extern void InternalFinalize();
 
 #if FEATURE_COMINTEROP_APARTMENT_SUPPORT
-
         [MethodImplAttribute(MethodImplOptions.InternalCall)]
         private extern void StartupSetApartmentStateInternal();
 #endif // FEATURE_COMINTEROP_APARTMENT_SUPPORT
index ff174b1..e10212a 100644 (file)
@@ -1149,7 +1149,6 @@ namespace System.Threading
         }
 
         [CLSCompliant(false)]
-        [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod            
         public static RegisteredWaitHandle RegisterWaitForSingleObject(  // throws RegisterWaitException
              WaitHandle waitObject,
              WaitOrTimerCallback callBack,
@@ -1158,12 +1157,10 @@ namespace System.Threading
              bool executeOnlyOnce    // NOTE: we do not allow other options that allow the callback to be queued as an APC
              )
         {
-            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-            return RegisterWaitForSingleObject(waitObject, callBack, state, millisecondsTimeOutInterval, executeOnlyOnce, ref stackMark, true);
+            return RegisterWaitForSingleObject(waitObject, callBack, state, millisecondsTimeOutInterval, executeOnlyOnce, true);
         }
 
         [CLSCompliant(false)]
-        [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
         public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(  // throws RegisterWaitException
              WaitHandle waitObject,
              WaitOrTimerCallback callBack,
@@ -1172,8 +1169,7 @@ namespace System.Threading
              bool executeOnlyOnce    // NOTE: we do not allow other options that allow the callback to be queued as an APC
              )
         {
-            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-            return RegisterWaitForSingleObject(waitObject, callBack, state, millisecondsTimeOutInterval, executeOnlyOnce, ref stackMark, false);
+            return RegisterWaitForSingleObject(waitObject, callBack, state, millisecondsTimeOutInterval, executeOnlyOnce, false);
         }
 
 
@@ -1183,7 +1179,6 @@ namespace System.Threading
              Object state,
              uint millisecondsTimeOutInterval,
              bool executeOnlyOnce,   // NOTE: we do not allow other options that allow the callback to be queued as an APC
-             ref StackCrawlMark stackMark,
              bool compressStack
              )
         {
@@ -1200,9 +1195,7 @@ namespace System.Threading
                                                                                state,
                                                                                millisecondsTimeOutInterval,
                                                                                executeOnlyOnce,
-                                                                               registeredWaitHandle,
-                                                                               ref stackMark,
-                                                                               compressStack);
+                                                                               registeredWaitHandle);
                 registeredWaitHandle.SetHandle(nativeRegisteredWaitHandle);
             }
             else
@@ -1213,7 +1206,6 @@ namespace System.Threading
         }
 
 
-        [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
         public static RegisteredWaitHandle RegisterWaitForSingleObject(  // throws RegisterWaitException
              WaitHandle waitObject,
              WaitOrTimerCallback callBack,
@@ -1224,11 +1216,9 @@ namespace System.Threading
         {
             if (millisecondsTimeOutInterval < -1)
                 throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), SR.ArgumentOutOfRange_NeedNonNegOrNegative1);
-            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-            return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)millisecondsTimeOutInterval, executeOnlyOnce, ref stackMark, true);
+            return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)millisecondsTimeOutInterval, executeOnlyOnce, true);
         }
 
-        [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod            
         public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(  // throws RegisterWaitException
              WaitHandle waitObject,
              WaitOrTimerCallback callBack,
@@ -1239,11 +1229,9 @@ namespace System.Threading
         {
             if (millisecondsTimeOutInterval < -1)
                 throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), SR.ArgumentOutOfRange_NeedNonNegOrNegative1);
-            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-            return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)millisecondsTimeOutInterval, executeOnlyOnce, ref stackMark, false);
+            return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)millisecondsTimeOutInterval, executeOnlyOnce, false);
         }
 
-        [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
         public static RegisteredWaitHandle RegisterWaitForSingleObject(  // throws RegisterWaitException
             WaitHandle waitObject,
             WaitOrTimerCallback callBack,
@@ -1254,11 +1242,9 @@ namespace System.Threading
         {
             if (millisecondsTimeOutInterval < -1)
                 throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), SR.ArgumentOutOfRange_NeedNonNegOrNegative1);
-            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-            return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)millisecondsTimeOutInterval, executeOnlyOnce, ref stackMark, true);
+            return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)millisecondsTimeOutInterval, executeOnlyOnce, true);
         }
 
-        [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
         public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(  // throws RegisterWaitException
             WaitHandle waitObject,
             WaitOrTimerCallback callBack,
@@ -1269,11 +1255,9 @@ namespace System.Threading
         {
             if (millisecondsTimeOutInterval < -1)
                 throw new ArgumentOutOfRangeException(nameof(millisecondsTimeOutInterval), SR.ArgumentOutOfRange_NeedNonNegOrNegative1);
-            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-            return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)millisecondsTimeOutInterval, executeOnlyOnce, ref stackMark, false);
+            return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)millisecondsTimeOutInterval, executeOnlyOnce, false);
         }
 
-        [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
         public static RegisteredWaitHandle RegisterWaitForSingleObject(
                           WaitHandle waitObject,
                           WaitOrTimerCallback callBack,
@@ -1287,11 +1271,9 @@ namespace System.Threading
                 throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1);
             if (tm > (long)Int32.MaxValue)
                 throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_LessEqualToIntegerMaxVal);
-            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-            return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)tm, executeOnlyOnce, ref stackMark, true);
+            return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)tm, executeOnlyOnce, true);
         }
 
-        [System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod
         public static RegisteredWaitHandle UnsafeRegisterWaitForSingleObject(
                           WaitHandle waitObject,
                           WaitOrTimerCallback callBack,
@@ -1305,8 +1287,7 @@ namespace System.Threading
                 throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_NeedNonNegOrNegative1);
             if (tm > (long)Int32.MaxValue)
                 throw new ArgumentOutOfRangeException(nameof(timeout), SR.ArgumentOutOfRange_LessEqualToIntegerMaxVal);
-            StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-            return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)tm, executeOnlyOnce, ref stackMark, false);
+            return RegisterWaitForSingleObject(waitObject, callBack, state, (UInt32)tm, executeOnlyOnce, false);
         }
 
         public static bool QueueUserWorkItem(WaitCallback callBack) =>
@@ -1529,9 +1510,7 @@ namespace System.Threading
              Object state,
              uint timeOutInterval,
              bool executeOnlyOnce,
-             RegisteredWaitHandle registeredWaitHandle,
-             ref StackCrawlMark stackMark,
-             bool compressStack
+             RegisteredWaitHandle registeredWaitHandle
              );
 
 
index 06c1d45..6b755a1 100644 (file)
@@ -477,7 +477,9 @@ namespace System
         start,
         format,
         culture,
-        comparable
+        comparable,
+        source,
+        state
     }
 
     //
index 61b81a0..6c58fe7 100644 (file)
@@ -503,10 +503,10 @@ MethodTable* Module::CreateArrayMethodTable(TypeHandle elemTypeHnd, CorElementTy
     if (arrayKind == ELEMENT_TYPE_ARRAY)
         baseSize += Rank*sizeof(DWORD)*2;
 
-#if !defined(_WIN64) && (DATA_ALIGNMENT > 4) 
+#if !defined(_TARGET_64BIT_) && (DATA_ALIGNMENT > 4)
     if (dwComponentSize >= DATA_ALIGNMENT)
         baseSize = (DWORD)ALIGN_UP(baseSize, DATA_ALIGNMENT);
-#endif // !defined(_WIN64) && (DATA_ALIGNMENT > 4)
+#endif // !defined(_TARGET_64BIT_) && (DATA_ALIGNMENT > 4)
     pMT->SetBaseSize(baseSize);
     // Because of array method table persisting, we need to copy the map
     for (unsigned index = 0; index < pParentClass->GetNumInterfaces(); ++index)
index a80e7f6..50724c0 100644 (file)
 #pragma warning(disable:4244)
 #endif // _MSC_VER
 
-#ifdef _WIN64 
+#ifdef _TARGET_64BIT_
 #define COR_VTABLE_PTRSIZED     COR_VTABLE_64BIT
 #define COR_VTABLE_NOT_PTRSIZED COR_VTABLE_32BIT
-#else // !_WIN64
+#else // !_TARGET_64BIT_
 #define COR_VTABLE_PTRSIZED     COR_VTABLE_32BIT
 #define COR_VTABLE_NOT_PTRSIZED COR_VTABLE_64BIT
-#endif // !_WIN64
+#endif // !_TARGET_64BIT_
 
 #define CEE_FILE_GEN_GROWTH_COLLECTIBLE 2048
 
index cd2bbba..c3e0637 100644 (file)
@@ -991,9 +991,9 @@ CorElementType EEClass::ComputeInternalCorElementTypeForValueType(MethodTable *
 
     if (pMT->GetNumInstanceFields() == 1 && (!pMT->HasLayout()
         || pMT->GetNumInstanceFieldBytes() == 4
-#ifdef _WIN64
+#ifdef _TARGET_64BIT_
         || pMT->GetNumInstanceFieldBytes() == 8
-#endif // _WIN64
+#endif // _TARGET_64BIT_
         )) // Don't do the optimization if we're getting specified anything but the trivial layout.
     {
         FieldDesc * pFD = pMT->GetApproxFieldDescListRaw();
@@ -1025,10 +1025,10 @@ CorElementType EEClass::ComputeInternalCorElementTypeForValueType(MethodTable *
             case ELEMENT_TYPE_U:
             case ELEMENT_TYPE_I4:
             case ELEMENT_TYPE_U4:
-#ifdef _WIN64 
+#ifdef _TARGET_64BIT_
             case ELEMENT_TYPE_I8:
             case ELEMENT_TYPE_U8:
-#endif // _WIN64
+#endif // _TARGET_64BIT_
             
             {
                 return type;
index ec5313f..d69329f 100644 (file)
@@ -2188,9 +2188,9 @@ HeapList* LoaderCodeHeap::CreateCodeHeap(CodeHeapRequestInfo *pInfo, LoaderHeap
          DBG_ADDR(pHp->startAddress), DBG_ADDR(pHp->startAddress+pHp->maxCodeHeapSize)
          ));
 
-#ifdef _WIN64
+#ifdef _TARGET_64BIT_
     emitJump((LPBYTE)pHp->CLRPersonalityRoutine, (void *)ProcessCLRException);
-#endif
+#endif // _TARGET_64BIT_
 
     pCodeHeap.SuppressRelease();
     RETURN pHp;
index 0663d59..e30b633 100644 (file)
@@ -1277,7 +1277,7 @@ public:
         BOOL Acquired();
     };
 
-#ifdef _WIN64
+#ifdef _TARGET_64BIT_
     static ULONG          GetCLRPersonalityRoutineValue()
     {
         LIMITED_METHOD_CONTRACT;
@@ -1285,7 +1285,7 @@ public:
             (size_t)((ULONG)offsetof(HeapList, CLRPersonalityRoutine)));
         return offsetof(HeapList, CLRPersonalityRoutine);
     }
-#endif // _WIN64
+#endif // _TARGET_64BIT_
 
     static EEJitManager * GetEEJitManager()
     {
index 322bcdc..5c2e187 100644 (file)
@@ -5398,7 +5398,7 @@ void ComCallWrapperTemplate::Cleanup()
     if (m_pIIDToInterfaceTemplateCache)
         delete m_pIIDToInterfaceTemplateCache;
 
-    delete[] this;
+    delete[] (BYTE*)this;
 }
 
 
index 9d8274d..6d8c168 100644 (file)
@@ -334,17 +334,17 @@ HRESULT CEECompileInfo::LoadAssemblyByPath(
         // by LoadAssembly then we can blame it on bitness mismatch.  We do the check here
         // and not in the CATCH to distinguish between the COR_IMAGE_ERROR that can be thrown by
         // VerifyIsAssembly (not necessarily a bitness mismatch) and that from LoadAssembly
-#ifdef _WIN64
+#ifdef _TARGET_64BIT_
         if (pImage->Has32BitNTHeaders())
         {
             hrProcessLibraryBitnessMismatch = PEFMT_E_32BIT;
         }
-#else
+#else // !_TARGET_64BIT_
         if (!pImage->Has32BitNTHeaders())
         {
             hrProcessLibraryBitnessMismatch = PEFMT_E_64BIT;
         }
-#endif
+#endif // !_TARGET_64BIT_
         
         AssemblySpec spec;
         spec.InitializeSpec(TokenFromRid(1, mdtAssembly), pImage->GetMDImport(), NULL, FALSE);
index c0d31f0..a2cc4f0 100644 (file)
@@ -399,20 +399,20 @@ ULONG WINAPI ThreadNative::KickOffThread(void* pass)
 }
 
 
-FCIMPL2(void, ThreadNative::Start, ThreadBaseObject* pThisUNSAFE, StackCrawlMark* pStackMark)
+FCIMPL1(void, ThreadNative::Start, ThreadBaseObject* pThisUNSAFE)
 {
     FCALL_CONTRACT;
 
     HELPER_METHOD_FRAME_BEGIN_NOPOLL();
 
-    StartInner(pThisUNSAFE, pStackMark);
+    StartInner(pThisUNSAFE);
 
     HELPER_METHOD_FRAME_END_POLL();
 }
 FCIMPLEND
 
 // Start up a thread, which by now should be in the ThreadStore's Unstarted list.
-void ThreadNative::StartInner(ThreadBaseObject* pThisUNSAFE, StackCrawlMark* pStackMark)
+void ThreadNative::StartInner(ThreadBaseObject* pThisUNSAFE)
 {
     CONTRACTL
     {
index 589fce3..87321fd 100644 (file)
@@ -64,11 +64,11 @@ public:
     static LPVOID F_CALL_CONV FastGetCurrentThread();
     static LPVOID F_CALL_CONV FastGetDomain();
 
-    static void StartInner(ThreadBaseObject* pThisUNSAFE, StackCrawlMark* pStackMark);
+    static void StartInner(ThreadBaseObject* pThisUNSAFE);
 
     static FCDECL1(void, Abort, ThreadBaseObject* pThis);
     static FCDECL1(void, ResetAbort, ThreadBaseObject* pThis);
-    static FCDECL2(void,    Start,             ThreadBaseObject* pThisUNSAFE, StackCrawlMark* pStackMark);
+    static FCDECL1(void,    Start,             ThreadBaseObject* pThisUNSAFE);
     static FCDECL1(INT32,   GetPriority,       ThreadBaseObject* pThisUNSAFE);
     static FCDECL2(void,    SetPriority,       ThreadBaseObject* pThisUNSAFE, INT32 iPriority);
     static FCDECL1(void,    Interrupt,         ThreadBaseObject* pThisUNSAFE);
index 6ab6b60..fcb51dc 100644 (file)
@@ -120,9 +120,6 @@ DelegateInfo *DelegateInfo::MakeDelegateInfo(AppDomain *pAppDomain,
     else
         delegateInfo->m_registeredWaitHandle = NULL;
 
-    delegateInfo->m_overridesCount = 0;
-    delegateInfo->m_hasSecurityInfo = FALSE;
-
     delegateInfo.SuppressRelease();
     
     return delegateInfo;
@@ -372,20 +369,12 @@ VOID NTAPI RegisterWaitForSingleObjectCallback(PVOID delegateInfo, BOOLEAN Timer
     return;
 }
 
-void ThreadPoolNative::Init()
-{
-
-}
-
-
-FCIMPL7(LPVOID, ThreadPoolNative::CorRegisterWaitForSingleObject,
+FCIMPL5(LPVOID, ThreadPoolNative::CorRegisterWaitForSingleObject,
                                         Object* waitObjectUNSAFE,
                                         Object* stateUNSAFE,
                                         UINT32 timeout,
                                         CLR_BOOL executeOnlyOnce,
-                                        Object* registeredWaitObjectUNSAFE,
-                                        StackCrawlMark* stackMark,
-                                        CLR_BOOL compressStack)
+                                        Object* registeredWaitObjectUNSAFE)
 {
     FCALL_CONTRACT;
     
@@ -422,13 +411,6 @@ FCIMPL7(LPVOID, ThreadPoolNative::CorRegisterWaitForSingleObject,
                                                                 (OBJECTREF *)&gc.waitObject,
                                                                 &gc.registeredWaitObject);
 
-    if (compressStack)
-    {
-        delegateInfo->SetThreadSecurityInfo( pCurThread, stackMark );
-    }
-
-
-
     if (!(ThreadpoolMgr::RegisterWaitForSingleObject(&handle,
                                           hWaitHandle,
                                           RegisterWaitForSingleObjectCallback,
index 3e01717..6b0f4ec 100644 (file)
@@ -23,9 +23,6 @@ class ThreadPoolNative
 {
 
 public:
-
-    static void Init();
-
     static FCDECL2(FC_BOOL_RET, CorSetMaxThreads, DWORD workerThreads, DWORD completionPortThreads);
     static FCDECL2(VOID, CorGetMaxThreads, DWORD* workerThreads, DWORD* completionPortThreads);
     static FCDECL2(FC_BOOL_RET, CorSetMinThreads, DWORD workerThreads, DWORD completionPortThreads);
@@ -40,14 +37,12 @@ public:
     static FCDECL1(void, ReportThreadStatus, CLR_BOOL isWorking);
 
 
-    static FCDECL7(LPVOID, CorRegisterWaitForSingleObject,
+    static FCDECL5(LPVOID, CorRegisterWaitForSingleObject,
                                 Object* waitObjectUNSAFE,
                                 Object* stateUNSAFE,
                                 UINT32 timeout,
                                 CLR_BOOL executeOnlyOnce,
-                                Object* registeredWaitObjectUNSAFE,
-                                StackCrawlMark* stackMark,
-                                CLR_BOOL compressStack);
+                                Object* registeredWaitObjectUNSAFE);
 
     static BOOL QCALLTYPE RequestWorkerThread();
 
index 0167ec5..90f3d4c 100644 (file)
 typedef BYTE ZapRelocationType; // IMAGE_REL_XXX enum
 
 // IMAGE_REL_BASED_PTR is architecture specific reloc of virtual address
-#ifdef _WIN64
+#ifdef _TARGET_64BIT_
 #define IMAGE_REL_BASED_PTR IMAGE_REL_BASED_DIR64
-#else
+#else // !_TARGET_64BIT_
 #define IMAGE_REL_BASED_PTR IMAGE_REL_BASED_HIGHLOW
-#endif
+#endif // !_TARGET_64BIT_
 
 // Special NGEN-specific relocation type for relative pointer (used to make NGen relocation section smaller)
 #define IMAGE_REL_BASED_RELPTR            0x7D
index c8a3e36..80a69a6 100644 (file)
@@ -25,21 +25,6 @@ struct DelegateInfo
     OBJECTHANDLE    m_stateHandle;
     OBJECTHANDLE    m_eventHandle;
     OBJECTHANDLE    m_registeredWaitHandle;
-    DWORD           m_overridesCount;
-    BOOL            m_hasSecurityInfo;
-
-    void SetThreadSecurityInfo( Thread* thread, StackCrawlMark* stackMark )
-    {
-        CONTRACTL {
-            THROWS;
-            GC_TRIGGERS;
-            MODE_COOPERATIVE; 
-            INJECT_FAULT(COMPlusThrowOM());
-        }
-        CONTRACTL_END;
-
-
-    }
 
 #ifndef DACCESS_COMPILE
     void Release()
index 345b3d6..d019631 100644 (file)
@@ -1373,7 +1373,7 @@ public:
         // convert 'this' to COM IP and the target method entry point
         m_slIL.EmitLoadRCWThis(pcsDispatch, m_dwStubFlags);
 
-#ifdef _WIN64
+#ifdef _TARGET_64BIT_
         if (SF_IsWinRTDelegateStub(m_dwStubFlags))
         {
             // write the stub context (EEImplMethodDesc representing the Invoke)
@@ -1386,7 +1386,7 @@ public:
             pcsDispatch->EmitCALL(METHOD__STUBHELPERS__GET_STUB_CONTEXT, 0, 1);
         }
         else
-#endif // _WIN64
+#endif // _TARGET_64BIT_
         {
             m_slIL.EmitLoadStubContext(pcsDispatch, dwStubFlags);
         }
@@ -2235,15 +2235,15 @@ void NDirectStubLinker::DoNDirect(ILCodeStream *pcsEmit, DWORD dwStubFlags, Meth
             // get the delegate unmanaged target - we call a helper instead of just grabbing
             // the _methodPtrAux field because we may need to intercept the call for host, MDA, etc.
             pcsEmit->EmitLoadThis();
-#ifdef _WIN64
+#ifdef _TARGET_64BIT_
             // on AMD64 GetDelegateTarget will return address of the generic stub for host when we are hosted
             // and update the secret argument with real target - the secret arg will be embedded in the
             // InlinedCallFrame by the JIT and fetched via TLS->Thread->Frame->Datum by the stub for host
             pcsEmit->EmitCALL(METHOD__STUBHELPERS__GET_STUB_CONTEXT_ADDR, 0, 1);
-#else // _WIN64
+#else // !_TARGET_64BIT_
             // we don't need to do this on x86 because stub for host is generated dynamically per target
             pcsEmit->EmitLDNULL();
-#endif // _WIN64
+#endif // !_TARGET_64BIT_
             pcsEmit->EmitCALL(METHOD__STUBHELPERS__GET_DELEGATE_TARGET, 2, 1);
         }
         else // direct invocation
index 460ebf6..4c69609 100644 (file)
@@ -1159,9 +1159,9 @@ FCFuncStart(gStubHelperFuncs)
     FCFuncElement("ValidateByref", StubHelpers::ValidateByref)
     FCFuncElement("LogPinnedArgument", StubHelpers::LogPinnedArgument)
     FCIntrinsic("GetStubContext", StubHelpers::GetStubContext, CORINFO_INTRINSIC_StubHelpers_GetStubContext)
-#ifdef _WIN64
+#ifdef _TARGET_64BIT_
     FCIntrinsic("GetStubContextAddr", StubHelpers::GetStubContextAddr, CORINFO_INTRINSIC_StubHelpers_GetStubContextAddr)
-#endif // _WIN64
+#endif // _TARGET_64BIT_
 #ifdef MDA_SUPPORTED
     FCFuncElement("TriggerGCForMDA", StubHelpers::TriggerGCForMDA)
 #endif // MDA_SUPPORTED
index 750fc43..1e24399 100644 (file)
@@ -496,14 +496,11 @@ do                                                      \
 #endif // FEATURE_COMINTEROP
             if (fDefault || ntype == NATIVE_TYPE_INT || ntype == NATIVE_TYPE_UINT)
             {
-                if (sizeof(LPVOID)==4)
-                {
-                    INITFIELDMARSHALER(NFT_COPY4, FieldMarshaler_Copy4, ());
-                }
-                else
-                {
-                    INITFIELDMARSHALER(NFT_COPY8, FieldMarshaler_Copy8, ());
-                }
+#ifdef _TARGET_64BIT_
+                INITFIELDMARSHALER(NFT_COPY8, FieldMarshaler_Copy8, ());
+#else // !_TARGET_64BIT_
+                INITFIELDMARSHALER(NFT_COPY4, FieldMarshaler_Copy4, ());
+#endif // !_TARGET_64BIT_
             }
             else
             {
@@ -543,20 +540,11 @@ do                                                      \
 #endif // FEATURE_COMINTEROP
             if (fDefault)
             {
-                switch (sizeof(LPVOID))
-                {
-                    case 4:
-                        INITFIELDMARSHALER(NFT_COPY4, FieldMarshaler_Copy4, ());
-                        break;
-                        
-                    case 8:
-                        INITFIELDMARSHALER(NFT_COPY8, FieldMarshaler_Copy8, ());
-                        break;
-
-                    default:
-                        INITFIELDMARSHALER(NFT_ILLEGAL, FieldMarshaler_Illegal, (IDS_EE_BADMARSHAL_BADMANAGED));
-                        break;
-                }
+#ifdef _TARGET_64BIT_
+                INITFIELDMARSHALER(NFT_COPY8, FieldMarshaler_Copy8, ());
+#else // !_TARGET_64BIT_
+                INITFIELDMARSHALER(NFT_COPY4, FieldMarshaler_Copy4, ());
+#endif // !_TARGET_64BIT_
             }
             else
             {
index 179a42d..6464e58 100644 (file)
@@ -8087,17 +8087,17 @@ VOID    MethodTableBuilder::PlaceInstanceFields(MethodTable ** pByValueClassCach
                     // value classes could have GC pointers in them, which need to be pointer-size aligned
                     // so do this if it has not been done already
 
-#if !defined(_WIN64) && (DATA_ALIGNMENT > 4) 
+#if !defined(_TARGET_64BIT_) && (DATA_ALIGNMENT > 4) 
                 dwCumulativeInstanceFieldPos = (DWORD)ALIGN_UP(dwCumulativeInstanceFieldPos,
                     (pByValueMT->GetNumInstanceFieldBytes() >= DATA_ALIGNMENT) ? DATA_ALIGNMENT : TARGET_POINTER_SIZE);
-#else // !(!defined(_WIN64) && (DATA_ALIGNMENT > 4))
+#else // !(!defined(_TARGET_64BIT_) && (DATA_ALIGNMENT > 4))
 #ifdef FEATURE_64BIT_ALIGNMENT
                 if (pByValueMT->RequiresAlign8())
                     dwCumulativeInstanceFieldPos = (DWORD)ALIGN_UP(dwCumulativeInstanceFieldPos, 8);
                 else
 #endif // FEATURE_64BIT_ALIGNMENT
                     dwCumulativeInstanceFieldPos = (DWORD)ALIGN_UP(dwCumulativeInstanceFieldPos, TARGET_POINTER_SIZE);
-#endif // !(!defined(_WIN64) && (DATA_ALIGNMENT > 4))
+#endif // !(!defined(_TARGET_64BIT_) && (DATA_ALIGNMENT > 4))
 
                 pFieldDescList[i].SetOffset(dwCumulativeInstanceFieldPos - dwOffsetBias);
                 dwCumulativeInstanceFieldPos += pByValueMT->GetAlignedNumInstanceFieldBytes();
index 528f2d9..0af6c94 100644 (file)
@@ -1058,9 +1058,9 @@ DEFINE_METHOD(STUBHELPERS,          VALIDATE_OBJECT,                    Validate
 DEFINE_METHOD(STUBHELPERS,          VALIDATE_BYREF,                     ValidateByref,                  SM_IntPtr_IntPtr_Obj_RetVoid)
 DEFINE_METHOD(STUBHELPERS,          GET_STUB_CONTEXT,                   GetStubContext,                 SM_RetIntPtr)
 DEFINE_METHOD(STUBHELPERS,          LOG_PINNED_ARGUMENT,                LogPinnedArgument,              SM_IntPtr_IntPtr_RetVoid)
-#ifdef _WIN64
+#ifdef _TARGET_64BIT_
 DEFINE_METHOD(STUBHELPERS,          GET_STUB_CONTEXT_ADDR,              GetStubContextAddr,             SM_RetIntPtr)
-#endif // _WIN64
+#endif // _TARGET_64BIT_
 #ifdef MDA_SUPPORTED
 DEFINE_METHOD(STUBHELPERS,          TRIGGER_GC_FOR_MDA,                 TriggerGCForMDA,                SM_RetVoid)
 #endif
index e6e0c02..5970806 100644 (file)
@@ -601,9 +601,9 @@ private:
     // Object::GetSize() looks at m_NumComponents even though it may not be an array (the
     // values is shifted out if not an array, so it's ok). 
     DWORD       m_NumComponents;
-#ifdef _WIN64
+#ifdef _TARGET_64BIT_
     DWORD       pad;
-#endif // _WIN64
+#endif // _TARGET_64BIT_
 
     SVAL_DECL(INT32, s_arrayBoundsZero); // = 0
 
@@ -1458,9 +1458,6 @@ private:
     OBJECTREF     m_SynchronizationContext;
     OBJECTREF     m_Name;
     OBJECTREF     m_Delegate;
-#ifdef IO_CANCELLATION_ENABLED
-    OBJECTREF     m_CancellationSignals;
-#endif
     OBJECTREF     m_ThreadStartArg;
 
     // The next field (m_InternalThread) is declared as IntPtr in the managed
@@ -1474,11 +1471,6 @@ private:
     //We need to cache the thread id in managed code for perf reasons.
     INT32         m_ManagedThreadId;
 
-    CLR_BOOL      m_ExecutionContextBelongsToCurrentScope;
-#ifdef _DEBUG
-    CLR_BOOL      m_ForbidExecutionContextMutation;
-#endif
-
 protected:
     // the ctor and dtor can do no useful work.
     ThreadBaseObject() {LIMITED_METHOD_CONTRACT;};
index 306a522..88ecf44 100644 (file)
@@ -286,7 +286,7 @@ void PEFile::LoadLibrary(BOOL allowNativeSkip/*=TRUE*/) // if allowNativeSkip==F
         RETURN;
     }
 
-#if !defined(_WIN64)
+#if !defined(_TARGET_64BIT_)
     if (!HasNativeImage() && (!GetILimage()->Has32BitNTHeaders()) && !IsIntrospectionOnly())
     {
         // Tried to load 64-bit assembly on 32-bit platform.
index 034b30e..ea3d888 100644 (file)
@@ -590,113 +590,3 @@ PEImageLayout::EnumMemoryRegions(CLRDataEnumMemoryFlags flags)
     PEDecoder::EnumMemoryRegions(flags,false);
 }
 #endif //DACCESS_COMPILE
-
-#if defined(_WIN64) && !defined(DACCESS_COMPILE)
-
-#define IMAGE_HEADER_3264_SIZE_DIFF (sizeof(IMAGE_NT_HEADERS64) - sizeof(IMAGE_NT_HEADERS32)) 
-
-// This function is expected to be in sync with LdrpCorFixupImage in the OS loader implementation (//depot/winmain/minkernel/ntdll/ldrcor.c).
-bool PEImageLayout::ConvertILOnlyPE32ToPE64Worker()
-{
-    CONTRACTL
-    {
-        NOTHROW;
-        GC_NOTRIGGER;
-        MODE_ANY;
-        PRECONDITION(IsILOnly()); // This should be called for IL-Only images
-        PRECONDITION(Has32BitNTHeaders()); // // Image should be marked to have a PE32 header only.
-        PRECONDITION(IsPlatformNeutral());
-    }
-    CONTRACTL_END;
-    
-    PBYTE pImage = (PBYTE)GetBase();
-    
-    IMAGE_DOS_HEADER *pDosHeader = (IMAGE_DOS_HEADER*)pImage;
-    IMAGE_NT_HEADERS32 *pHeader32 = GetNTHeaders32();
-    IMAGE_NT_HEADERS64 *pHeader64 = GetNTHeaders64();
-
-    _ASSERTE(&pHeader32->OptionalHeader.Magic == &pHeader64->OptionalHeader.Magic);
-    _ASSERTE(pHeader32->OptionalHeader.Magic == VAL16(IMAGE_NT_OPTIONAL_HDR32_MAGIC));
-
-    // Move the data directory and section headers down IMAGE_HEADER_3264_SIZE_DIFF bytes.
-    PBYTE pStart32 = (PBYTE) &pHeader32->OptionalHeader.DataDirectory[0];
-    PBYTE pStart64 = (PBYTE) &pHeader64->OptionalHeader.DataDirectory[0];
-    _ASSERTE(pStart64 - pStart32 == IMAGE_HEADER_3264_SIZE_DIFF);
-
-    PBYTE pEnd32 = (PBYTE) (IMAGE_FIRST_SECTION(pHeader32)
-                            + VAL16(pHeader32->FileHeader.NumberOfSections));
-    
-    // On AMD64, used for a 12-byte jump thunk + the original entry point offset.
-    if (((pEnd32 + IMAGE_HEADER_3264_SIZE_DIFF /* delta in headers to compute end of 64bit header */) - pImage) > GetOsPageSize() ) {
-        // This should never happen.  An IL_ONLY image should at most 3 sections.  
-        _ASSERTE(!"ConvertILOnlyPE32ToPE64Worker: Insufficient room to rewrite headers as PE64");
-        return false;
-    }
-
-    memmove(pStart64, pStart32, pEnd32 - pStart32);
-
-    // Move the tail fields in reverse order.
-    pHeader64->OptionalHeader.NumberOfRvaAndSizes = pHeader32->OptionalHeader.NumberOfRvaAndSizes;
-    pHeader64->OptionalHeader.LoaderFlags = pHeader32->OptionalHeader.LoaderFlags;
-    pHeader64->OptionalHeader.SizeOfHeapCommit = VAL64(VAL32(pHeader32->OptionalHeader.SizeOfHeapCommit));
-    pHeader64->OptionalHeader.SizeOfHeapReserve = VAL64(VAL32(pHeader32->OptionalHeader.SizeOfHeapReserve));
-    pHeader64->OptionalHeader.SizeOfStackCommit = VAL64(VAL32(pHeader32->OptionalHeader.SizeOfStackCommit));
-    pHeader64->OptionalHeader.SizeOfStackReserve = VAL64(VAL32(pHeader32->OptionalHeader.SizeOfStackReserve));
-
-    // One more field that's not the same
-    pHeader64->OptionalHeader.ImageBase = VAL64(VAL32(pHeader32->OptionalHeader.ImageBase));
-
-    // The optional header changed size.
-    pHeader64->FileHeader.SizeOfOptionalHeader = VAL16(VAL16(pHeader64->FileHeader.SizeOfOptionalHeader) + 16);
-    pHeader64->OptionalHeader.Magic = VAL16(IMAGE_NT_OPTIONAL_HDR64_MAGIC);
-
-    // Now we just have to make a new 16-byte PPLABEL_DESCRIPTOR for the new entry point address & gp
-    PBYTE pEnd64 = (PBYTE) (IMAGE_FIRST_SECTION(pHeader64) + VAL16(pHeader64->FileHeader.NumberOfSections));
-    pHeader64->OptionalHeader.AddressOfEntryPoint = VAL32((ULONG) (pEnd64 - pImage));
-    
-    // Should be PE32+ now
-    _ASSERTE(!Has32BitNTHeaders());
-    
-    return true;
-}
-
-bool PEImageLayout::ConvertILOnlyPE32ToPE64()
-{
-    CONTRACTL
-    {
-        NOTHROW;
-        GC_NOTRIGGER;
-        MODE_ANY;
-        PRECONDITION(IsILOnly()); // This should be called for IL-Only images
-        PRECONDITION(Has32BitNTHeaders()); 
-    }
-    CONTRACTL_END;
-    
-    bool fConvertedToPE64 = false;
-
-    // Only handle platform neutral IL assemblies
-    if (!IsPlatformNeutral())
-    {
-        return false;
-    }
-
-    PBYTE pageBase = (PBYTE)GetBase();
-    DWORD oldProtect;
-
-    if (!ClrVirtualProtect(pageBase, GetOsPageSize(), PAGE_READWRITE, &oldProtect))
-    {
-        // We are not going to be able to update header.
-        return false;
-    }
-        
-    fConvertedToPE64 = ConvertILOnlyPE32ToPE64Worker();
-    
-    DWORD ignore;
-    if (!ClrVirtualProtect(pageBase, GetOsPageSize(), oldProtect, &ignore))
-    {
-        // This is not so bad; just ignore it
-    }
-    
-    return fConvertedToPE64;
-}
-#endif // defined(_WIN64) && !defined(DACCESS_COMPILE)
index 79df992..557a2a5 100644 (file)
@@ -77,12 +77,6 @@ public:
     void EnumMemoryRegions(CLRDataEnumMemoryFlags flags);
 #endif
 
-#if defined(_WIN64) && !defined(DACCESS_COMPILE)
-    bool ConvertILOnlyPE32ToPE64();
-private:
-    bool ConvertILOnlyPE32ToPE64Worker();
-#endif // defined(_WIN64) && !defined(DACCESS_COMPILE)
-    
 private:
     Volatile<LONG> m_refCount;
 public:    
index ead312d..071c879 100644 (file)
@@ -1912,7 +1912,7 @@ FCIMPL2(void, StubHelpers::LogPinnedArgument, MethodDesc *target, Object *pinned
 }
 FCIMPLEND
 
-#ifdef _WIN64
+#ifdef _TARGET_64BIT_
 FCIMPL0(void*, StubHelpers::GetStubContextAddr)
 {
     FCALL_CONTRACT;
@@ -1921,7 +1921,7 @@ FCIMPL0(void*, StubHelpers::GetStubContextAddr)
     UNREACHABLE_MSG("This is a JIT intrinsic!");
 }
 FCIMPLEND
-#endif // _WIN64
+#endif // _TARGET_64BIT_
 
 #ifdef MDA_SUPPORTED    
 FCIMPL0(void, StubHelpers::TriggerGCForMDA)
index 70fb529..4c4bc8b 100644 (file)
@@ -115,9 +115,9 @@ public:
     static FCDECL2(void,            MarshalToManagedVaListInternal, va_list va, VARARGS* pArgIterator);
     static FCDECL0(void*,           GetStubContext);
     static FCDECL2(void,            LogPinnedArgument, MethodDesc *localDesc, Object *nativeArg);
-#ifdef _WIN64
+#ifdef _TARGET_64BIT_
     static FCDECL0(void*,           GetStubContextAddr);
-#endif // _WIN64
+#endif // _TARGET_64BIT_
     static FCDECL1(DWORD,           CalcVaListSize, VARARGS *varargs);
     static FCDECL3(void,            ValidateObject, Object *pObjUNSAFE, MethodDesc *pMD, Object *pThisUNSAFE);
     static FCDECL3(void,            ValidateByref, void *pByref, MethodDesc *pMD, Object *pThisUNSAFE);
index b2e779c..07e512c 100644 (file)
@@ -1243,7 +1243,7 @@ void ZapImage::CalculateZapBaseAddress()
 #if defined(_TARGET_X86_)
                 // We use 30000000 for an exe
                 baseAddress = 0x30000000;
-#elif defined(_WIN64)
+#elif defined(_TARGET_64BIT_)
                 // We use 04000000 for an exe
                 // which is remapped to 0x642`88000000 on x64
                 baseAddress = 0x04000000;
@@ -1254,7 +1254,7 @@ void ZapImage::CalculateZapBaseAddress()
 #if defined(_TARGET_X86_)
                 // We start a 31000000 for the main assembly with the manifest
                 baseAddress = 0x31000000;
-#elif defined(_WIN64)
+#elif defined(_TARGET_64BIT_)
                 // We start a 05000000 for the main assembly with the manifest
                 // which is remapped to 0x642`8A000000 on x64
                 baseAddress = 0x05000000;
@@ -1306,7 +1306,7 @@ void ZapImage::CalculateZapBaseAddress()
     // upper address range used on 64-bit platforms
     //
 #if USE_UPPER_ADDRESS
-#if defined(_WIN64)
+#if defined(_TARGET_64BIT_)
     if (baseAddress < 0x80000000)
     {
         if (baseAddress < 0x40000000)
@@ -1520,7 +1520,7 @@ void ZapImage::OutputTables()
     {
         USHORT dllCharacteristics = 0;
 
-#ifndef _WIN64
+#ifndef _TARGET_64BIT_
         dllCharacteristics |= IMAGE_DLLCHARACTERISTICS_NO_SEH;
 #endif
 
@@ -1550,7 +1550,7 @@ void ZapImage::OutputTables()
         SetSizeOfStackCommit(m_ModuleDecoder.GetSizeOfStackCommit());
     }
 
-#if defined(FEATURE_PAL) && !defined(BIT64)
+#if defined(FEATURE_PAL) && !defined(_TARGET_64BIT_)
     // To minimize wasted VA space on 32 bit systems align file to page bounaries (presumed to be 4K).
     SetFileAlignment(0x1000);
 #elif defined(_TARGET_ARM_) && defined(FEATURE_CORESYSTEM)
index 582c9a3..4687d75 100644 (file)
@@ -54,7 +54,7 @@ class ZapperStats;
 #define DEFAULT_CODE_BUFFER_INIT 0
 #endif
 
-#ifdef _WIN64
+#ifdef _TARGET_64BIT_
 // Optimize for speed
 #define DEFAULT_CODE_ALIGN  16
 #else
index 3d8033d..501972f 100644 (file)
@@ -26,7 +26,7 @@ typedef BYTE ZapRelocationType; // IMAGE_REL_XXX enum
 #define IMAGE_REL_INVALID           0xFF
 
 // IMAGE_REL_BASED_PTR is architecture specific reloc of virtual address
-#ifdef _WIN64
+#ifdef _TARGET_64BIT_
 #define IMAGE_REL_BASED_PTR IMAGE_REL_BASED_DIR64
 #else
 #define IMAGE_REL_BASED_PTR IMAGE_REL_BASED_HIGHLOW
index d91a565..4ec0c5a 100644 (file)
@@ -55,7 +55,7 @@ void ZapWriter::Initialize()
     m_FileAlignment = 0x200;
 }
 
-#if defined(FEATURE_PAL) && defined(BIT64)
+#if defined(FEATURE_PAL) && defined(_TARGET_64BIT_)
 #define SECTION_ALIGNMENT   m_FileAlignment
 #define PAL_MAX_PAGE_SIZE   0x10000
 #else
index e31af2a..05b5738 100644 (file)
@@ -312,11 +312,11 @@ class ZapWriter : public IStream
 
     BOOL Is64Bit()
     {
-#ifdef _WIN64
+#ifdef _TARGET_64BIT_
         return TRUE;
-#else
+#else // !_TARGET_64BIT_
         return FALSE;
-#endif
+#endif // !_TARGET_64BIT_
     }
 
     USHORT GetMachine()
index 49494d2..8c74e72 100644 (file)
         <ExcludeList Include="$(XunitTestBinBase)\Loader\classloader\TypeGeneratorTests\TypeGeneratorTest683\Generated683\*">
             <Issue>6707</Issue>
         </ExcludeList>
-        <ExcludeList Include="$(XunitTestBinBase)\tracing\eventsourcetrace\**">
-            <Issue>15919</Issue>
-        </ExcludeList>
     </ItemGroup>
 
     <!-- The following are x86 failures -->
     <!-- The following are tests that fail on Windows -->
 
     <ItemGroup Condition="'$(XunitTestBinBase)' != '' and '$(TargetsWindows)' == 'true'">
-        <ExcludeList Include="$(XunitTestBinBase)\tracing\eventsource**">
+        <ExcludeList Include="$(XunitTestBinBase)\tracing\eventsourcetrace\eventsourcetrace\eventsourcetrace.cmd">
             <Issue>15494</Issue>
         </ExcludeList>
     </ItemGroup>
index 7b93bec..93f7b6b 100644 (file)
     <Compile Include="AndNot.Single.cs" />
     <Compile Include="BlendVariable.Double.cs" />
     <Compile Include="BlendVariable.Single.cs" />
-    <Compile Include="Divide.Double.cs"/>
-    <Compile Include="Divide.Single.cs"/>
+    <Compile Include="Ceiling.Double.cs" />
+    <Compile Include="Ceiling.Single.cs" />
+    <Compile Include="Divide.Double.cs" />
+    <Compile Include="Divide.Single.cs" />
     <Compile Include="DuplicateEvenIndexed.Double.cs" />
     <Compile Include="DuplicateEvenIndexed.Single.cs" />
     <Compile Include="DuplicateOddIndexed.Single.cs" />
+    <Compile Include="Floor.Double.cs" />
+    <Compile Include="Floor.Single.cs" />
     <Compile Include="Max.Double.cs" />
     <Compile Include="Max.Single.cs" />
     <Compile Include="Min.Double.cs" />
     <Compile Include="Min.Single.cs" />
     <Compile Include="Multiply.Double.cs" />
     <Compile Include="Multiply.Single.cs" />
-    <Compile Include="Or.Double.cs"/>
-    <Compile Include="Or.Single.cs"/>
+    <Compile Include="Or.Double.cs" />
+    <Compile Include="Or.Single.cs" />
+    <Compile Include="RoundCurrentDirection.Double.cs" />
+    <Compile Include="RoundCurrentDirection.Single.cs" />
+    <Compile Include="RoundToNearestInteger.Double.cs" />
+    <Compile Include="RoundToNearestInteger.Single.cs" />
+    <Compile Include="RoundToNegativeInfinity.Double.cs" />
+    <Compile Include="RoundToNegativeInfinity.Single.cs" />
+    <Compile Include="RoundToPositiveInfinity.Double.cs" />
+    <Compile Include="RoundToPositiveInfinity.Single.cs" />
+    <Compile Include="RoundToZero.Double.cs" />
+    <Compile Include="RoundToZero.Single.cs" />
     <Compile Include="Subtract.Double.cs" />
     <Compile Include="Subtract.Single.cs" />
-    <Compile Include="Xor.Double.cs"/>
-    <Compile Include="Xor.Single.cs"/>
+    <Compile Include="TestC.Byte.cs" />
+    <Compile Include="TestC.Int16.cs" />
+    <Compile Include="TestC.Int32.cs" />
+    <Compile Include="TestC.Int64.cs" />
+    <Compile Include="TestC.SByte.cs" />
+    <Compile Include="TestC.UInt16.cs" />
+    <Compile Include="TestC.UInt32.cs" />
+    <Compile Include="TestC.UInt64.cs" />
+    <Compile Include="TestNotZAndNotC.Byte.cs" />
+    <Compile Include="TestNotZAndNotC.Int16.cs" />
+    <Compile Include="TestNotZAndNotC.Int32.cs" />
+    <Compile Include="TestNotZAndNotC.Int64.cs" />
+    <Compile Include="TestNotZAndNotC.SByte.cs" />
+    <Compile Include="TestNotZAndNotC.UInt16.cs" />
+    <Compile Include="TestNotZAndNotC.UInt32.cs" />
+    <Compile Include="TestNotZAndNotC.UInt64.cs" />
+    <Compile Include="TestZ.Byte.cs" />
+    <Compile Include="TestZ.Int16.cs" />
+    <Compile Include="TestZ.Int32.cs" />
+    <Compile Include="TestZ.Int64.cs" />
+    <Compile Include="TestZ.SByte.cs" />
+    <Compile Include="TestZ.UInt16.cs" />
+    <Compile Include="TestZ.UInt32.cs" />
+    <Compile Include="TestZ.UInt64.cs" />
+    <Compile Include="Xor.Double.cs" />
+    <Compile Include="Xor.Single.cs" />
     <Compile Include="Program.Avx.cs" />
+    <Compile Include="..\Shared\BooleanBinOpTest_DataTable.cs" />
+    <Compile Include="..\Shared\BooleanTwoCmpOpTest_DataTable.cs" />
     <Compile Include="..\Shared\Program.cs" />
     <Compile Include="..\Shared\SimpleBinOpTest_DataTable.cs" />     
     <Compile Include="..\Shared\SimpleTernOpTest_DataTable.cs" />    
index 672241d..03150f7 100644 (file)
     <Compile Include="AndNot.Single.cs" />
     <Compile Include="BlendVariable.Double.cs" />
     <Compile Include="BlendVariable.Single.cs" />
-    <Compile Include="Divide.Double.cs"/>
-    <Compile Include="Divide.Single.cs"/>
+    <Compile Include="Ceiling.Double.cs" />
+    <Compile Include="Ceiling.Single.cs" />
+    <Compile Include="Divide.Double.cs" />
+    <Compile Include="Divide.Single.cs" />
     <Compile Include="DuplicateEvenIndexed.Double.cs" />
     <Compile Include="DuplicateEvenIndexed.Single.cs" />
     <Compile Include="DuplicateOddIndexed.Single.cs" />
+    <Compile Include="Floor.Double.cs" />
+    <Compile Include="Floor.Single.cs" />
     <Compile Include="Max.Double.cs" />
     <Compile Include="Max.Single.cs" />
     <Compile Include="Min.Double.cs" />
     <Compile Include="Min.Single.cs" />
     <Compile Include="Multiply.Double.cs" />
     <Compile Include="Multiply.Single.cs" />
-    <Compile Include="Or.Double.cs"/>
-    <Compile Include="Or.Single.cs"/>
+    <Compile Include="Or.Double.cs" />
+    <Compile Include="Or.Single.cs" />
+    <Compile Include="RoundCurrentDirection.Double.cs" />
+    <Compile Include="RoundCurrentDirection.Single.cs" />
+    <Compile Include="RoundToNearestInteger.Double.cs" />
+    <Compile Include="RoundToNearestInteger.Single.cs" />
+    <Compile Include="RoundToNegativeInfinity.Double.cs" />
+    <Compile Include="RoundToNegativeInfinity.Single.cs" />
+    <Compile Include="RoundToPositiveInfinity.Double.cs" />
+    <Compile Include="RoundToPositiveInfinity.Single.cs" />
+    <Compile Include="RoundToZero.Double.cs" />
+    <Compile Include="RoundToZero.Single.cs" />
     <Compile Include="Subtract.Double.cs" />
     <Compile Include="Subtract.Single.cs" />
-    <Compile Include="Xor.Double.cs"/>
-    <Compile Include="Xor.Single.cs"/>
+    <Compile Include="TestC.Byte.cs" />
+    <Compile Include="TestC.Int16.cs" />
+    <Compile Include="TestC.Int32.cs" />
+    <Compile Include="TestC.Int64.cs" />
+    <Compile Include="TestC.SByte.cs" />
+    <Compile Include="TestC.UInt16.cs" />
+    <Compile Include="TestC.UInt32.cs" />
+    <Compile Include="TestC.UInt64.cs" />
+    <Compile Include="TestNotZAndNotC.Byte.cs" />
+    <Compile Include="TestNotZAndNotC.Int16.cs" />
+    <Compile Include="TestNotZAndNotC.Int32.cs" />
+    <Compile Include="TestNotZAndNotC.Int64.cs" />
+    <Compile Include="TestNotZAndNotC.SByte.cs" />
+    <Compile Include="TestNotZAndNotC.UInt16.cs" />
+    <Compile Include="TestNotZAndNotC.UInt32.cs" />
+    <Compile Include="TestNotZAndNotC.UInt64.cs" />
+    <Compile Include="TestZ.Byte.cs" />
+    <Compile Include="TestZ.Int16.cs" />
+    <Compile Include="TestZ.Int32.cs" />
+    <Compile Include="TestZ.Int64.cs" />
+    <Compile Include="TestZ.SByte.cs" />
+    <Compile Include="TestZ.UInt16.cs" />
+    <Compile Include="TestZ.UInt32.cs" />
+    <Compile Include="TestZ.UInt64.cs" />
+    <Compile Include="Xor.Double.cs" />
+    <Compile Include="Xor.Single.cs" />
     <Compile Include="Program.Avx.cs" />
+    <Compile Include="..\Shared\BooleanBinOpTest_DataTable.cs" />
+    <Compile Include="..\Shared\BooleanTwoCmpOpTest_DataTable.cs" />
     <Compile Include="..\Shared\Program.cs" />
-    <Compile Include="..\Shared\SimpleBinOpTest_DataTable.cs" />     
-    <Compile Include="..\Shared\SimpleTernOpTest_DataTable.cs" />    
+    <Compile Include="..\Shared\SimpleBinOpTest_DataTable.cs" />
+    <Compile Include="..\Shared\SimpleTernOpTest_DataTable.cs" />
     <Compile Include="..\Shared\SimpleUnOpTest_DataTable.cs" />
   </ItemGroup>
   <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Blend.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Blend.cs
new file mode 100644 (file)
index 0000000..3040a35
--- /dev/null
@@ -0,0 +1,247 @@
+// 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.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics.X86;
+using System.Runtime.Intrinsics;
+
+namespace IntelHardwareIntrinsicTest
+{
+    class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+
+            if (Avx.IsSupported)
+            {
+                using (TestTable<float> floatTable = new TestTable<float>(new float[8] { 1, -5, 100, 0, 1, -5, 100, 0 }, new float[8] { 22, -1, -50, 0, 22, -1, -50, 0 }, new float[8]))
+                {
+                    var vf1 = Unsafe.Read<Vector256<float>>(floatTable.inArray1Ptr);
+                    var vf2 = Unsafe.Read<Vector256<float>>(floatTable.inArray2Ptr);
+
+                    // SDDD SDDD
+                    var vf3 = Avx.Blend(vf1, vf2, 1);
+                    Unsafe.Write(floatTable.outArrayPtr, vf3);
+
+                    if (!floatTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == x[1]) &&
+                                                             (z[2] == x[2]) && (z[3] == x[3]) &&
+                                                             (z[4] == x[4]) && (z[5] == x[5]) &&
+                                                             (z[6] == x[6]) && (z[7] == x[7])))
+                    {
+                        Console.WriteLine("0Avx Blend failed on float:");
+                        foreach (var item in floatTable.outArray)
+                        {
+                            Console.Write(item + ", ");
+                        }
+                        Console.WriteLine();
+                        testResult = Fail;
+                    }
+
+                    // DSDD DDDD
+                    vf3 = Avx.Blend(vf1, vf2, 2);
+                    Unsafe.Write(floatTable.outArrayPtr, vf3);
+
+                    if (!floatTable.CheckResult((x, y, z) => (z[0] == x[0]) && (z[1] == y[1]) &&
+                                                             (z[2] == x[2]) && (z[3] == x[3]) &&
+                                                             (z[4] == x[4]) && (z[5] == x[5]) &&
+                                                             (z[6] == x[6]) && (z[7] == x[7])))
+                    {
+                        Console.WriteLine("Avx Blend failed on float:");
+                        foreach (var item in floatTable.outArray)
+                        {
+                            Console.Write(item + ", ");
+                        }
+                        Console.WriteLine();
+                        testResult = Fail;
+                    }
+
+                    // DDSD DDDD
+                    vf3 = Avx.Blend(vf1, vf2, 4);
+                    Unsafe.Write(floatTable.outArrayPtr, vf3);
+
+                    if (!floatTable.CheckResult((x, y, z) => (z[0] == x[0]) && (z[1] == x[1]) &&
+                                                             (z[2] == y[2]) && (z[3] == x[3]) &&
+                                                             (z[4] == x[4]) && (z[5] == x[5]) &&
+                                                             (z[6] == x[6]) && (z[7] == x[7])))
+                    {
+                        Console.WriteLine("Avx Blend failed on float:");
+                        foreach (var item in floatTable.outArray)
+                        {
+                            Console.Write(item + ", ");
+                        }
+                        Console.WriteLine();
+                        testResult = Fail;
+                    }
+
+                    // SDSD SDSD
+                    vf3 = Avx.Blend(vf1, vf2, 85);
+                    Unsafe.Write(floatTable.outArrayPtr, vf3);
+
+                    if (!floatTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == x[1]) &&
+                                                             (z[2] == y[2]) && (z[3] == x[3]) &&
+                                                             (z[4] == y[4]) && (z[5] == x[5]) &&
+                                                             (z[6] == y[6]) && (z[7] == x[7])))
+                    {
+                        Console.WriteLine("Avx Blend failed on float:");
+                        foreach (var item in floatTable.outArray)
+                        {
+                            Console.Write(item + ", ");
+                        }
+                        Console.WriteLine();
+                        testResult = Fail;
+                    }
+                    
+                    // SDDD DDDD
+                    vf3 = (Vector256<float>)typeof(Avx).GetMethod(nameof(Avx.Blend), new Type[] { vf1.GetType(), vf2.GetType(), typeof(byte) }).Invoke(null, new object[] { vf1, vf2, (byte)(1) });
+                    Unsafe.Write(floatTable.outArrayPtr, vf3);
+
+                    if (!floatTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == x[1]) &&
+                                                             (z[2] == x[2]) && (z[3] == x[3]) &&
+                                                             (z[4] == x[4]) && (z[5] == x[5]) &&
+                                                             (z[6] == x[6]) && (z[7] == x[7])))
+                    {
+                        Console.WriteLine("Avx Blend failed on float:");
+                        foreach (var item in floatTable.outArray)
+                        {
+                            Console.Write(item + ", ");
+                        }
+                        Console.WriteLine();
+                        testResult = Fail;
+                    }
+                }
+
+                using (TestTable<double> doubleTable = new TestTable<double>(new double[4] { 1, -5, 100, 0 }, new double[4] { 22, -1, -50, 0 }, new double[4]))
+                {
+                    var vf1 = Unsafe.Read<Vector256<double>>(doubleTable.inArray1Ptr);
+                    var vf2 = Unsafe.Read<Vector256<double>>(doubleTable.inArray2Ptr);
+
+                    // DD DD
+                    var vf3 = Avx.Blend(vf1, vf2, 0);
+                    Unsafe.Write(doubleTable.outArrayPtr, vf3);
+
+                    if (!doubleTable.CheckResult((x, y, z) => (z[0] == x[0]) && (z[1] == x[1]) &&
+                                                              (z[2] == x[2]) && (z[3] == x[3])))
+                    {
+                        Console.WriteLine("Avx Blend failed on double:");
+                        foreach (var item in doubleTable.outArray)
+                        {
+                            Console.Write(item + ", ");
+                        }
+                        Console.WriteLine();
+                        testResult = Fail;
+                    }
+
+                    // SD DD
+                    vf3 = Avx.Blend(vf1, vf2, 1);
+                    Unsafe.Write(doubleTable.outArrayPtr, vf3);
+
+                    if (!doubleTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == x[1]) &&
+                                                              (z[2] == x[2]) && (z[3] == x[3])))
+                    {
+                        Console.WriteLine("Avx Blend failed on double:");
+                        foreach (var item in doubleTable.outArray)
+                        {
+                            Console.Write(item + ", ");
+                        }
+                        Console.WriteLine();
+                        testResult = Fail;
+                    }
+
+                    // DS DD
+                    vf3 = Avx.Blend(vf1, vf2, 2);
+                    Unsafe.Write(doubleTable.outArrayPtr, vf3);
+
+                    if (!doubleTable.CheckResult((x, y, z) => (z[0] == x[0]) && (z[1] == y[1]) &&
+                                                              (z[2] == x[2]) && (z[3] == x[3])))
+                    {
+                        Console.WriteLine("Avx Blend failed on double:");
+                        foreach (var item in doubleTable.outArray)
+                        {
+                            Console.Write(item + ", ");
+                        }
+                        Console.WriteLine();
+                        testResult = Fail;
+                    }
+
+                    // SS DD
+                    vf3 = Avx.Blend(vf1, vf2, 51);
+                    Unsafe.Write(doubleTable.outArrayPtr, vf3);
+
+                    if (!doubleTable.CheckResult((x, y, z) => (z[0] == y[0]) && (z[1] == y[1]) &&
+                                                              (z[2] == x[2]) && (z[3] == x[3])))
+                    {
+                        Console.WriteLine("Avx Blend failed on double:");
+                        foreach (var item in doubleTable.outArray)
+                        {
+                            Console.Write(item + ", ");
+                        }
+                        Console.WriteLine();
+                        testResult = Fail;
+                    }
+
+                    // DD DD
+                    vf3 = (Vector256<double>)typeof(Avx).GetMethod(nameof(Avx.Blend), new Type[] { vf1.GetType(), vf2.GetType(), typeof(byte) }).Invoke(null, new object[] { vf1, vf2, (byte)(0) });
+                    Unsafe.Write(doubleTable.outArrayPtr, vf3);
+
+                    if (!doubleTable.CheckResult((x, y, z) => (z[0] == x[0]) && (z[1] == x[1]) &&
+                                                              (z[2] == x[2]) && (z[3] == x[3])))
+                    {
+                        Console.WriteLine("Avx Blend failed on double:");
+                        foreach (var item in doubleTable.outArray)
+                        {
+                            Console.Write(item + ", ");
+                        }
+                        Console.WriteLine();
+                        testResult = Fail;
+                    }
+                }
+            }
+
+            return testResult;
+        }
+
+        public unsafe struct TestTable<T> : IDisposable where T : struct
+        {
+            public T[] inArray1;
+            public T[] inArray2;
+            public T[] outArray;
+
+            public void* inArray1Ptr => inHandle1.AddrOfPinnedObject().ToPointer();
+            public void* inArray2Ptr => inHandle2.AddrOfPinnedObject().ToPointer();
+            public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer();
+
+            GCHandle inHandle1;
+            GCHandle inHandle2;
+            GCHandle outHandle;
+            public TestTable(T[] a, T[] b, T[] c)
+            {
+                this.inArray1 = a;
+                this.inArray2 = b;
+                this.outArray = c;
+
+                inHandle1 = GCHandle.Alloc(inArray1, GCHandleType.Pinned);
+                inHandle2 = GCHandle.Alloc(inArray2, GCHandleType.Pinned);
+                outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned);
+            }
+            public bool CheckResult(Func<T[], T[], T[], bool> check)
+            {
+                return check(inArray1, inArray2, outArray);
+            }
+
+            public void Dispose()
+            {
+                inHandle1.Free();
+                inHandle2.Free();
+                outHandle.Free();
+            }
+        }
+    }
+}
@@ -5,28 +5,30 @@
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
     <SchemaVersion>2.0</SchemaVersion>
-    <ProjectGuid>{8E3244CB-407F-4142-BAAB-E7A55901A5FA}</ProjectGuid>
+    <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>
-    <CLRTestKind>BuildAndRun</CLRTestKind>
-    <DefineConstants>$(DefineConstants);STATIC</DefineConstants>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
-    <CLRTestPriority>1</CLRTestPriority>
   </PropertyGroup>
   <!-- Default configurations to help VS understand the configurations -->
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
-  </PropertyGroup>
+  <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="EventSourceSmoke.cs" />
-    <ProjectReference Include="../common/common.csproj" />
+    <Compile Include="Blend.cs" />
   </ItemGroup>
   <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
 </Project>
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Blend_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Blend_ro.csproj
new file mode 100644 (file)
index 0000000..884ea63
--- /dev/null
@@ -0,0 +1,34 @@
+<?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>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Blend.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project>
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Ceiling.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Ceiling.Double.cs
new file mode 100644 (file)
index 0000000..202f4e2
--- /dev/null
@@ -0,0 +1,306 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void CeilingDouble()
+        {
+            var test = new SimpleUnaryOpTest__CeilingDouble();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class SimpleUnaryOpTest__CeilingDouble
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Double);
+        private const int RetElementCount = VectorSize / sizeof(Double);
+
+        private static Double[] _data = new Double[Op1ElementCount];
+
+        private static Vector256<Double> _clsVar;
+
+        private Vector256<Double> _fld;
+
+        private SimpleUnaryOpTest__DataTable<Double, Double> _dataTable;
+
+        static SimpleUnaryOpTest__CeilingDouble()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar), ref Unsafe.As<Double, byte>(ref _data[0]), VectorSize);
+        }
+
+        public SimpleUnaryOpTest__CeilingDouble()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld), ref Unsafe.As<Double, byte>(ref _data[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+            _dataTable = new SimpleUnaryOpTest__DataTable<Double, Double>(_data, new Double[RetElementCount], VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.Ceiling(
+                Unsafe.Read<Vector256<Double>>(_dataTable.inArrayPtr)
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.Ceiling(
+                Avx.LoadVector256((Double*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.Ceiling(
+                Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.Ceiling), new Type[] { typeof(Vector256<Double>) })
+                                     .Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Double>>(_dataTable.inArrayPtr)
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.Ceiling), new Type[] { typeof(Vector256<Double>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadVector256((Double*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.Ceiling), new Type[] { typeof(Vector256<Double>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.Ceiling(
+                _clsVar
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_clsVar, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var firstOp = Unsafe.Read<Vector256<Double>>(_dataTable.inArrayPtr);
+            var result = Avx.Ceiling(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var firstOp = Avx.LoadVector256((Double*)(_dataTable.inArrayPtr));
+            var result = Avx.Ceiling(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var firstOp = Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr));
+            var result = Avx.Ceiling(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new SimpleUnaryOpTest__CeilingDouble();
+            var result = Avx.Ceiling(test._fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(test._fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.Ceiling(_fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Double> firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Double[] inArray = new Double[Op1ElementCount];
+            Double[] outArray = new Double[RetElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray[0]), firstOp);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Double[] inArray = new Double[Op1ElementCount];
+            Double[] outArray = new Double[RetElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(Double[] firstOp, Double[] result, [CallerMemberName] string method = "")
+        {
+            if (BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(firstOp[0])))
+            {
+                Succeeded = false;
+            }
+            else
+            {
+                for (var i = 1; i < RetElementCount; i++)
+                {
+                    if (BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(firstOp[i])))
+                    {
+                        Succeeded = false;
+                        break;
+                    }
+                }
+            }
+
+            if (!Succeeded)
+            {
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Ceiling)}<Double>(Vector256<Double>): {method} failed:");
+                Console.WriteLine($"  firstOp: ({string.Join(", ", firstOp)})");
+                Console.WriteLine($"   result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Ceiling.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Ceiling.Single.cs
new file mode 100644 (file)
index 0000000..c2df15d
--- /dev/null
@@ -0,0 +1,306 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void CeilingSingle()
+        {
+            var test = new SimpleUnaryOpTest__CeilingSingle();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class SimpleUnaryOpTest__CeilingSingle
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Single);
+        private const int RetElementCount = VectorSize / sizeof(Single);
+
+        private static Single[] _data = new Single[Op1ElementCount];
+
+        private static Vector256<Single> _clsVar;
+
+        private Vector256<Single> _fld;
+
+        private SimpleUnaryOpTest__DataTable<Single, Single> _dataTable;
+
+        static SimpleUnaryOpTest__CeilingSingle()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar), ref Unsafe.As<Single, byte>(ref _data[0]), VectorSize);
+        }
+
+        public SimpleUnaryOpTest__CeilingSingle()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld), ref Unsafe.As<Single, byte>(ref _data[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+            _dataTable = new SimpleUnaryOpTest__DataTable<Single, Single>(_data, new Single[RetElementCount], VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.Ceiling(
+                Unsafe.Read<Vector256<Single>>(_dataTable.inArrayPtr)
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.Ceiling(
+                Avx.LoadVector256((Single*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.Ceiling(
+                Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.Ceiling), new Type[] { typeof(Vector256<Single>) })
+                                     .Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Single>>(_dataTable.inArrayPtr)
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Single>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.Ceiling), new Type[] { typeof(Vector256<Single>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadVector256((Single*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Single>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.Ceiling), new Type[] { typeof(Vector256<Single>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Single>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.Ceiling(
+                _clsVar
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_clsVar, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var firstOp = Unsafe.Read<Vector256<Single>>(_dataTable.inArrayPtr);
+            var result = Avx.Ceiling(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var firstOp = Avx.LoadVector256((Single*)(_dataTable.inArrayPtr));
+            var result = Avx.Ceiling(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var firstOp = Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr));
+            var result = Avx.Ceiling(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new SimpleUnaryOpTest__CeilingSingle();
+            var result = Avx.Ceiling(test._fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(test._fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.Ceiling(_fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Single> firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Single[] inArray = new Single[Op1ElementCount];
+            Single[] outArray = new Single[RetElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray[0]), firstOp);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Single[] inArray = new Single[Op1ElementCount];
+            Single[] outArray = new Single[RetElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "")
+        {
+            if (BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(firstOp[0])))
+            {
+                Succeeded = false;
+            }
+            else
+            {
+                for (var i = 1; i < RetElementCount; i++)
+                {
+                    if (BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(firstOp[i])))
+                    {
+                        Succeeded = false;
+                        break;
+                    }
+                }
+            }
+
+            if (!Succeeded)
+            {
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Ceiling)}<Single>(Vector256<Single>): {method} failed:");
+                Console.WriteLine($"  firstOp: ({string.Join(", ", firstOp)})");
+                Console.WriteLine($"   result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/DotProduct.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/DotProduct.cs
new file mode 100644 (file)
index 0000000..eadcea3
--- /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.Linq;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics.X86;
+using System.Runtime.Intrinsics;
+
+namespace IntelHardwareIntrinsicTest
+{
+    class Program
+    {
+        const int Pass = 100;
+        const int Fail = 0;
+
+        static unsafe int Main(string[] args)
+        {
+            int testResult = Pass;
+
+            if (Avx.IsSupported)
+            {
+                using (TestTable<float> floatTable = new TestTable<float>(new float[8] { 1, -5, 100, 0, 1, -5, 100, 0 }, new float[8] { 22, -1, -50, 0, 22, -1, -50, 0 }, new float[8]))
+                {
+                    var vf1 = Unsafe.Read<Vector256<float>>(floatTable.inArray1Ptr);
+                    var vf2 = Unsafe.Read<Vector256<float>>(floatTable.inArray2Ptr);
+
+                    var vf3 = Avx.DotProduct(vf1, vf2, 255);
+                    Unsafe.Write(floatTable.outArrayPtr, vf3);
+
+                    if (!floatTable.CheckResult((x, y, z) => z.All(result => result == (x[0] * y[0]) + (x[1] * y[1]) +
+                                                                                       (x[2] * y[2]) + (x[3] * y[3]))))
+                    {
+                        Console.WriteLine("Avx DotProduct failed on float:");
+                        foreach (var item in floatTable.outArray)
+                        {
+                            Console.Write(item + ", ");
+                        }
+                        Console.WriteLine();
+                        testResult = Fail;
+                    }
+
+                    vf3 = Avx.DotProduct(vf1, vf2, 127);
+                    Unsafe.Write(floatTable.outArrayPtr, vf3);
+
+                    if (!floatTable.CheckResult((x, y, z) => z.All(result => result == (x[0] * y[0]) + (x[1] * y[1]) +
+                                                                                       (x[2] * y[2]))))
+                    {
+                        Console.WriteLine("Avx DotProduct failed on float:");
+                        foreach (var item in floatTable.outArray)
+                        {
+                            Console.Write(item + ", ");
+                        }
+                        Console.WriteLine();
+                        testResult = Fail;
+                    }
+
+                    vf3 = Avx.DotProduct(vf1, vf2, 63);
+                    Unsafe.Write(floatTable.outArrayPtr, vf3);
+
+                    if (!floatTable.CheckResult((x, y, z) => z.All(result => result == ((x[0] * y[0]) + (x[1] * y[1])))))
+                    {
+                        Console.WriteLine("3 Avx DotProduct failed on float:");
+                        foreach (var item in floatTable.outArray)
+                        {
+                            Console.Write(item + ", ");
+                        }
+                        Console.WriteLine();
+                        testResult = Fail;
+                    }
+
+                    vf3 = Avx.DotProduct(vf1, vf2, 85);
+                    Unsafe.Write(floatTable.outArrayPtr, vf3);
+
+                    if (!floatTable.CheckResult((x, y, z) => z[0] == ((x[0] * y[0]) + (x[2] * y[2])) &&
+                                                             z[2] == ((x[0] * y[0]) + (x[2] * y[2])) &&
+                                                             z[4] == ((x[4] * y[4]) + (x[6] * y[6])) &&
+                                                             z[6] == ((x[4] * y[4]) + (x[6] * y[6])) &&
+                                                             z[1] == 0 && z[3] == 0 &&
+                                                             z[5] == 0 && z[7] == 0))
+                    {
+                        Console.WriteLine("Avx DotProduct failed on float:");
+                        foreach (var item in floatTable.outArray)
+                        {
+                            Console.Write(item + ", ");
+                        }
+                        Console.WriteLine();
+                        testResult = Fail;
+                    }
+
+                    vf3 = (Vector256<float>)typeof(Avx).GetMethod(nameof(Avx.DotProduct), new Type[] { vf1.GetType(), vf2.GetType(), typeof(byte) }).Invoke(null, new object[] { vf1, vf2, (byte)(255) });
+                    Unsafe.Write(floatTable.outArrayPtr, vf3);
+
+                    if (!floatTable.CheckResult((x, y, z) => z.All(result => result == (x[0] * y[0]) + (x[1] * y[1]) +
+                                                                                       (x[2] * y[2]) + (x[3] * y[3]))))
+                    {
+                        Console.WriteLine("Avx DotProduct failed on float:");
+                        foreach (var item in floatTable.outArray)
+                        {
+                            Console.Write(item + ", ");
+                        }
+                        Console.WriteLine();
+                        testResult = Fail;
+                    }
+                }
+            }
+
+            return testResult;
+        }
+
+        public unsafe struct TestTable<T> : IDisposable where T : struct
+        {
+            public T[] inArray1;
+            public T[] inArray2;
+            public T[] outArray;
+
+            public void* inArray1Ptr => inHandle1.AddrOfPinnedObject().ToPointer();
+            public void* inArray2Ptr => inHandle2.AddrOfPinnedObject().ToPointer();
+            public void* outArrayPtr => outHandle.AddrOfPinnedObject().ToPointer();
+
+            GCHandle inHandle1;
+            GCHandle inHandle2;
+            GCHandle outHandle;
+            public TestTable(T[] a, T[] b, T[] c)
+            {
+                this.inArray1 = a;
+                this.inArray2 = b;
+                this.outArray = c;
+
+                inHandle1 = GCHandle.Alloc(inArray1, GCHandleType.Pinned);
+                inHandle2 = GCHandle.Alloc(inArray2, GCHandleType.Pinned);
+                outHandle = GCHandle.Alloc(outArray, GCHandleType.Pinned);
+            }
+            public bool CheckResult(Func<T[], T[], T[], bool> check)
+            {
+                return check(inArray1, inArray2, outArray);
+            }
+
+            public void Dispose()
+            {
+                inHandle1.Free();
+                inHandle2.Free();
+                outHandle.Free();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/DotProduct_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx/DotProduct_r.csproj
new file mode 100644 (file)
index 0000000..59f4aa5
--- /dev/null
@@ -0,0 +1,34 @@
+<?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="DotProduct.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project>
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/DotProduct_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx/DotProduct_ro.csproj
new file mode 100644 (file)
index 0000000..9b8e5c4
--- /dev/null
@@ -0,0 +1,34 @@
+<?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>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="DotProduct.cs" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project>
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Floor.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Floor.Double.cs
new file mode 100644 (file)
index 0000000..2698d03
--- /dev/null
@@ -0,0 +1,306 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void FloorDouble()
+        {
+            var test = new SimpleUnaryOpTest__FloorDouble();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class SimpleUnaryOpTest__FloorDouble
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Double);
+        private const int RetElementCount = VectorSize / sizeof(Double);
+
+        private static Double[] _data = new Double[Op1ElementCount];
+
+        private static Vector256<Double> _clsVar;
+
+        private Vector256<Double> _fld;
+
+        private SimpleUnaryOpTest__DataTable<Double, Double> _dataTable;
+
+        static SimpleUnaryOpTest__FloorDouble()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar), ref Unsafe.As<Double, byte>(ref _data[0]), VectorSize);
+        }
+
+        public SimpleUnaryOpTest__FloorDouble()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld), ref Unsafe.As<Double, byte>(ref _data[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+            _dataTable = new SimpleUnaryOpTest__DataTable<Double, Double>(_data, new Double[RetElementCount], VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.Floor(
+                Unsafe.Read<Vector256<Double>>(_dataTable.inArrayPtr)
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.Floor(
+                Avx.LoadVector256((Double*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.Floor(
+                Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.Floor), new Type[] { typeof(Vector256<Double>) })
+                                     .Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Double>>(_dataTable.inArrayPtr)
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.Floor), new Type[] { typeof(Vector256<Double>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadVector256((Double*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.Floor), new Type[] { typeof(Vector256<Double>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.Floor(
+                _clsVar
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_clsVar, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var firstOp = Unsafe.Read<Vector256<Double>>(_dataTable.inArrayPtr);
+            var result = Avx.Floor(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var firstOp = Avx.LoadVector256((Double*)(_dataTable.inArrayPtr));
+            var result = Avx.Floor(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var firstOp = Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr));
+            var result = Avx.Floor(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new SimpleUnaryOpTest__FloorDouble();
+            var result = Avx.Floor(test._fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(test._fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.Floor(_fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Double> firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Double[] inArray = new Double[Op1ElementCount];
+            Double[] outArray = new Double[RetElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray[0]), firstOp);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Double[] inArray = new Double[Op1ElementCount];
+            Double[] outArray = new Double[RetElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(Double[] firstOp, Double[] result, [CallerMemberName] string method = "")
+        {
+            if (BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[0])))
+            {
+                Succeeded = false;
+            }
+            else
+            {
+                for (var i = 1; i < RetElementCount; i++)
+                {
+                    if (BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[i])))
+                    {
+                        Succeeded = false;
+                        break;
+                    }
+                }
+            }
+
+            if (!Succeeded)
+            {
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Floor)}<Double>(Vector256<Double>): {method} failed:");
+                Console.WriteLine($"  firstOp: ({string.Join(", ", firstOp)})");
+                Console.WriteLine($"   result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Floor.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Floor.Single.cs
new file mode 100644 (file)
index 0000000..3342423
--- /dev/null
@@ -0,0 +1,306 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void FloorSingle()
+        {
+            var test = new SimpleUnaryOpTest__FloorSingle();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class SimpleUnaryOpTest__FloorSingle
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Single);
+        private const int RetElementCount = VectorSize / sizeof(Single);
+
+        private static Single[] _data = new Single[Op1ElementCount];
+
+        private static Vector256<Single> _clsVar;
+
+        private Vector256<Single> _fld;
+
+        private SimpleUnaryOpTest__DataTable<Single, Single> _dataTable;
+
+        static SimpleUnaryOpTest__FloorSingle()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar), ref Unsafe.As<Single, byte>(ref _data[0]), VectorSize);
+        }
+
+        public SimpleUnaryOpTest__FloorSingle()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld), ref Unsafe.As<Single, byte>(ref _data[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+            _dataTable = new SimpleUnaryOpTest__DataTable<Single, Single>(_data, new Single[RetElementCount], VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.Floor(
+                Unsafe.Read<Vector256<Single>>(_dataTable.inArrayPtr)
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.Floor(
+                Avx.LoadVector256((Single*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.Floor(
+                Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.Floor), new Type[] { typeof(Vector256<Single>) })
+                                     .Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Single>>(_dataTable.inArrayPtr)
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Single>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.Floor), new Type[] { typeof(Vector256<Single>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadVector256((Single*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Single>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.Floor), new Type[] { typeof(Vector256<Single>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Single>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.Floor(
+                _clsVar
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_clsVar, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var firstOp = Unsafe.Read<Vector256<Single>>(_dataTable.inArrayPtr);
+            var result = Avx.Floor(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var firstOp = Avx.LoadVector256((Single*)(_dataTable.inArrayPtr));
+            var result = Avx.Floor(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var firstOp = Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr));
+            var result = Avx.Floor(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new SimpleUnaryOpTest__FloorSingle();
+            var result = Avx.Floor(test._fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(test._fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.Floor(_fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Single> firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Single[] inArray = new Single[Op1ElementCount];
+            Single[] outArray = new Single[RetElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray[0]), firstOp);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Single[] inArray = new Single[Op1ElementCount];
+            Single[] outArray = new Single[RetElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "")
+        {
+            if (BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[0])))
+            {
+                Succeeded = false;
+            }
+            else
+            {
+                for (var i = 1; i < RetElementCount; i++)
+                {
+                    if (BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[i])))
+                    {
+                        Succeeded = false;
+                        break;
+                    }
+                }
+            }
+
+            if (!Succeeded)
+            {
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Floor)}<Single>(Vector256<Single>): {method} failed:");
+                Console.WriteLine($"  firstOp: ({string.Join(", ", firstOp)})");
+                Console.WriteLine($"   result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
index bfe07b8..dd5a44f 100644 (file)
@@ -22,11 +22,15 @@ namespace JIT.HardwareIntrinsics.X86
                 ["AndNot.Single"] = AndNotSingle,
                 ["BlendVariable.Double"] = BlendVariableDouble,
                 ["BlendVariable.Single"] = BlendVariableSingle,
+                ["Ceiling.Double"] = CeilingDouble,
+                ["Ceiling.Single"] = CeilingSingle,
                 ["Divide.Double"] = DivideDouble,
                 ["Divide.Single"] = DivideSingle,
                 ["DuplicateEvenIndexed.Double"] = DuplicateEvenIndexedDouble,
                 ["DuplicateEvenIndexed.Single"] = DuplicateEvenIndexedSingle,
                 ["DuplicateOddIndexed.Single"] = DuplicateOddIndexedSingle,
+                ["Floor.Double"] = FloorDouble,
+                ["Floor.Single"] = FloorSingle,
                 ["Max.Double"] = MaxDouble,
                 ["Max.Single"] = MaxSingle,
                 ["Min.Double"] = MinDouble,
@@ -35,8 +39,42 @@ namespace JIT.HardwareIntrinsics.X86
                 ["Multiply.Single"] = MultiplySingle,
                 ["Or.Double"] = OrDouble,
                 ["Or.Single"] = OrSingle,
+                ["RoundCurrentDirection.Double"] = RoundCurrentDirectionDouble,
+                ["RoundCurrentDirection.Single"] = RoundCurrentDirectionSingle,
+                ["RoundToNearestInteger.Double"] = RoundToNearestIntegerDouble,
+                ["RoundToNearestInteger.Single"] = RoundToNearestIntegerSingle,
+                ["RoundToNegativeInfinity.Double"] = RoundToNegativeInfinityDouble,
+                ["RoundToNegativeInfinity.Single"] = RoundToNegativeInfinitySingle,
+                ["RoundToPositiveInfinity.Double"] = RoundToPositiveInfinityDouble,
+                ["RoundToPositiveInfinity.Single"] = RoundToPositiveInfinitySingle,
+                ["RoundToZero.Double"] = RoundToZeroDouble,
+                ["RoundToZero.Single"] = RoundToZeroSingle,
                 ["Subtract.Double"] = SubtractDouble,
                 ["Subtract.Single"] = SubtractSingle,
+                ["TestC.Byte"] = TestCByte,
+                ["TestC.Int16"] = TestCInt16,
+                ["TestC.Int32"] = TestCInt32,
+                ["TestC.Int64"] = TestCInt64,
+                ["TestC.SByte"] = TestCSByte,
+                ["TestC.UInt16"] = TestCUInt16,
+                ["TestC.UInt32"] = TestCUInt32,
+                ["TestC.UInt64"] = TestCUInt64,
+                ["TestNotZAndNotC.Byte"] = TestNotZAndNotCByte,
+                ["TestNotZAndNotC.Int16"] = TestNotZAndNotCInt16,
+                ["TestNotZAndNotC.Int32"] = TestNotZAndNotCInt32,
+                ["TestNotZAndNotC.Int64"] = TestNotZAndNotCInt64,
+                ["TestNotZAndNotC.SByte"] = TestNotZAndNotCSByte,
+                ["TestNotZAndNotC.UInt16"] = TestNotZAndNotCUInt16,
+                ["TestNotZAndNotC.UInt32"] = TestNotZAndNotCUInt32,
+                ["TestNotZAndNotC.UInt64"] = TestNotZAndNotCUInt64,
+                ["TestZ.Byte"] = TestZByte,
+                ["TestZ.Int16"] = TestZInt16,
+                ["TestZ.Int32"] = TestZInt32,
+                ["TestZ.Int64"] = TestZInt64,
+                ["TestZ.SByte"] = TestZSByte,
+                ["TestZ.UInt16"] = TestZUInt16,
+                ["TestZ.UInt32"] = TestZUInt32,
+                ["TestZ.UInt64"] = TestZUInt64,
                 ["Xor.Double"] = XorDouble,
                 ["Xor.Single"] = XorSingle,
             };
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundCurrentDirection.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundCurrentDirection.Double.cs
new file mode 100644 (file)
index 0000000..0501d3a
--- /dev/null
@@ -0,0 +1,306 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void RoundCurrentDirectionDouble()
+        {
+            var test = new SimpleUnaryOpTest__RoundCurrentDirectionDouble();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class SimpleUnaryOpTest__RoundCurrentDirectionDouble
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Double);
+        private const int RetElementCount = VectorSize / sizeof(Double);
+
+        private static Double[] _data = new Double[Op1ElementCount];
+
+        private static Vector256<Double> _clsVar;
+
+        private Vector256<Double> _fld;
+
+        private SimpleUnaryOpTest__DataTable<Double, Double> _dataTable;
+
+        static SimpleUnaryOpTest__RoundCurrentDirectionDouble()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar), ref Unsafe.As<Double, byte>(ref _data[0]), VectorSize);
+        }
+
+        public SimpleUnaryOpTest__RoundCurrentDirectionDouble()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld), ref Unsafe.As<Double, byte>(ref _data[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+            _dataTable = new SimpleUnaryOpTest__DataTable<Double, Double>(_data, new Double[RetElementCount], VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.RoundCurrentDirection(
+                Unsafe.Read<Vector256<Double>>(_dataTable.inArrayPtr)
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.RoundCurrentDirection(
+                Avx.LoadVector256((Double*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.RoundCurrentDirection(
+                Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundCurrentDirection), new Type[] { typeof(Vector256<Double>) })
+                                     .Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Double>>(_dataTable.inArrayPtr)
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundCurrentDirection), new Type[] { typeof(Vector256<Double>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadVector256((Double*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundCurrentDirection), new Type[] { typeof(Vector256<Double>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.RoundCurrentDirection(
+                _clsVar
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_clsVar, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var firstOp = Unsafe.Read<Vector256<Double>>(_dataTable.inArrayPtr);
+            var result = Avx.RoundCurrentDirection(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var firstOp = Avx.LoadVector256((Double*)(_dataTable.inArrayPtr));
+            var result = Avx.RoundCurrentDirection(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var firstOp = Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr));
+            var result = Avx.RoundCurrentDirection(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new SimpleUnaryOpTest__RoundCurrentDirectionDouble();
+            var result = Avx.RoundCurrentDirection(test._fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(test._fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.RoundCurrentDirection(_fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Double> firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Double[] inArray = new Double[Op1ElementCount];
+            Double[] outArray = new Double[RetElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray[0]), firstOp);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Double[] inArray = new Double[Op1ElementCount];
+            Double[] outArray = new Double[RetElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(Double[] firstOp, Double[] result, [CallerMemberName] string method = "")
+        {
+            if (BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Round(firstOp[0])))
+            {
+                Succeeded = false;
+            }
+            else
+            {
+                for (var i = 1; i < RetElementCount; i++)
+                {
+                    if (BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Round(firstOp[i])))
+                    {
+                        Succeeded = false;
+                        break;
+                    }
+                }
+            }
+
+            if (!Succeeded)
+            {
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.RoundCurrentDirection)}<Double>(Vector256<Double>): {method} failed:");
+                Console.WriteLine($"  firstOp: ({string.Join(", ", firstOp)})");
+                Console.WriteLine($"   result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundCurrentDirection.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundCurrentDirection.Single.cs
new file mode 100644 (file)
index 0000000..b444c94
--- /dev/null
@@ -0,0 +1,306 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void RoundCurrentDirectionSingle()
+        {
+            var test = new SimpleUnaryOpTest__RoundCurrentDirectionSingle();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class SimpleUnaryOpTest__RoundCurrentDirectionSingle
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Single);
+        private const int RetElementCount = VectorSize / sizeof(Single);
+
+        private static Single[] _data = new Single[Op1ElementCount];
+
+        private static Vector256<Single> _clsVar;
+
+        private Vector256<Single> _fld;
+
+        private SimpleUnaryOpTest__DataTable<Single, Single> _dataTable;
+
+        static SimpleUnaryOpTest__RoundCurrentDirectionSingle()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar), ref Unsafe.As<Single, byte>(ref _data[0]), VectorSize);
+        }
+
+        public SimpleUnaryOpTest__RoundCurrentDirectionSingle()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld), ref Unsafe.As<Single, byte>(ref _data[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+            _dataTable = new SimpleUnaryOpTest__DataTable<Single, Single>(_data, new Single[RetElementCount], VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.RoundCurrentDirection(
+                Unsafe.Read<Vector256<Single>>(_dataTable.inArrayPtr)
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.RoundCurrentDirection(
+                Avx.LoadVector256((Single*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.RoundCurrentDirection(
+                Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundCurrentDirection), new Type[] { typeof(Vector256<Single>) })
+                                     .Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Single>>(_dataTable.inArrayPtr)
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Single>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundCurrentDirection), new Type[] { typeof(Vector256<Single>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadVector256((Single*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Single>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundCurrentDirection), new Type[] { typeof(Vector256<Single>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Single>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.RoundCurrentDirection(
+                _clsVar
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_clsVar, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var firstOp = Unsafe.Read<Vector256<Single>>(_dataTable.inArrayPtr);
+            var result = Avx.RoundCurrentDirection(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var firstOp = Avx.LoadVector256((Single*)(_dataTable.inArrayPtr));
+            var result = Avx.RoundCurrentDirection(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var firstOp = Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr));
+            var result = Avx.RoundCurrentDirection(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new SimpleUnaryOpTest__RoundCurrentDirectionSingle();
+            var result = Avx.RoundCurrentDirection(test._fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(test._fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.RoundCurrentDirection(_fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Single> firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Single[] inArray = new Single[Op1ElementCount];
+            Single[] outArray = new Single[RetElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray[0]), firstOp);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Single[] inArray = new Single[Op1ElementCount];
+            Single[] outArray = new Single[RetElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "")
+        {
+            if (BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Round(firstOp[0])))
+            {
+                Succeeded = false;
+            }
+            else
+            {
+                for (var i = 1; i < RetElementCount; i++)
+                {
+                    if (BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Round(firstOp[i])))
+                    {
+                        Succeeded = false;
+                        break;
+                    }
+                }
+            }
+
+            if (!Succeeded)
+            {
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.RoundCurrentDirection)}<Single>(Vector256<Single>): {method} failed:");
+                Console.WriteLine($"  firstOp: ({string.Join(", ", firstOp)})");
+                Console.WriteLine($"   result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNearestInteger.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNearestInteger.Double.cs
new file mode 100644 (file)
index 0000000..51d87fa
--- /dev/null
@@ -0,0 +1,306 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void RoundToNearestIntegerDouble()
+        {
+            var test = new SimpleUnaryOpTest__RoundToNearestIntegerDouble();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class SimpleUnaryOpTest__RoundToNearestIntegerDouble
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Double);
+        private const int RetElementCount = VectorSize / sizeof(Double);
+
+        private static Double[] _data = new Double[Op1ElementCount];
+
+        private static Vector256<Double> _clsVar;
+
+        private Vector256<Double> _fld;
+
+        private SimpleUnaryOpTest__DataTable<Double, Double> _dataTable;
+
+        static SimpleUnaryOpTest__RoundToNearestIntegerDouble()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar), ref Unsafe.As<Double, byte>(ref _data[0]), VectorSize);
+        }
+
+        public SimpleUnaryOpTest__RoundToNearestIntegerDouble()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld), ref Unsafe.As<Double, byte>(ref _data[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+            _dataTable = new SimpleUnaryOpTest__DataTable<Double, Double>(_data, new Double[RetElementCount], VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.RoundToNearestInteger(
+                Unsafe.Read<Vector256<Double>>(_dataTable.inArrayPtr)
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.RoundToNearestInteger(
+                Avx.LoadVector256((Double*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.RoundToNearestInteger(
+                Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundToNearestInteger), new Type[] { typeof(Vector256<Double>) })
+                                     .Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Double>>(_dataTable.inArrayPtr)
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundToNearestInteger), new Type[] { typeof(Vector256<Double>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadVector256((Double*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundToNearestInteger), new Type[] { typeof(Vector256<Double>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.RoundToNearestInteger(
+                _clsVar
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_clsVar, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var firstOp = Unsafe.Read<Vector256<Double>>(_dataTable.inArrayPtr);
+            var result = Avx.RoundToNearestInteger(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var firstOp = Avx.LoadVector256((Double*)(_dataTable.inArrayPtr));
+            var result = Avx.RoundToNearestInteger(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var firstOp = Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr));
+            var result = Avx.RoundToNearestInteger(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new SimpleUnaryOpTest__RoundToNearestIntegerDouble();
+            var result = Avx.RoundToNearestInteger(test._fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(test._fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.RoundToNearestInteger(_fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Double> firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Double[] inArray = new Double[Op1ElementCount];
+            Double[] outArray = new Double[RetElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray[0]), firstOp);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Double[] inArray = new Double[Op1ElementCount];
+            Double[] outArray = new Double[RetElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(Double[] firstOp, Double[] result, [CallerMemberName] string method = "")
+        {
+            if (BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Round(firstOp[0], MidpointRounding.AwayFromZero)))
+            {
+                Succeeded = false;
+            }
+            else
+            {
+                for (var i = 1; i < RetElementCount; i++)
+                {
+                    if (BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Round(firstOp[i], MidpointRounding.AwayFromZero)))
+                    {
+                        Succeeded = false;
+                        break;
+                    }
+                }
+            }
+
+            if (!Succeeded)
+            {
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.RoundToNearestInteger)}<Double>(Vector256<Double>): {method} failed:");
+                Console.WriteLine($"  firstOp: ({string.Join(", ", firstOp)})");
+                Console.WriteLine($"   result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNearestInteger.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNearestInteger.Single.cs
new file mode 100644 (file)
index 0000000..7fc26cb
--- /dev/null
@@ -0,0 +1,306 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void RoundToNearestIntegerSingle()
+        {
+            var test = new SimpleUnaryOpTest__RoundToNearestIntegerSingle();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class SimpleUnaryOpTest__RoundToNearestIntegerSingle
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Single);
+        private const int RetElementCount = VectorSize / sizeof(Single);
+
+        private static Single[] _data = new Single[Op1ElementCount];
+
+        private static Vector256<Single> _clsVar;
+
+        private Vector256<Single> _fld;
+
+        private SimpleUnaryOpTest__DataTable<Single, Single> _dataTable;
+
+        static SimpleUnaryOpTest__RoundToNearestIntegerSingle()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar), ref Unsafe.As<Single, byte>(ref _data[0]), VectorSize);
+        }
+
+        public SimpleUnaryOpTest__RoundToNearestIntegerSingle()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld), ref Unsafe.As<Single, byte>(ref _data[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+            _dataTable = new SimpleUnaryOpTest__DataTable<Single, Single>(_data, new Single[RetElementCount], VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.RoundToNearestInteger(
+                Unsafe.Read<Vector256<Single>>(_dataTable.inArrayPtr)
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.RoundToNearestInteger(
+                Avx.LoadVector256((Single*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.RoundToNearestInteger(
+                Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundToNearestInteger), new Type[] { typeof(Vector256<Single>) })
+                                     .Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Single>>(_dataTable.inArrayPtr)
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Single>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundToNearestInteger), new Type[] { typeof(Vector256<Single>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadVector256((Single*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Single>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundToNearestInteger), new Type[] { typeof(Vector256<Single>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Single>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.RoundToNearestInteger(
+                _clsVar
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_clsVar, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var firstOp = Unsafe.Read<Vector256<Single>>(_dataTable.inArrayPtr);
+            var result = Avx.RoundToNearestInteger(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var firstOp = Avx.LoadVector256((Single*)(_dataTable.inArrayPtr));
+            var result = Avx.RoundToNearestInteger(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var firstOp = Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr));
+            var result = Avx.RoundToNearestInteger(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new SimpleUnaryOpTest__RoundToNearestIntegerSingle();
+            var result = Avx.RoundToNearestInteger(test._fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(test._fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.RoundToNearestInteger(_fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Single> firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Single[] inArray = new Single[Op1ElementCount];
+            Single[] outArray = new Single[RetElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray[0]), firstOp);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Single[] inArray = new Single[Op1ElementCount];
+            Single[] outArray = new Single[RetElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "")
+        {
+            if (BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Round(firstOp[0], MidpointRounding.AwayFromZero)))
+            {
+                Succeeded = false;
+            }
+            else
+            {
+                for (var i = 1; i < RetElementCount; i++)
+                {
+                    if (BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Round(firstOp[i], MidpointRounding.AwayFromZero)))
+                    {
+                        Succeeded = false;
+                        break;
+                    }
+                }
+            }
+
+            if (!Succeeded)
+            {
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.RoundToNearestInteger)}<Single>(Vector256<Single>): {method} failed:");
+                Console.WriteLine($"  firstOp: ({string.Join(", ", firstOp)})");
+                Console.WriteLine($"   result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNegativeInfinity.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNegativeInfinity.Double.cs
new file mode 100644 (file)
index 0000000..2c11ab6
--- /dev/null
@@ -0,0 +1,306 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void RoundToNegativeInfinityDouble()
+        {
+            var test = new SimpleUnaryOpTest__RoundToNegativeInfinityDouble();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class SimpleUnaryOpTest__RoundToNegativeInfinityDouble
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Double);
+        private const int RetElementCount = VectorSize / sizeof(Double);
+
+        private static Double[] _data = new Double[Op1ElementCount];
+
+        private static Vector256<Double> _clsVar;
+
+        private Vector256<Double> _fld;
+
+        private SimpleUnaryOpTest__DataTable<Double, Double> _dataTable;
+
+        static SimpleUnaryOpTest__RoundToNegativeInfinityDouble()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar), ref Unsafe.As<Double, byte>(ref _data[0]), VectorSize);
+        }
+
+        public SimpleUnaryOpTest__RoundToNegativeInfinityDouble()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld), ref Unsafe.As<Double, byte>(ref _data[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+            _dataTable = new SimpleUnaryOpTest__DataTable<Double, Double>(_data, new Double[RetElementCount], VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.RoundToNegativeInfinity(
+                Unsafe.Read<Vector256<Double>>(_dataTable.inArrayPtr)
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.RoundToNegativeInfinity(
+                Avx.LoadVector256((Double*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.RoundToNegativeInfinity(
+                Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundToNegativeInfinity), new Type[] { typeof(Vector256<Double>) })
+                                     .Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Double>>(_dataTable.inArrayPtr)
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundToNegativeInfinity), new Type[] { typeof(Vector256<Double>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadVector256((Double*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundToNegativeInfinity), new Type[] { typeof(Vector256<Double>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.RoundToNegativeInfinity(
+                _clsVar
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_clsVar, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var firstOp = Unsafe.Read<Vector256<Double>>(_dataTable.inArrayPtr);
+            var result = Avx.RoundToNegativeInfinity(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var firstOp = Avx.LoadVector256((Double*)(_dataTable.inArrayPtr));
+            var result = Avx.RoundToNegativeInfinity(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var firstOp = Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr));
+            var result = Avx.RoundToNegativeInfinity(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new SimpleUnaryOpTest__RoundToNegativeInfinityDouble();
+            var result = Avx.RoundToNegativeInfinity(test._fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(test._fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.RoundToNegativeInfinity(_fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Double> firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Double[] inArray = new Double[Op1ElementCount];
+            Double[] outArray = new Double[RetElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray[0]), firstOp);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Double[] inArray = new Double[Op1ElementCount];
+            Double[] outArray = new Double[RetElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(Double[] firstOp, Double[] result, [CallerMemberName] string method = "")
+        {
+            if (BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[0])))
+            {
+                Succeeded = false;
+            }
+            else
+            {
+                for (var i = 1; i < RetElementCount; i++)
+                {
+                    if (BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[i])))
+                    {
+                        Succeeded = false;
+                        break;
+                    }
+                }
+            }
+
+            if (!Succeeded)
+            {
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.RoundToNegativeInfinity)}<Double>(Vector256<Double>): {method} failed:");
+                Console.WriteLine($"  firstOp: ({string.Join(", ", firstOp)})");
+                Console.WriteLine($"   result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNegativeInfinity.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToNegativeInfinity.Single.cs
new file mode 100644 (file)
index 0000000..10fa04d
--- /dev/null
@@ -0,0 +1,306 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void RoundToNegativeInfinitySingle()
+        {
+            var test = new SimpleUnaryOpTest__RoundToNegativeInfinitySingle();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class SimpleUnaryOpTest__RoundToNegativeInfinitySingle
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Single);
+        private const int RetElementCount = VectorSize / sizeof(Single);
+
+        private static Single[] _data = new Single[Op1ElementCount];
+
+        private static Vector256<Single> _clsVar;
+
+        private Vector256<Single> _fld;
+
+        private SimpleUnaryOpTest__DataTable<Single, Single> _dataTable;
+
+        static SimpleUnaryOpTest__RoundToNegativeInfinitySingle()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar), ref Unsafe.As<Single, byte>(ref _data[0]), VectorSize);
+        }
+
+        public SimpleUnaryOpTest__RoundToNegativeInfinitySingle()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld), ref Unsafe.As<Single, byte>(ref _data[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+            _dataTable = new SimpleUnaryOpTest__DataTable<Single, Single>(_data, new Single[RetElementCount], VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.RoundToNegativeInfinity(
+                Unsafe.Read<Vector256<Single>>(_dataTable.inArrayPtr)
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.RoundToNegativeInfinity(
+                Avx.LoadVector256((Single*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.RoundToNegativeInfinity(
+                Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundToNegativeInfinity), new Type[] { typeof(Vector256<Single>) })
+                                     .Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Single>>(_dataTable.inArrayPtr)
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Single>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundToNegativeInfinity), new Type[] { typeof(Vector256<Single>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadVector256((Single*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Single>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundToNegativeInfinity), new Type[] { typeof(Vector256<Single>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Single>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.RoundToNegativeInfinity(
+                _clsVar
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_clsVar, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var firstOp = Unsafe.Read<Vector256<Single>>(_dataTable.inArrayPtr);
+            var result = Avx.RoundToNegativeInfinity(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var firstOp = Avx.LoadVector256((Single*)(_dataTable.inArrayPtr));
+            var result = Avx.RoundToNegativeInfinity(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var firstOp = Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr));
+            var result = Avx.RoundToNegativeInfinity(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new SimpleUnaryOpTest__RoundToNegativeInfinitySingle();
+            var result = Avx.RoundToNegativeInfinity(test._fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(test._fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.RoundToNegativeInfinity(_fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Single> firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Single[] inArray = new Single[Op1ElementCount];
+            Single[] outArray = new Single[RetElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray[0]), firstOp);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Single[] inArray = new Single[Op1ElementCount];
+            Single[] outArray = new Single[RetElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "")
+        {
+            if (BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[0])))
+            {
+                Succeeded = false;
+            }
+            else
+            {
+                for (var i = 1; i < RetElementCount; i++)
+                {
+                    if (BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[i])))
+                    {
+                        Succeeded = false;
+                        break;
+                    }
+                }
+            }
+
+            if (!Succeeded)
+            {
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.RoundToNegativeInfinity)}<Single>(Vector256<Single>): {method} failed:");
+                Console.WriteLine($"  firstOp: ({string.Join(", ", firstOp)})");
+                Console.WriteLine($"   result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToPositiveInfinity.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToPositiveInfinity.Double.cs
new file mode 100644 (file)
index 0000000..d53b365
--- /dev/null
@@ -0,0 +1,306 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void RoundToPositiveInfinityDouble()
+        {
+            var test = new SimpleUnaryOpTest__RoundToPositiveInfinityDouble();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class SimpleUnaryOpTest__RoundToPositiveInfinityDouble
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Double);
+        private const int RetElementCount = VectorSize / sizeof(Double);
+
+        private static Double[] _data = new Double[Op1ElementCount];
+
+        private static Vector256<Double> _clsVar;
+
+        private Vector256<Double> _fld;
+
+        private SimpleUnaryOpTest__DataTable<Double, Double> _dataTable;
+
+        static SimpleUnaryOpTest__RoundToPositiveInfinityDouble()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar), ref Unsafe.As<Double, byte>(ref _data[0]), VectorSize);
+        }
+
+        public SimpleUnaryOpTest__RoundToPositiveInfinityDouble()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld), ref Unsafe.As<Double, byte>(ref _data[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+            _dataTable = new SimpleUnaryOpTest__DataTable<Double, Double>(_data, new Double[RetElementCount], VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.RoundToPositiveInfinity(
+                Unsafe.Read<Vector256<Double>>(_dataTable.inArrayPtr)
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.RoundToPositiveInfinity(
+                Avx.LoadVector256((Double*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.RoundToPositiveInfinity(
+                Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundToPositiveInfinity), new Type[] { typeof(Vector256<Double>) })
+                                     .Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Double>>(_dataTable.inArrayPtr)
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundToPositiveInfinity), new Type[] { typeof(Vector256<Double>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadVector256((Double*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundToPositiveInfinity), new Type[] { typeof(Vector256<Double>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.RoundToPositiveInfinity(
+                _clsVar
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_clsVar, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var firstOp = Unsafe.Read<Vector256<Double>>(_dataTable.inArrayPtr);
+            var result = Avx.RoundToPositiveInfinity(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var firstOp = Avx.LoadVector256((Double*)(_dataTable.inArrayPtr));
+            var result = Avx.RoundToPositiveInfinity(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var firstOp = Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr));
+            var result = Avx.RoundToPositiveInfinity(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new SimpleUnaryOpTest__RoundToPositiveInfinityDouble();
+            var result = Avx.RoundToPositiveInfinity(test._fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(test._fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.RoundToPositiveInfinity(_fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Double> firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Double[] inArray = new Double[Op1ElementCount];
+            Double[] outArray = new Double[RetElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray[0]), firstOp);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Double[] inArray = new Double[Op1ElementCount];
+            Double[] outArray = new Double[RetElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(Double[] firstOp, Double[] result, [CallerMemberName] string method = "")
+        {
+            if (BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(firstOp[0])))
+            {
+                Succeeded = false;
+            }
+            else
+            {
+                for (var i = 1; i < RetElementCount; i++)
+                {
+                    if (BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(firstOp[i])))
+                    {
+                        Succeeded = false;
+                        break;
+                    }
+                }
+            }
+
+            if (!Succeeded)
+            {
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.RoundToPositiveInfinity)}<Double>(Vector256<Double>): {method} failed:");
+                Console.WriteLine($"  firstOp: ({string.Join(", ", firstOp)})");
+                Console.WriteLine($"   result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToPositiveInfinity.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToPositiveInfinity.Single.cs
new file mode 100644 (file)
index 0000000..d3d57cc
--- /dev/null
@@ -0,0 +1,306 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void RoundToPositiveInfinitySingle()
+        {
+            var test = new SimpleUnaryOpTest__RoundToPositiveInfinitySingle();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class SimpleUnaryOpTest__RoundToPositiveInfinitySingle
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Single);
+        private const int RetElementCount = VectorSize / sizeof(Single);
+
+        private static Single[] _data = new Single[Op1ElementCount];
+
+        private static Vector256<Single> _clsVar;
+
+        private Vector256<Single> _fld;
+
+        private SimpleUnaryOpTest__DataTable<Single, Single> _dataTable;
+
+        static SimpleUnaryOpTest__RoundToPositiveInfinitySingle()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar), ref Unsafe.As<Single, byte>(ref _data[0]), VectorSize);
+        }
+
+        public SimpleUnaryOpTest__RoundToPositiveInfinitySingle()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld), ref Unsafe.As<Single, byte>(ref _data[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+            _dataTable = new SimpleUnaryOpTest__DataTable<Single, Single>(_data, new Single[RetElementCount], VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.RoundToPositiveInfinity(
+                Unsafe.Read<Vector256<Single>>(_dataTable.inArrayPtr)
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.RoundToPositiveInfinity(
+                Avx.LoadVector256((Single*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.RoundToPositiveInfinity(
+                Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundToPositiveInfinity), new Type[] { typeof(Vector256<Single>) })
+                                     .Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Single>>(_dataTable.inArrayPtr)
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Single>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundToPositiveInfinity), new Type[] { typeof(Vector256<Single>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadVector256((Single*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Single>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundToPositiveInfinity), new Type[] { typeof(Vector256<Single>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Single>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.RoundToPositiveInfinity(
+                _clsVar
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_clsVar, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var firstOp = Unsafe.Read<Vector256<Single>>(_dataTable.inArrayPtr);
+            var result = Avx.RoundToPositiveInfinity(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var firstOp = Avx.LoadVector256((Single*)(_dataTable.inArrayPtr));
+            var result = Avx.RoundToPositiveInfinity(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var firstOp = Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr));
+            var result = Avx.RoundToPositiveInfinity(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new SimpleUnaryOpTest__RoundToPositiveInfinitySingle();
+            var result = Avx.RoundToPositiveInfinity(test._fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(test._fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.RoundToPositiveInfinity(_fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Single> firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Single[] inArray = new Single[Op1ElementCount];
+            Single[] outArray = new Single[RetElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray[0]), firstOp);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Single[] inArray = new Single[Op1ElementCount];
+            Single[] outArray = new Single[RetElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "")
+        {
+            if (BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(firstOp[0])))
+            {
+                Succeeded = false;
+            }
+            else
+            {
+                for (var i = 1; i < RetElementCount; i++)
+                {
+                    if (BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(firstOp[i])))
+                    {
+                        Succeeded = false;
+                        break;
+                    }
+                }
+            }
+
+            if (!Succeeded)
+            {
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.RoundToPositiveInfinity)}<Single>(Vector256<Single>): {method} failed:");
+                Console.WriteLine($"  firstOp: ({string.Join(", ", firstOp)})");
+                Console.WriteLine($"   result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToZero.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToZero.Double.cs
new file mode 100644 (file)
index 0000000..f23c8e7
--- /dev/null
@@ -0,0 +1,306 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void RoundToZeroDouble()
+        {
+            var test = new SimpleUnaryOpTest__RoundToZeroDouble();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class SimpleUnaryOpTest__RoundToZeroDouble
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Double);
+        private const int RetElementCount = VectorSize / sizeof(Double);
+
+        private static Double[] _data = new Double[Op1ElementCount];
+
+        private static Vector256<Double> _clsVar;
+
+        private Vector256<Double> _fld;
+
+        private SimpleUnaryOpTest__DataTable<Double, Double> _dataTable;
+
+        static SimpleUnaryOpTest__RoundToZeroDouble()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar), ref Unsafe.As<Double, byte>(ref _data[0]), VectorSize);
+        }
+
+        public SimpleUnaryOpTest__RoundToZeroDouble()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld), ref Unsafe.As<Double, byte>(ref _data[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+            _dataTable = new SimpleUnaryOpTest__DataTable<Double, Double>(_data, new Double[RetElementCount], VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.RoundToZero(
+                Unsafe.Read<Vector256<Double>>(_dataTable.inArrayPtr)
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.RoundToZero(
+                Avx.LoadVector256((Double*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.RoundToZero(
+                Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundToZero), new Type[] { typeof(Vector256<Double>) })
+                                     .Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Double>>(_dataTable.inArrayPtr)
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundToZero), new Type[] { typeof(Vector256<Double>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadVector256((Double*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundToZero), new Type[] { typeof(Vector256<Double>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Double>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.RoundToZero(
+                _clsVar
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_clsVar, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var firstOp = Unsafe.Read<Vector256<Double>>(_dataTable.inArrayPtr);
+            var result = Avx.RoundToZero(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var firstOp = Avx.LoadVector256((Double*)(_dataTable.inArrayPtr));
+            var result = Avx.RoundToZero(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var firstOp = Avx.LoadAlignedVector256((Double*)(_dataTable.inArrayPtr));
+            var result = Avx.RoundToZero(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new SimpleUnaryOpTest__RoundToZeroDouble();
+            var result = Avx.RoundToZero(test._fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(test._fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.RoundToZero(_fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Double> firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Double[] inArray = new Double[Op1ElementCount];
+            Double[] outArray = new Double[RetElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray[0]), firstOp);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Double[] inArray = new Double[Op1ElementCount];
+            Double[] outArray = new Double[RetElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(Double[] firstOp, Double[] result, [CallerMemberName] string method = "")
+        {
+            if (BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits((firstOp[0] > 0) ? Math.Floor(firstOp[0]) : Math.Ceiling(firstOp[0])))
+            {
+                Succeeded = false;
+            }
+            else
+            {
+                for (var i = 1; i < RetElementCount; i++)
+                {
+                    if (BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits((firstOp[i] > 0) ? Math.Floor(firstOp[i]) : Math.Ceiling(firstOp[i])))
+                    {
+                        Succeeded = false;
+                        break;
+                    }
+                }
+            }
+
+            if (!Succeeded)
+            {
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.RoundToZero)}<Double>(Vector256<Double>): {method} failed:");
+                Console.WriteLine($"  firstOp: ({string.Join(", ", firstOp)})");
+                Console.WriteLine($"   result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToZero.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/RoundToZero.Single.cs
new file mode 100644 (file)
index 0000000..7569809
--- /dev/null
@@ -0,0 +1,306 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void RoundToZeroSingle()
+        {
+            var test = new SimpleUnaryOpTest__RoundToZeroSingle();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class SimpleUnaryOpTest__RoundToZeroSingle
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Single);
+        private const int RetElementCount = VectorSize / sizeof(Single);
+
+        private static Single[] _data = new Single[Op1ElementCount];
+
+        private static Vector256<Single> _clsVar;
+
+        private Vector256<Single> _fld;
+
+        private SimpleUnaryOpTest__DataTable<Single, Single> _dataTable;
+
+        static SimpleUnaryOpTest__RoundToZeroSingle()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar), ref Unsafe.As<Single, byte>(ref _data[0]), VectorSize);
+        }
+
+        public SimpleUnaryOpTest__RoundToZeroSingle()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld), ref Unsafe.As<Single, byte>(ref _data[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+            _dataTable = new SimpleUnaryOpTest__DataTable<Single, Single>(_data, new Single[RetElementCount], VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.RoundToZero(
+                Unsafe.Read<Vector256<Single>>(_dataTable.inArrayPtr)
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.RoundToZero(
+                Avx.LoadVector256((Single*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.RoundToZero(
+                Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr))
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundToZero), new Type[] { typeof(Vector256<Single>) })
+                                     .Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Single>>(_dataTable.inArrayPtr)
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Single>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundToZero), new Type[] { typeof(Vector256<Single>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadVector256((Single*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Single>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var result = typeof(Avx).GetMethod(nameof(Avx.RoundToZero), new Type[] { typeof(Vector256<Single>) })
+                                     .Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr))
+                                     });
+
+            Unsafe.Write(_dataTable.outArrayPtr, (Vector256<Single>)(result));
+            ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.RoundToZero(
+                _clsVar
+            );
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_clsVar, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var firstOp = Unsafe.Read<Vector256<Single>>(_dataTable.inArrayPtr);
+            var result = Avx.RoundToZero(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var firstOp = Avx.LoadVector256((Single*)(_dataTable.inArrayPtr));
+            var result = Avx.RoundToZero(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var firstOp = Avx.LoadAlignedVector256((Single*)(_dataTable.inArrayPtr));
+            var result = Avx.RoundToZero(firstOp);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(firstOp, _dataTable.outArrayPtr);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new SimpleUnaryOpTest__RoundToZeroSingle();
+            var result = Avx.RoundToZero(test._fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(test._fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.RoundToZero(_fld);
+
+            Unsafe.Write(_dataTable.outArrayPtr, result);
+            ValidateResult(_fld, _dataTable.outArrayPtr);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Single> firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Single[] inArray = new Single[Op1ElementCount];
+            Single[] outArray = new Single[RetElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray[0]), firstOp);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
+        {
+            Single[] inArray = new Single[Op1ElementCount];
+            Single[] outArray = new Single[RetElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+
+            ValidateResult(inArray, outArray, method);
+        }
+
+        private void ValidateResult(Single[] firstOp, Single[] result, [CallerMemberName] string method = "")
+        {
+            if (BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits((firstOp[0] > 0) ? MathF.Floor(firstOp[0]) : MathF.Ceiling(firstOp[0])))
+            {
+                Succeeded = false;
+            }
+            else
+            {
+                for (var i = 1; i < RetElementCount; i++)
+                {
+                    if (BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits((firstOp[i] > 0) ? MathF.Floor(firstOp[i]) : MathF.Ceiling(firstOp[i])))
+                    {
+                        Succeeded = false;
+                        break;
+                    }
+                }
+            }
+
+            if (!Succeeded)
+            {
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.RoundToZero)}<Single>(Vector256<Single>): {method} failed:");
+                Console.WriteLine($"  firstOp: ({string.Join(", ", firstOp)})");
+                Console.WriteLine($"   result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Byte.cs
new file mode 100644 (file)
index 0000000..8ea205c
--- /dev/null
@@ -0,0 +1,318 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void TestCByte()
+        {
+            var test = new BooleanBinaryOpTest__TestCByte();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class BooleanBinaryOpTest__TestCByte
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Byte);
+        private const int Op2ElementCount = VectorSize / sizeof(Byte);
+
+        private static Byte[] _data1 = new Byte[Op1ElementCount];
+        private static Byte[] _data2 = new Byte[Op2ElementCount];
+
+        private static Vector256<Byte> _clsVar1;
+        private static Vector256<Byte> _clsVar2;
+
+        private Vector256<Byte> _fld1;
+        private Vector256<Byte> _fld2;
+
+        private BooleanBinaryOpTest__DataTable<Byte, Byte> _dataTable;
+
+        static BooleanBinaryOpTest__TestCByte()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
+        }
+
+        public BooleanBinaryOpTest__TestCByte()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+            _dataTable = new BooleanBinaryOpTest__DataTable<Byte, Byte>(_data1, _data2, VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.TestC(
+                Unsafe.Read<Vector256<Byte>>(_dataTable.inArray1Ptr),
+                Unsafe.Read<Vector256<Byte>>(_dataTable.inArray2Ptr)
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.TestC(
+                Avx.LoadVector256((Byte*)(_dataTable.inArray1Ptr)),
+                Avx.LoadVector256((Byte*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.TestC(
+                Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray1Ptr)),
+                Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256<Byte>), typeof(Vector256<Byte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Byte>>(_dataTable.inArray1Ptr),
+                                        Unsafe.Read<Vector256<Byte>>(_dataTable.inArray2Ptr)
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256<Byte>), typeof(Vector256<Byte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadVector256((Byte*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadVector256((Byte*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256<Byte>), typeof(Vector256<Byte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.TestC(
+                _clsVar1,
+                _clsVar2
+            );
+
+            ValidateResult(_clsVar1, _clsVar2, result);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var left = Unsafe.Read<Vector256<Byte>>(_dataTable.inArray1Ptr);
+            var right = Unsafe.Read<Vector256<Byte>>(_dataTable.inArray2Ptr);
+            var result = Avx.TestC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var left = Avx.LoadVector256((Byte*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadVector256((Byte*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var left = Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new BooleanBinaryOpTest__TestCByte();
+            var result = Avx.TestC(test._fld1, test._fld2);
+
+            ValidateResult(test._fld1, test._fld2, result);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.TestC(_fld1, _fld2);
+
+            ValidateResult(_fld1, _fld2, result);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Byte> left, Vector256<Byte> right, bool result, [CallerMemberName] string method = "")
+        {
+            Byte[] inArray1 = new Byte[Op1ElementCount];
+            Byte[] inArray2 = new Byte[Op2ElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
+            Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
+        {
+            Byte[] inArray1 = new Byte[Op1ElementCount];
+            Byte[] inArray2 = new Byte[Op2ElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(Byte[] left, Byte[] right, bool result, [CallerMemberName] string method = "")
+        {
+            var expectedResult = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult &= ((~left[i] & right[i]) == 0);
+            }
+
+            if (expectedResult != result)
+            {
+                Succeeded = false;
+
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.TestC)}<Byte>(Vector256<Byte>, Vector256<Byte>): {method} failed:");
+                Console.WriteLine($"    left: ({string.Join(", ", left)})");
+                Console.WriteLine($"   right: ({string.Join(", ", right)})");
+                Console.WriteLine($"  result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Int16.cs
new file mode 100644 (file)
index 0000000..47e1f2f
--- /dev/null
@@ -0,0 +1,318 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void TestCInt16()
+        {
+            var test = new BooleanBinaryOpTest__TestCInt16();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class BooleanBinaryOpTest__TestCInt16
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Int16);
+        private const int Op2ElementCount = VectorSize / sizeof(Int16);
+
+        private static Int16[] _data1 = new Int16[Op1ElementCount];
+        private static Int16[] _data2 = new Int16[Op2ElementCount];
+
+        private static Vector256<Int16> _clsVar1;
+        private static Vector256<Int16> _clsVar2;
+
+        private Vector256<Int16> _fld1;
+        private Vector256<Int16> _fld2;
+
+        private BooleanBinaryOpTest__DataTable<Int16, Int16> _dataTable;
+
+        static BooleanBinaryOpTest__TestCInt16()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
+        }
+
+        public BooleanBinaryOpTest__TestCInt16()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+            _dataTable = new BooleanBinaryOpTest__DataTable<Int16, Int16>(_data1, _data2, VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.TestC(
+                Unsafe.Read<Vector256<Int16>>(_dataTable.inArray1Ptr),
+                Unsafe.Read<Vector256<Int16>>(_dataTable.inArray2Ptr)
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.TestC(
+                Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)),
+                Avx.LoadVector256((Int16*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.TestC(
+                Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)),
+                Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256<Int16>), typeof(Vector256<Int16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Int16>>(_dataTable.inArray1Ptr),
+                                        Unsafe.Read<Vector256<Int16>>(_dataTable.inArray2Ptr)
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256<Int16>), typeof(Vector256<Int16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadVector256((Int16*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256<Int16>), typeof(Vector256<Int16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.TestC(
+                _clsVar1,
+                _clsVar2
+            );
+
+            ValidateResult(_clsVar1, _clsVar2, result);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var left = Unsafe.Read<Vector256<Int16>>(_dataTable.inArray1Ptr);
+            var right = Unsafe.Read<Vector256<Int16>>(_dataTable.inArray2Ptr);
+            var result = Avx.TestC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var left = Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadVector256((Int16*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var left = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new BooleanBinaryOpTest__TestCInt16();
+            var result = Avx.TestC(test._fld1, test._fld2);
+
+            ValidateResult(test._fld1, test._fld2, result);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.TestC(_fld1, _fld2);
+
+            ValidateResult(_fld1, _fld2, result);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Int16> left, Vector256<Int16> right, bool result, [CallerMemberName] string method = "")
+        {
+            Int16[] inArray1 = new Int16[Op1ElementCount];
+            Int16[] inArray2 = new Int16[Op2ElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
+            Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
+        {
+            Int16[] inArray1 = new Int16[Op1ElementCount];
+            Int16[] inArray2 = new Int16[Op2ElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(Int16[] left, Int16[] right, bool result, [CallerMemberName] string method = "")
+        {
+            var expectedResult = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult &= ((~left[i] & right[i]) == 0);
+            }
+
+            if (expectedResult != result)
+            {
+                Succeeded = false;
+
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.TestC)}<Int16>(Vector256<Int16>, Vector256<Int16>): {method} failed:");
+                Console.WriteLine($"    left: ({string.Join(", ", left)})");
+                Console.WriteLine($"   right: ({string.Join(", ", right)})");
+                Console.WriteLine($"  result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Int32.cs
new file mode 100644 (file)
index 0000000..1cbe4f5
--- /dev/null
@@ -0,0 +1,318 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void TestCInt32()
+        {
+            var test = new BooleanBinaryOpTest__TestCInt32();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class BooleanBinaryOpTest__TestCInt32
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Int32);
+        private const int Op2ElementCount = VectorSize / sizeof(Int32);
+
+        private static Int32[] _data1 = new Int32[Op1ElementCount];
+        private static Int32[] _data2 = new Int32[Op2ElementCount];
+
+        private static Vector256<Int32> _clsVar1;
+        private static Vector256<Int32> _clsVar2;
+
+        private Vector256<Int32> _fld1;
+        private Vector256<Int32> _fld2;
+
+        private BooleanBinaryOpTest__DataTable<Int32, Int32> _dataTable;
+
+        static BooleanBinaryOpTest__TestCInt32()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
+        }
+
+        public BooleanBinaryOpTest__TestCInt32()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+            _dataTable = new BooleanBinaryOpTest__DataTable<Int32, Int32>(_data1, _data2, VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.TestC(
+                Unsafe.Read<Vector256<Int32>>(_dataTable.inArray1Ptr),
+                Unsafe.Read<Vector256<Int32>>(_dataTable.inArray2Ptr)
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.TestC(
+                Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)),
+                Avx.LoadVector256((Int32*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.TestC(
+                Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)),
+                Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256<Int32>), typeof(Vector256<Int32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Int32>>(_dataTable.inArray1Ptr),
+                                        Unsafe.Read<Vector256<Int32>>(_dataTable.inArray2Ptr)
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256<Int32>), typeof(Vector256<Int32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadVector256((Int32*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256<Int32>), typeof(Vector256<Int32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.TestC(
+                _clsVar1,
+                _clsVar2
+            );
+
+            ValidateResult(_clsVar1, _clsVar2, result);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var left = Unsafe.Read<Vector256<Int32>>(_dataTable.inArray1Ptr);
+            var right = Unsafe.Read<Vector256<Int32>>(_dataTable.inArray2Ptr);
+            var result = Avx.TestC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var left = Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadVector256((Int32*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var left = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new BooleanBinaryOpTest__TestCInt32();
+            var result = Avx.TestC(test._fld1, test._fld2);
+
+            ValidateResult(test._fld1, test._fld2, result);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.TestC(_fld1, _fld2);
+
+            ValidateResult(_fld1, _fld2, result);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Int32> left, Vector256<Int32> right, bool result, [CallerMemberName] string method = "")
+        {
+            Int32[] inArray1 = new Int32[Op1ElementCount];
+            Int32[] inArray2 = new Int32[Op2ElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
+            Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
+        {
+            Int32[] inArray1 = new Int32[Op1ElementCount];
+            Int32[] inArray2 = new Int32[Op2ElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(Int32[] left, Int32[] right, bool result, [CallerMemberName] string method = "")
+        {
+            var expectedResult = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult &= ((~left[i] & right[i]) == 0);
+            }
+
+            if (expectedResult != result)
+            {
+                Succeeded = false;
+
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.TestC)}<Int32>(Vector256<Int32>, Vector256<Int32>): {method} failed:");
+                Console.WriteLine($"    left: ({string.Join(", ", left)})");
+                Console.WriteLine($"   right: ({string.Join(", ", right)})");
+                Console.WriteLine($"  result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.Int64.cs
new file mode 100644 (file)
index 0000000..50e881c
--- /dev/null
@@ -0,0 +1,318 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void TestCInt64()
+        {
+            var test = new BooleanBinaryOpTest__TestCInt64();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class BooleanBinaryOpTest__TestCInt64
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Int64);
+        private const int Op2ElementCount = VectorSize / sizeof(Int64);
+
+        private static Int64[] _data1 = new Int64[Op1ElementCount];
+        private static Int64[] _data2 = new Int64[Op2ElementCount];
+
+        private static Vector256<Int64> _clsVar1;
+        private static Vector256<Int64> _clsVar2;
+
+        private Vector256<Int64> _fld1;
+        private Vector256<Int64> _fld2;
+
+        private BooleanBinaryOpTest__DataTable<Int64, Int64> _dataTable;
+
+        static BooleanBinaryOpTest__TestCInt64()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
+        }
+
+        public BooleanBinaryOpTest__TestCInt64()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+            _dataTable = new BooleanBinaryOpTest__DataTable<Int64, Int64>(_data1, _data2, VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.TestC(
+                Unsafe.Read<Vector256<Int64>>(_dataTable.inArray1Ptr),
+                Unsafe.Read<Vector256<Int64>>(_dataTable.inArray2Ptr)
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.TestC(
+                Avx.LoadVector256((Int64*)(_dataTable.inArray1Ptr)),
+                Avx.LoadVector256((Int64*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.TestC(
+                Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray1Ptr)),
+                Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256<Int64>), typeof(Vector256<Int64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Int64>>(_dataTable.inArray1Ptr),
+                                        Unsafe.Read<Vector256<Int64>>(_dataTable.inArray2Ptr)
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256<Int64>), typeof(Vector256<Int64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadVector256((Int64*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadVector256((Int64*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256<Int64>), typeof(Vector256<Int64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.TestC(
+                _clsVar1,
+                _clsVar2
+            );
+
+            ValidateResult(_clsVar1, _clsVar2, result);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var left = Unsafe.Read<Vector256<Int64>>(_dataTable.inArray1Ptr);
+            var right = Unsafe.Read<Vector256<Int64>>(_dataTable.inArray2Ptr);
+            var result = Avx.TestC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var left = Avx.LoadVector256((Int64*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadVector256((Int64*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var left = Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new BooleanBinaryOpTest__TestCInt64();
+            var result = Avx.TestC(test._fld1, test._fld2);
+
+            ValidateResult(test._fld1, test._fld2, result);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.TestC(_fld1, _fld2);
+
+            ValidateResult(_fld1, _fld2, result);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Int64> left, Vector256<Int64> right, bool result, [CallerMemberName] string method = "")
+        {
+            Int64[] inArray1 = new Int64[Op1ElementCount];
+            Int64[] inArray2 = new Int64[Op2ElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
+            Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
+        {
+            Int64[] inArray1 = new Int64[Op1ElementCount];
+            Int64[] inArray2 = new Int64[Op2ElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(Int64[] left, Int64[] right, bool result, [CallerMemberName] string method = "")
+        {
+            var expectedResult = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult &= ((~left[i] & right[i]) == 0);
+            }
+
+            if (expectedResult != result)
+            {
+                Succeeded = false;
+
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.TestC)}<Int64>(Vector256<Int64>, Vector256<Int64>): {method} failed:");
+                Console.WriteLine($"    left: ({string.Join(", ", left)})");
+                Console.WriteLine($"   right: ({string.Join(", ", right)})");
+                Console.WriteLine($"  result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.SByte.cs
new file mode 100644 (file)
index 0000000..ebb96bc
--- /dev/null
@@ -0,0 +1,318 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void TestCSByte()
+        {
+            var test = new BooleanBinaryOpTest__TestCSByte();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class BooleanBinaryOpTest__TestCSByte
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(SByte);
+        private const int Op2ElementCount = VectorSize / sizeof(SByte);
+
+        private static SByte[] _data1 = new SByte[Op1ElementCount];
+        private static SByte[] _data2 = new SByte[Op2ElementCount];
+
+        private static Vector256<SByte> _clsVar1;
+        private static Vector256<SByte> _clsVar2;
+
+        private Vector256<SByte> _fld1;
+        private Vector256<SByte> _fld2;
+
+        private BooleanBinaryOpTest__DataTable<SByte, SByte> _dataTable;
+
+        static BooleanBinaryOpTest__TestCSByte()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
+        }
+
+        public BooleanBinaryOpTest__TestCSByte()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+            _dataTable = new BooleanBinaryOpTest__DataTable<SByte, SByte>(_data1, _data2, VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.TestC(
+                Unsafe.Read<Vector256<SByte>>(_dataTable.inArray1Ptr),
+                Unsafe.Read<Vector256<SByte>>(_dataTable.inArray2Ptr)
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.TestC(
+                Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)),
+                Avx.LoadVector256((SByte*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.TestC(
+                Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)),
+                Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256<SByte>), typeof(Vector256<SByte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<SByte>>(_dataTable.inArray1Ptr),
+                                        Unsafe.Read<Vector256<SByte>>(_dataTable.inArray2Ptr)
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256<SByte>), typeof(Vector256<SByte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadVector256((SByte*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256<SByte>), typeof(Vector256<SByte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.TestC(
+                _clsVar1,
+                _clsVar2
+            );
+
+            ValidateResult(_clsVar1, _clsVar2, result);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var left = Unsafe.Read<Vector256<SByte>>(_dataTable.inArray1Ptr);
+            var right = Unsafe.Read<Vector256<SByte>>(_dataTable.inArray2Ptr);
+            var result = Avx.TestC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var left = Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadVector256((SByte*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var left = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new BooleanBinaryOpTest__TestCSByte();
+            var result = Avx.TestC(test._fld1, test._fld2);
+
+            ValidateResult(test._fld1, test._fld2, result);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.TestC(_fld1, _fld2);
+
+            ValidateResult(_fld1, _fld2, result);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<SByte> left, Vector256<SByte> right, bool result, [CallerMemberName] string method = "")
+        {
+            SByte[] inArray1 = new SByte[Op1ElementCount];
+            SByte[] inArray2 = new SByte[Op2ElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
+            Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
+        {
+            SByte[] inArray1 = new SByte[Op1ElementCount];
+            SByte[] inArray2 = new SByte[Op2ElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(SByte[] left, SByte[] right, bool result, [CallerMemberName] string method = "")
+        {
+            var expectedResult = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult &= ((~left[i] & right[i]) == 0);
+            }
+
+            if (expectedResult != result)
+            {
+                Succeeded = false;
+
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.TestC)}<SByte>(Vector256<SByte>, Vector256<SByte>): {method} failed:");
+                Console.WriteLine($"    left: ({string.Join(", ", left)})");
+                Console.WriteLine($"   right: ({string.Join(", ", right)})");
+                Console.WriteLine($"  result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.UInt16.cs
new file mode 100644 (file)
index 0000000..b52c323
--- /dev/null
@@ -0,0 +1,318 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void TestCUInt16()
+        {
+            var test = new BooleanBinaryOpTest__TestCUInt16();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class BooleanBinaryOpTest__TestCUInt16
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+        private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+
+        private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+        private static UInt16[] _data2 = new UInt16[Op2ElementCount];
+
+        private static Vector256<UInt16> _clsVar1;
+        private static Vector256<UInt16> _clsVar2;
+
+        private Vector256<UInt16> _fld1;
+        private Vector256<UInt16> _fld2;
+
+        private BooleanBinaryOpTest__DataTable<UInt16, UInt16> _dataTable;
+
+        static BooleanBinaryOpTest__TestCUInt16()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
+        }
+
+        public BooleanBinaryOpTest__TestCUInt16()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _fld1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+            _dataTable = new BooleanBinaryOpTest__DataTable<UInt16, UInt16>(_data1, _data2, VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.TestC(
+                Unsafe.Read<Vector256<UInt16>>(_dataTable.inArray1Ptr),
+                Unsafe.Read<Vector256<UInt16>>(_dataTable.inArray2Ptr)
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.TestC(
+                Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)),
+                Avx.LoadVector256((UInt16*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.TestC(
+                Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)),
+                Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256<UInt16>), typeof(Vector256<UInt16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<UInt16>>(_dataTable.inArray1Ptr),
+                                        Unsafe.Read<Vector256<UInt16>>(_dataTable.inArray2Ptr)
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256<UInt16>), typeof(Vector256<UInt16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadVector256((UInt16*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256<UInt16>), typeof(Vector256<UInt16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.TestC(
+                _clsVar1,
+                _clsVar2
+            );
+
+            ValidateResult(_clsVar1, _clsVar2, result);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var left = Unsafe.Read<Vector256<UInt16>>(_dataTable.inArray1Ptr);
+            var right = Unsafe.Read<Vector256<UInt16>>(_dataTable.inArray2Ptr);
+            var result = Avx.TestC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var left = Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadVector256((UInt16*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var left = Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new BooleanBinaryOpTest__TestCUInt16();
+            var result = Avx.TestC(test._fld1, test._fld2);
+
+            ValidateResult(test._fld1, test._fld2, result);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.TestC(_fld1, _fld2);
+
+            ValidateResult(_fld1, _fld2, result);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<UInt16> left, Vector256<UInt16> right, bool result, [CallerMemberName] string method = "")
+        {
+            UInt16[] inArray1 = new UInt16[Op1ElementCount];
+            UInt16[] inArray2 = new UInt16[Op2ElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
+            Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
+        {
+            UInt16[] inArray1 = new UInt16[Op1ElementCount];
+            UInt16[] inArray2 = new UInt16[Op2ElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(UInt16[] left, UInt16[] right, bool result, [CallerMemberName] string method = "")
+        {
+            var expectedResult = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult &= ((~left[i] & right[i]) == 0);
+            }
+
+            if (expectedResult != result)
+            {
+                Succeeded = false;
+
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.TestC)}<UInt16>(Vector256<UInt16>, Vector256<UInt16>): {method} failed:");
+                Console.WriteLine($"    left: ({string.Join(", ", left)})");
+                Console.WriteLine($"   right: ({string.Join(", ", right)})");
+                Console.WriteLine($"  result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.UInt32.cs
new file mode 100644 (file)
index 0000000..22d8c3e
--- /dev/null
@@ -0,0 +1,318 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void TestCUInt32()
+        {
+            var test = new BooleanBinaryOpTest__TestCUInt32();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class BooleanBinaryOpTest__TestCUInt32
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+        private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+
+        private static UInt32[] _data1 = new UInt32[Op1ElementCount];
+        private static UInt32[] _data2 = new UInt32[Op2ElementCount];
+
+        private static Vector256<UInt32> _clsVar1;
+        private static Vector256<UInt32> _clsVar2;
+
+        private Vector256<UInt32> _fld1;
+        private Vector256<UInt32> _fld2;
+
+        private BooleanBinaryOpTest__DataTable<UInt32, UInt32> _dataTable;
+
+        static BooleanBinaryOpTest__TestCUInt32()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
+        }
+
+        public BooleanBinaryOpTest__TestCUInt32()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+            _dataTable = new BooleanBinaryOpTest__DataTable<UInt32, UInt32>(_data1, _data2, VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.TestC(
+                Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray1Ptr),
+                Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray2Ptr)
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.TestC(
+                Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)),
+                Avx.LoadVector256((UInt32*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.TestC(
+                Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)),
+                Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256<UInt32>), typeof(Vector256<UInt32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray1Ptr),
+                                        Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray2Ptr)
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256<UInt32>), typeof(Vector256<UInt32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadVector256((UInt32*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256<UInt32>), typeof(Vector256<UInt32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.TestC(
+                _clsVar1,
+                _clsVar2
+            );
+
+            ValidateResult(_clsVar1, _clsVar2, result);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var left = Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray1Ptr);
+            var right = Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray2Ptr);
+            var result = Avx.TestC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var left = Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadVector256((UInt32*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var left = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new BooleanBinaryOpTest__TestCUInt32();
+            var result = Avx.TestC(test._fld1, test._fld2);
+
+            ValidateResult(test._fld1, test._fld2, result);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.TestC(_fld1, _fld2);
+
+            ValidateResult(_fld1, _fld2, result);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<UInt32> left, Vector256<UInt32> right, bool result, [CallerMemberName] string method = "")
+        {
+            UInt32[] inArray1 = new UInt32[Op1ElementCount];
+            UInt32[] inArray2 = new UInt32[Op2ElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
+            Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
+        {
+            UInt32[] inArray1 = new UInt32[Op1ElementCount];
+            UInt32[] inArray2 = new UInt32[Op2ElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(UInt32[] left, UInt32[] right, bool result, [CallerMemberName] string method = "")
+        {
+            var expectedResult = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult &= ((~left[i] & right[i]) == 0);
+            }
+
+            if (expectedResult != result)
+            {
+                Succeeded = false;
+
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.TestC)}<UInt32>(Vector256<UInt32>, Vector256<UInt32>): {method} failed:");
+                Console.WriteLine($"    left: ({string.Join(", ", left)})");
+                Console.WriteLine($"   right: ({string.Join(", ", right)})");
+                Console.WriteLine($"  result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestC.UInt64.cs
new file mode 100644 (file)
index 0000000..e09bcc9
--- /dev/null
@@ -0,0 +1,318 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void TestCUInt64()
+        {
+            var test = new BooleanBinaryOpTest__TestCUInt64();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class BooleanBinaryOpTest__TestCUInt64
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+        private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+
+        private static UInt64[] _data1 = new UInt64[Op1ElementCount];
+        private static UInt64[] _data2 = new UInt64[Op2ElementCount];
+
+        private static Vector256<UInt64> _clsVar1;
+        private static Vector256<UInt64> _clsVar2;
+
+        private Vector256<UInt64> _fld1;
+        private Vector256<UInt64> _fld2;
+
+        private BooleanBinaryOpTest__DataTable<UInt64, UInt64> _dataTable;
+
+        static BooleanBinaryOpTest__TestCUInt64()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
+        }
+
+        public BooleanBinaryOpTest__TestCUInt64()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+            _dataTable = new BooleanBinaryOpTest__DataTable<UInt64, UInt64>(_data1, _data2, VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.TestC(
+                Unsafe.Read<Vector256<UInt64>>(_dataTable.inArray1Ptr),
+                Unsafe.Read<Vector256<UInt64>>(_dataTable.inArray2Ptr)
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.TestC(
+                Avx.LoadVector256((UInt64*)(_dataTable.inArray1Ptr)),
+                Avx.LoadVector256((UInt64*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.TestC(
+                Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray1Ptr)),
+                Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256<UInt64>), typeof(Vector256<UInt64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<UInt64>>(_dataTable.inArray1Ptr),
+                                        Unsafe.Read<Vector256<UInt64>>(_dataTable.inArray2Ptr)
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256<UInt64>), typeof(Vector256<UInt64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadVector256((UInt64*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadVector256((UInt64*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestC), new Type[] { typeof(Vector256<UInt64>), typeof(Vector256<UInt64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.TestC(
+                _clsVar1,
+                _clsVar2
+            );
+
+            ValidateResult(_clsVar1, _clsVar2, result);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var left = Unsafe.Read<Vector256<UInt64>>(_dataTable.inArray1Ptr);
+            var right = Unsafe.Read<Vector256<UInt64>>(_dataTable.inArray2Ptr);
+            var result = Avx.TestC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var left = Avx.LoadVector256((UInt64*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadVector256((UInt64*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var left = Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new BooleanBinaryOpTest__TestCUInt64();
+            var result = Avx.TestC(test._fld1, test._fld2);
+
+            ValidateResult(test._fld1, test._fld2, result);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.TestC(_fld1, _fld2);
+
+            ValidateResult(_fld1, _fld2, result);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<UInt64> left, Vector256<UInt64> right, bool result, [CallerMemberName] string method = "")
+        {
+            UInt64[] inArray1 = new UInt64[Op1ElementCount];
+            UInt64[] inArray2 = new UInt64[Op2ElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
+            Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
+        {
+            UInt64[] inArray1 = new UInt64[Op1ElementCount];
+            UInt64[] inArray2 = new UInt64[Op2ElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(UInt64[] left, UInt64[] right, bool result, [CallerMemberName] string method = "")
+        {
+            var expectedResult = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult &= ((~left[i] & right[i]) == 0);
+            }
+
+            if (expectedResult != result)
+            {
+                Succeeded = false;
+
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.TestC)}<UInt64>(Vector256<UInt64>, Vector256<UInt64>): {method} failed:");
+                Console.WriteLine($"    left: ({string.Join(", ", left)})");
+                Console.WriteLine($"   right: ({string.Join(", ", right)})");
+                Console.WriteLine($"  result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Byte.cs
new file mode 100644 (file)
index 0000000..58232bc
--- /dev/null
@@ -0,0 +1,324 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void TestNotZAndNotCByte()
+        {
+            var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCByte();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class BooleanTwoComparisonOpTest__TestNotZAndNotCByte
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Byte);
+        private const int Op2ElementCount = VectorSize / sizeof(Byte);
+
+        private static Byte[] _data1 = new Byte[Op1ElementCount];
+        private static Byte[] _data2 = new Byte[Op2ElementCount];
+
+        private static Vector256<Byte> _clsVar1;
+        private static Vector256<Byte> _clsVar2;
+
+        private Vector256<Byte> _fld1;
+        private Vector256<Byte> _fld2;
+
+        private BooleanTwoComparisonOpTest__DataTable<Byte, Byte> _dataTable;
+
+        static BooleanTwoComparisonOpTest__TestNotZAndNotCByte()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
+        }
+
+        public BooleanTwoComparisonOpTest__TestNotZAndNotCByte()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+            _dataTable = new BooleanTwoComparisonOpTest__DataTable<Byte, Byte>(_data1, _data2, VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.TestNotZAndNotC(
+                Unsafe.Read<Vector256<Byte>>(_dataTable.inArray1Ptr),
+                Unsafe.Read<Vector256<Byte>>(_dataTable.inArray2Ptr)
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.TestNotZAndNotC(
+                Avx.LoadVector256((Byte*)(_dataTable.inArray1Ptr)),
+                Avx.LoadVector256((Byte*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.TestNotZAndNotC(
+                Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray1Ptr)),
+                Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256<Byte>), typeof(Vector256<Byte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Byte>>(_dataTable.inArray1Ptr),
+                                        Unsafe.Read<Vector256<Byte>>(_dataTable.inArray2Ptr)
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256<Byte>), typeof(Vector256<Byte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadVector256((Byte*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadVector256((Byte*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256<Byte>), typeof(Vector256<Byte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.TestNotZAndNotC(
+                _clsVar1,
+                _clsVar2
+            );
+
+            ValidateResult(_clsVar1, _clsVar2, result);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var left = Unsafe.Read<Vector256<Byte>>(_dataTable.inArray1Ptr);
+            var right = Unsafe.Read<Vector256<Byte>>(_dataTable.inArray2Ptr);
+            var result = Avx.TestNotZAndNotC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var left = Avx.LoadVector256((Byte*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadVector256((Byte*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestNotZAndNotC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var left = Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestNotZAndNotC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCByte();
+            var result = Avx.TestNotZAndNotC(test._fld1, test._fld2);
+
+            ValidateResult(test._fld1, test._fld2, result);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.TestNotZAndNotC(_fld1, _fld2);
+
+            ValidateResult(_fld1, _fld2, result);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Byte> left, Vector256<Byte> right, bool result, [CallerMemberName] string method = "")
+        {
+            Byte[] inArray1 = new Byte[Op1ElementCount];
+            Byte[] inArray2 = new Byte[Op2ElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
+            Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
+        {
+            Byte[] inArray1 = new Byte[Op1ElementCount];
+            Byte[] inArray2 = new Byte[Op2ElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(Byte[] left, Byte[] right, bool result, [CallerMemberName] string method = "")
+        {
+            var expectedResult1 = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult1 &= (((left[i] & right[i]) == 0));
+            }
+
+            var expectedResult2 = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult2 &= (((~left[i] & right[i]) == 0));
+            }
+
+            if (((expectedResult1 == false) && (expectedResult2 == false)) != result)
+            {
+                Succeeded = false;
+
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.TestNotZAndNotC)}<Byte>(Vector256<Byte>, Vector256<Byte>): {method} failed:");
+                Console.WriteLine($"    left: ({string.Join(", ", left)})");
+                Console.WriteLine($"   right: ({string.Join(", ", right)})");
+                Console.WriteLine($"  result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Int16.cs
new file mode 100644 (file)
index 0000000..ee4efaf
--- /dev/null
@@ -0,0 +1,324 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void TestNotZAndNotCInt16()
+        {
+            var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCInt16();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class BooleanTwoComparisonOpTest__TestNotZAndNotCInt16
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Int16);
+        private const int Op2ElementCount = VectorSize / sizeof(Int16);
+
+        private static Int16[] _data1 = new Int16[Op1ElementCount];
+        private static Int16[] _data2 = new Int16[Op2ElementCount];
+
+        private static Vector256<Int16> _clsVar1;
+        private static Vector256<Int16> _clsVar2;
+
+        private Vector256<Int16> _fld1;
+        private Vector256<Int16> _fld2;
+
+        private BooleanTwoComparisonOpTest__DataTable<Int16, Int16> _dataTable;
+
+        static BooleanTwoComparisonOpTest__TestNotZAndNotCInt16()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
+        }
+
+        public BooleanTwoComparisonOpTest__TestNotZAndNotCInt16()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+            _dataTable = new BooleanTwoComparisonOpTest__DataTable<Int16, Int16>(_data1, _data2, VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.TestNotZAndNotC(
+                Unsafe.Read<Vector256<Int16>>(_dataTable.inArray1Ptr),
+                Unsafe.Read<Vector256<Int16>>(_dataTable.inArray2Ptr)
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.TestNotZAndNotC(
+                Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)),
+                Avx.LoadVector256((Int16*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.TestNotZAndNotC(
+                Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)),
+                Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256<Int16>), typeof(Vector256<Int16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Int16>>(_dataTable.inArray1Ptr),
+                                        Unsafe.Read<Vector256<Int16>>(_dataTable.inArray2Ptr)
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256<Int16>), typeof(Vector256<Int16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadVector256((Int16*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256<Int16>), typeof(Vector256<Int16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.TestNotZAndNotC(
+                _clsVar1,
+                _clsVar2
+            );
+
+            ValidateResult(_clsVar1, _clsVar2, result);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var left = Unsafe.Read<Vector256<Int16>>(_dataTable.inArray1Ptr);
+            var right = Unsafe.Read<Vector256<Int16>>(_dataTable.inArray2Ptr);
+            var result = Avx.TestNotZAndNotC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var left = Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadVector256((Int16*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestNotZAndNotC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var left = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestNotZAndNotC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCInt16();
+            var result = Avx.TestNotZAndNotC(test._fld1, test._fld2);
+
+            ValidateResult(test._fld1, test._fld2, result);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.TestNotZAndNotC(_fld1, _fld2);
+
+            ValidateResult(_fld1, _fld2, result);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Int16> left, Vector256<Int16> right, bool result, [CallerMemberName] string method = "")
+        {
+            Int16[] inArray1 = new Int16[Op1ElementCount];
+            Int16[] inArray2 = new Int16[Op2ElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
+            Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
+        {
+            Int16[] inArray1 = new Int16[Op1ElementCount];
+            Int16[] inArray2 = new Int16[Op2ElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(Int16[] left, Int16[] right, bool result, [CallerMemberName] string method = "")
+        {
+            var expectedResult1 = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult1 &= (((left[i] & right[i]) == 0));
+            }
+
+            var expectedResult2 = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult2 &= (((~left[i] & right[i]) == 0));
+            }
+
+            if (((expectedResult1 == false) && (expectedResult2 == false)) != result)
+            {
+                Succeeded = false;
+
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.TestNotZAndNotC)}<Int16>(Vector256<Int16>, Vector256<Int16>): {method} failed:");
+                Console.WriteLine($"    left: ({string.Join(", ", left)})");
+                Console.WriteLine($"   right: ({string.Join(", ", right)})");
+                Console.WriteLine($"  result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Int32.cs
new file mode 100644 (file)
index 0000000..ffc8fe5
--- /dev/null
@@ -0,0 +1,324 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void TestNotZAndNotCInt32()
+        {
+            var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCInt32();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class BooleanTwoComparisonOpTest__TestNotZAndNotCInt32
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Int32);
+        private const int Op2ElementCount = VectorSize / sizeof(Int32);
+
+        private static Int32[] _data1 = new Int32[Op1ElementCount];
+        private static Int32[] _data2 = new Int32[Op2ElementCount];
+
+        private static Vector256<Int32> _clsVar1;
+        private static Vector256<Int32> _clsVar2;
+
+        private Vector256<Int32> _fld1;
+        private Vector256<Int32> _fld2;
+
+        private BooleanTwoComparisonOpTest__DataTable<Int32, Int32> _dataTable;
+
+        static BooleanTwoComparisonOpTest__TestNotZAndNotCInt32()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
+        }
+
+        public BooleanTwoComparisonOpTest__TestNotZAndNotCInt32()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+            _dataTable = new BooleanTwoComparisonOpTest__DataTable<Int32, Int32>(_data1, _data2, VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.TestNotZAndNotC(
+                Unsafe.Read<Vector256<Int32>>(_dataTable.inArray1Ptr),
+                Unsafe.Read<Vector256<Int32>>(_dataTable.inArray2Ptr)
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.TestNotZAndNotC(
+                Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)),
+                Avx.LoadVector256((Int32*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.TestNotZAndNotC(
+                Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)),
+                Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256<Int32>), typeof(Vector256<Int32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Int32>>(_dataTable.inArray1Ptr),
+                                        Unsafe.Read<Vector256<Int32>>(_dataTable.inArray2Ptr)
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256<Int32>), typeof(Vector256<Int32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadVector256((Int32*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256<Int32>), typeof(Vector256<Int32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.TestNotZAndNotC(
+                _clsVar1,
+                _clsVar2
+            );
+
+            ValidateResult(_clsVar1, _clsVar2, result);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var left = Unsafe.Read<Vector256<Int32>>(_dataTable.inArray1Ptr);
+            var right = Unsafe.Read<Vector256<Int32>>(_dataTable.inArray2Ptr);
+            var result = Avx.TestNotZAndNotC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var left = Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadVector256((Int32*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestNotZAndNotC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var left = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestNotZAndNotC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCInt32();
+            var result = Avx.TestNotZAndNotC(test._fld1, test._fld2);
+
+            ValidateResult(test._fld1, test._fld2, result);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.TestNotZAndNotC(_fld1, _fld2);
+
+            ValidateResult(_fld1, _fld2, result);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Int32> left, Vector256<Int32> right, bool result, [CallerMemberName] string method = "")
+        {
+            Int32[] inArray1 = new Int32[Op1ElementCount];
+            Int32[] inArray2 = new Int32[Op2ElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
+            Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
+        {
+            Int32[] inArray1 = new Int32[Op1ElementCount];
+            Int32[] inArray2 = new Int32[Op2ElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(Int32[] left, Int32[] right, bool result, [CallerMemberName] string method = "")
+        {
+            var expectedResult1 = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult1 &= (((left[i] & right[i]) == 0));
+            }
+
+            var expectedResult2 = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult2 &= (((~left[i] & right[i]) == 0));
+            }
+
+            if (((expectedResult1 == false) && (expectedResult2 == false)) != result)
+            {
+                Succeeded = false;
+
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.TestNotZAndNotC)}<Int32>(Vector256<Int32>, Vector256<Int32>): {method} failed:");
+                Console.WriteLine($"    left: ({string.Join(", ", left)})");
+                Console.WriteLine($"   right: ({string.Join(", ", right)})");
+                Console.WriteLine($"  result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.Int64.cs
new file mode 100644 (file)
index 0000000..abebb08
--- /dev/null
@@ -0,0 +1,324 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void TestNotZAndNotCInt64()
+        {
+            var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCInt64();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class BooleanTwoComparisonOpTest__TestNotZAndNotCInt64
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Int64);
+        private const int Op2ElementCount = VectorSize / sizeof(Int64);
+
+        private static Int64[] _data1 = new Int64[Op1ElementCount];
+        private static Int64[] _data2 = new Int64[Op2ElementCount];
+
+        private static Vector256<Int64> _clsVar1;
+        private static Vector256<Int64> _clsVar2;
+
+        private Vector256<Int64> _fld1;
+        private Vector256<Int64> _fld2;
+
+        private BooleanTwoComparisonOpTest__DataTable<Int64, Int64> _dataTable;
+
+        static BooleanTwoComparisonOpTest__TestNotZAndNotCInt64()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
+        }
+
+        public BooleanTwoComparisonOpTest__TestNotZAndNotCInt64()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+            _dataTable = new BooleanTwoComparisonOpTest__DataTable<Int64, Int64>(_data1, _data2, VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.TestNotZAndNotC(
+                Unsafe.Read<Vector256<Int64>>(_dataTable.inArray1Ptr),
+                Unsafe.Read<Vector256<Int64>>(_dataTable.inArray2Ptr)
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.TestNotZAndNotC(
+                Avx.LoadVector256((Int64*)(_dataTable.inArray1Ptr)),
+                Avx.LoadVector256((Int64*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.TestNotZAndNotC(
+                Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray1Ptr)),
+                Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256<Int64>), typeof(Vector256<Int64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Int64>>(_dataTable.inArray1Ptr),
+                                        Unsafe.Read<Vector256<Int64>>(_dataTable.inArray2Ptr)
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256<Int64>), typeof(Vector256<Int64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadVector256((Int64*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadVector256((Int64*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256<Int64>), typeof(Vector256<Int64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.TestNotZAndNotC(
+                _clsVar1,
+                _clsVar2
+            );
+
+            ValidateResult(_clsVar1, _clsVar2, result);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var left = Unsafe.Read<Vector256<Int64>>(_dataTable.inArray1Ptr);
+            var right = Unsafe.Read<Vector256<Int64>>(_dataTable.inArray2Ptr);
+            var result = Avx.TestNotZAndNotC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var left = Avx.LoadVector256((Int64*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadVector256((Int64*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestNotZAndNotC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var left = Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestNotZAndNotC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCInt64();
+            var result = Avx.TestNotZAndNotC(test._fld1, test._fld2);
+
+            ValidateResult(test._fld1, test._fld2, result);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.TestNotZAndNotC(_fld1, _fld2);
+
+            ValidateResult(_fld1, _fld2, result);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Int64> left, Vector256<Int64> right, bool result, [CallerMemberName] string method = "")
+        {
+            Int64[] inArray1 = new Int64[Op1ElementCount];
+            Int64[] inArray2 = new Int64[Op2ElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
+            Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
+        {
+            Int64[] inArray1 = new Int64[Op1ElementCount];
+            Int64[] inArray2 = new Int64[Op2ElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(Int64[] left, Int64[] right, bool result, [CallerMemberName] string method = "")
+        {
+            var expectedResult1 = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult1 &= (((left[i] & right[i]) == 0));
+            }
+
+            var expectedResult2 = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult2 &= (((~left[i] & right[i]) == 0));
+            }
+
+            if (((expectedResult1 == false) && (expectedResult2 == false)) != result)
+            {
+                Succeeded = false;
+
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.TestNotZAndNotC)}<Int64>(Vector256<Int64>, Vector256<Int64>): {method} failed:");
+                Console.WriteLine($"    left: ({string.Join(", ", left)})");
+                Console.WriteLine($"   right: ({string.Join(", ", right)})");
+                Console.WriteLine($"  result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.SByte.cs
new file mode 100644 (file)
index 0000000..3d967a4
--- /dev/null
@@ -0,0 +1,324 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void TestNotZAndNotCSByte()
+        {
+            var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCSByte();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class BooleanTwoComparisonOpTest__TestNotZAndNotCSByte
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(SByte);
+        private const int Op2ElementCount = VectorSize / sizeof(SByte);
+
+        private static SByte[] _data1 = new SByte[Op1ElementCount];
+        private static SByte[] _data2 = new SByte[Op2ElementCount];
+
+        private static Vector256<SByte> _clsVar1;
+        private static Vector256<SByte> _clsVar2;
+
+        private Vector256<SByte> _fld1;
+        private Vector256<SByte> _fld2;
+
+        private BooleanTwoComparisonOpTest__DataTable<SByte, SByte> _dataTable;
+
+        static BooleanTwoComparisonOpTest__TestNotZAndNotCSByte()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
+        }
+
+        public BooleanTwoComparisonOpTest__TestNotZAndNotCSByte()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+            _dataTable = new BooleanTwoComparisonOpTest__DataTable<SByte, SByte>(_data1, _data2, VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.TestNotZAndNotC(
+                Unsafe.Read<Vector256<SByte>>(_dataTable.inArray1Ptr),
+                Unsafe.Read<Vector256<SByte>>(_dataTable.inArray2Ptr)
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.TestNotZAndNotC(
+                Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)),
+                Avx.LoadVector256((SByte*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.TestNotZAndNotC(
+                Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)),
+                Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256<SByte>), typeof(Vector256<SByte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<SByte>>(_dataTable.inArray1Ptr),
+                                        Unsafe.Read<Vector256<SByte>>(_dataTable.inArray2Ptr)
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256<SByte>), typeof(Vector256<SByte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadVector256((SByte*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256<SByte>), typeof(Vector256<SByte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.TestNotZAndNotC(
+                _clsVar1,
+                _clsVar2
+            );
+
+            ValidateResult(_clsVar1, _clsVar2, result);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var left = Unsafe.Read<Vector256<SByte>>(_dataTable.inArray1Ptr);
+            var right = Unsafe.Read<Vector256<SByte>>(_dataTable.inArray2Ptr);
+            var result = Avx.TestNotZAndNotC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var left = Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadVector256((SByte*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestNotZAndNotC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var left = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestNotZAndNotC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCSByte();
+            var result = Avx.TestNotZAndNotC(test._fld1, test._fld2);
+
+            ValidateResult(test._fld1, test._fld2, result);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.TestNotZAndNotC(_fld1, _fld2);
+
+            ValidateResult(_fld1, _fld2, result);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<SByte> left, Vector256<SByte> right, bool result, [CallerMemberName] string method = "")
+        {
+            SByte[] inArray1 = new SByte[Op1ElementCount];
+            SByte[] inArray2 = new SByte[Op2ElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
+            Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
+        {
+            SByte[] inArray1 = new SByte[Op1ElementCount];
+            SByte[] inArray2 = new SByte[Op2ElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(SByte[] left, SByte[] right, bool result, [CallerMemberName] string method = "")
+        {
+            var expectedResult1 = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult1 &= (((left[i] & right[i]) == 0));
+            }
+
+            var expectedResult2 = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult2 &= (((~left[i] & right[i]) == 0));
+            }
+
+            if (((expectedResult1 == false) && (expectedResult2 == false)) != result)
+            {
+                Succeeded = false;
+
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.TestNotZAndNotC)}<SByte>(Vector256<SByte>, Vector256<SByte>): {method} failed:");
+                Console.WriteLine($"    left: ({string.Join(", ", left)})");
+                Console.WriteLine($"   right: ({string.Join(", ", right)})");
+                Console.WriteLine($"  result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.UInt16.cs
new file mode 100644 (file)
index 0000000..d82ff7f
--- /dev/null
@@ -0,0 +1,324 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void TestNotZAndNotCUInt16()
+        {
+            var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCUInt16();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class BooleanTwoComparisonOpTest__TestNotZAndNotCUInt16
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+        private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+
+        private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+        private static UInt16[] _data2 = new UInt16[Op2ElementCount];
+
+        private static Vector256<UInt16> _clsVar1;
+        private static Vector256<UInt16> _clsVar2;
+
+        private Vector256<UInt16> _fld1;
+        private Vector256<UInt16> _fld2;
+
+        private BooleanTwoComparisonOpTest__DataTable<UInt16, UInt16> _dataTable;
+
+        static BooleanTwoComparisonOpTest__TestNotZAndNotCUInt16()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
+        }
+
+        public BooleanTwoComparisonOpTest__TestNotZAndNotCUInt16()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _fld1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+            _dataTable = new BooleanTwoComparisonOpTest__DataTable<UInt16, UInt16>(_data1, _data2, VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.TestNotZAndNotC(
+                Unsafe.Read<Vector256<UInt16>>(_dataTable.inArray1Ptr),
+                Unsafe.Read<Vector256<UInt16>>(_dataTable.inArray2Ptr)
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.TestNotZAndNotC(
+                Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)),
+                Avx.LoadVector256((UInt16*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.TestNotZAndNotC(
+                Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)),
+                Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256<UInt16>), typeof(Vector256<UInt16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<UInt16>>(_dataTable.inArray1Ptr),
+                                        Unsafe.Read<Vector256<UInt16>>(_dataTable.inArray2Ptr)
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256<UInt16>), typeof(Vector256<UInt16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadVector256((UInt16*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256<UInt16>), typeof(Vector256<UInt16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.TestNotZAndNotC(
+                _clsVar1,
+                _clsVar2
+            );
+
+            ValidateResult(_clsVar1, _clsVar2, result);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var left = Unsafe.Read<Vector256<UInt16>>(_dataTable.inArray1Ptr);
+            var right = Unsafe.Read<Vector256<UInt16>>(_dataTable.inArray2Ptr);
+            var result = Avx.TestNotZAndNotC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var left = Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadVector256((UInt16*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestNotZAndNotC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var left = Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestNotZAndNotC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCUInt16();
+            var result = Avx.TestNotZAndNotC(test._fld1, test._fld2);
+
+            ValidateResult(test._fld1, test._fld2, result);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.TestNotZAndNotC(_fld1, _fld2);
+
+            ValidateResult(_fld1, _fld2, result);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<UInt16> left, Vector256<UInt16> right, bool result, [CallerMemberName] string method = "")
+        {
+            UInt16[] inArray1 = new UInt16[Op1ElementCount];
+            UInt16[] inArray2 = new UInt16[Op2ElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
+            Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
+        {
+            UInt16[] inArray1 = new UInt16[Op1ElementCount];
+            UInt16[] inArray2 = new UInt16[Op2ElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(UInt16[] left, UInt16[] right, bool result, [CallerMemberName] string method = "")
+        {
+            var expectedResult1 = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult1 &= (((left[i] & right[i]) == 0));
+            }
+
+            var expectedResult2 = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult2 &= (((~left[i] & right[i]) == 0));
+            }
+
+            if (((expectedResult1 == false) && (expectedResult2 == false)) != result)
+            {
+                Succeeded = false;
+
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.TestNotZAndNotC)}<UInt16>(Vector256<UInt16>, Vector256<UInt16>): {method} failed:");
+                Console.WriteLine($"    left: ({string.Join(", ", left)})");
+                Console.WriteLine($"   right: ({string.Join(", ", right)})");
+                Console.WriteLine($"  result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.UInt32.cs
new file mode 100644 (file)
index 0000000..da6beba
--- /dev/null
@@ -0,0 +1,324 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void TestNotZAndNotCUInt32()
+        {
+            var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCUInt32();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class BooleanTwoComparisonOpTest__TestNotZAndNotCUInt32
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+        private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+
+        private static UInt32[] _data1 = new UInt32[Op1ElementCount];
+        private static UInt32[] _data2 = new UInt32[Op2ElementCount];
+
+        private static Vector256<UInt32> _clsVar1;
+        private static Vector256<UInt32> _clsVar2;
+
+        private Vector256<UInt32> _fld1;
+        private Vector256<UInt32> _fld2;
+
+        private BooleanTwoComparisonOpTest__DataTable<UInt32, UInt32> _dataTable;
+
+        static BooleanTwoComparisonOpTest__TestNotZAndNotCUInt32()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
+        }
+
+        public BooleanTwoComparisonOpTest__TestNotZAndNotCUInt32()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+            _dataTable = new BooleanTwoComparisonOpTest__DataTable<UInt32, UInt32>(_data1, _data2, VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.TestNotZAndNotC(
+                Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray1Ptr),
+                Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray2Ptr)
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.TestNotZAndNotC(
+                Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)),
+                Avx.LoadVector256((UInt32*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.TestNotZAndNotC(
+                Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)),
+                Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256<UInt32>), typeof(Vector256<UInt32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray1Ptr),
+                                        Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray2Ptr)
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256<UInt32>), typeof(Vector256<UInt32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadVector256((UInt32*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256<UInt32>), typeof(Vector256<UInt32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.TestNotZAndNotC(
+                _clsVar1,
+                _clsVar2
+            );
+
+            ValidateResult(_clsVar1, _clsVar2, result);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var left = Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray1Ptr);
+            var right = Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray2Ptr);
+            var result = Avx.TestNotZAndNotC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var left = Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadVector256((UInt32*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestNotZAndNotC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var left = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestNotZAndNotC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCUInt32();
+            var result = Avx.TestNotZAndNotC(test._fld1, test._fld2);
+
+            ValidateResult(test._fld1, test._fld2, result);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.TestNotZAndNotC(_fld1, _fld2);
+
+            ValidateResult(_fld1, _fld2, result);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<UInt32> left, Vector256<UInt32> right, bool result, [CallerMemberName] string method = "")
+        {
+            UInt32[] inArray1 = new UInt32[Op1ElementCount];
+            UInt32[] inArray2 = new UInt32[Op2ElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
+            Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
+        {
+            UInt32[] inArray1 = new UInt32[Op1ElementCount];
+            UInt32[] inArray2 = new UInt32[Op2ElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(UInt32[] left, UInt32[] right, bool result, [CallerMemberName] string method = "")
+        {
+            var expectedResult1 = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult1 &= (((left[i] & right[i]) == 0));
+            }
+
+            var expectedResult2 = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult2 &= (((~left[i] & right[i]) == 0));
+            }
+
+            if (((expectedResult1 == false) && (expectedResult2 == false)) != result)
+            {
+                Succeeded = false;
+
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.TestNotZAndNotC)}<UInt32>(Vector256<UInt32>, Vector256<UInt32>): {method} failed:");
+                Console.WriteLine($"    left: ({string.Join(", ", left)})");
+                Console.WriteLine($"   right: ({string.Join(", ", right)})");
+                Console.WriteLine($"  result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestNotZAndNotC.UInt64.cs
new file mode 100644 (file)
index 0000000..aeeb848
--- /dev/null
@@ -0,0 +1,324 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void TestNotZAndNotCUInt64()
+        {
+            var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCUInt64();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class BooleanTwoComparisonOpTest__TestNotZAndNotCUInt64
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+        private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+
+        private static UInt64[] _data1 = new UInt64[Op1ElementCount];
+        private static UInt64[] _data2 = new UInt64[Op2ElementCount];
+
+        private static Vector256<UInt64> _clsVar1;
+        private static Vector256<UInt64> _clsVar2;
+
+        private Vector256<UInt64> _fld1;
+        private Vector256<UInt64> _fld2;
+
+        private BooleanTwoComparisonOpTest__DataTable<UInt64, UInt64> _dataTable;
+
+        static BooleanTwoComparisonOpTest__TestNotZAndNotCUInt64()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
+        }
+
+        public BooleanTwoComparisonOpTest__TestNotZAndNotCUInt64()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+            _dataTable = new BooleanTwoComparisonOpTest__DataTable<UInt64, UInt64>(_data1, _data2, VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.TestNotZAndNotC(
+                Unsafe.Read<Vector256<UInt64>>(_dataTable.inArray1Ptr),
+                Unsafe.Read<Vector256<UInt64>>(_dataTable.inArray2Ptr)
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.TestNotZAndNotC(
+                Avx.LoadVector256((UInt64*)(_dataTable.inArray1Ptr)),
+                Avx.LoadVector256((UInt64*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.TestNotZAndNotC(
+                Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray1Ptr)),
+                Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256<UInt64>), typeof(Vector256<UInt64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<UInt64>>(_dataTable.inArray1Ptr),
+                                        Unsafe.Read<Vector256<UInt64>>(_dataTable.inArray2Ptr)
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256<UInt64>), typeof(Vector256<UInt64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadVector256((UInt64*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadVector256((UInt64*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {var method = typeof(Avx).GetMethod(nameof(Avx.TestNotZAndNotC), new Type[] { typeof(Vector256<UInt64>), typeof(Vector256<UInt64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.TestNotZAndNotC(
+                _clsVar1,
+                _clsVar2
+            );
+
+            ValidateResult(_clsVar1, _clsVar2, result);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var left = Unsafe.Read<Vector256<UInt64>>(_dataTable.inArray1Ptr);
+            var right = Unsafe.Read<Vector256<UInt64>>(_dataTable.inArray2Ptr);
+            var result = Avx.TestNotZAndNotC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var left = Avx.LoadVector256((UInt64*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadVector256((UInt64*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestNotZAndNotC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var left = Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestNotZAndNotC(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new BooleanTwoComparisonOpTest__TestNotZAndNotCUInt64();
+            var result = Avx.TestNotZAndNotC(test._fld1, test._fld2);
+
+            ValidateResult(test._fld1, test._fld2, result);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.TestNotZAndNotC(_fld1, _fld2);
+
+            ValidateResult(_fld1, _fld2, result);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<UInt64> left, Vector256<UInt64> right, bool result, [CallerMemberName] string method = "")
+        {
+            UInt64[] inArray1 = new UInt64[Op1ElementCount];
+            UInt64[] inArray2 = new UInt64[Op2ElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
+            Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
+        {
+            UInt64[] inArray1 = new UInt64[Op1ElementCount];
+            UInt64[] inArray2 = new UInt64[Op2ElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(UInt64[] left, UInt64[] right, bool result, [CallerMemberName] string method = "")
+        {
+            var expectedResult1 = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult1 &= (((left[i] & right[i]) == 0));
+            }
+
+            var expectedResult2 = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult2 &= (((~left[i] & right[i]) == 0));
+            }
+
+            if (((expectedResult1 == false) && (expectedResult2 == false)) != result)
+            {
+                Succeeded = false;
+
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.TestNotZAndNotC)}<UInt64>(Vector256<UInt64>, Vector256<UInt64>): {method} failed:");
+                Console.WriteLine($"    left: ({string.Join(", ", left)})");
+                Console.WriteLine($"   right: ({string.Join(", ", right)})");
+                Console.WriteLine($"  result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Byte.cs
new file mode 100644 (file)
index 0000000..bdf04e5
--- /dev/null
@@ -0,0 +1,318 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void TestZByte()
+        {
+            var test = new BooleanBinaryOpTest__TestZByte();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class BooleanBinaryOpTest__TestZByte
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Byte);
+        private const int Op2ElementCount = VectorSize / sizeof(Byte);
+
+        private static Byte[] _data1 = new Byte[Op1ElementCount];
+        private static Byte[] _data2 = new Byte[Op2ElementCount];
+
+        private static Vector256<Byte> _clsVar1;
+        private static Vector256<Byte> _clsVar2;
+
+        private Vector256<Byte> _fld1;
+        private Vector256<Byte> _fld2;
+
+        private BooleanBinaryOpTest__DataTable<Byte, Byte> _dataTable;
+
+        static BooleanBinaryOpTest__TestZByte()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
+        }
+
+        public BooleanBinaryOpTest__TestZByte()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld1), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+            _dataTable = new BooleanBinaryOpTest__DataTable<Byte, Byte>(_data1, _data2, VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.TestZ(
+                Unsafe.Read<Vector256<Byte>>(_dataTable.inArray1Ptr),
+                Unsafe.Read<Vector256<Byte>>(_dataTable.inArray2Ptr)
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.TestZ(
+                Avx.LoadVector256((Byte*)(_dataTable.inArray1Ptr)),
+                Avx.LoadVector256((Byte*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.TestZ(
+                Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray1Ptr)),
+                Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256<Byte>), typeof(Vector256<Byte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Byte>>(_dataTable.inArray1Ptr),
+                                        Unsafe.Read<Vector256<Byte>>(_dataTable.inArray2Ptr)
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256<Byte>), typeof(Vector256<Byte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadVector256((Byte*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadVector256((Byte*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256<Byte>), typeof(Vector256<Byte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.TestZ(
+                _clsVar1,
+                _clsVar2
+            );
+
+            ValidateResult(_clsVar1, _clsVar2, result);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var left = Unsafe.Read<Vector256<Byte>>(_dataTable.inArray1Ptr);
+            var right = Unsafe.Read<Vector256<Byte>>(_dataTable.inArray2Ptr);
+            var result = Avx.TestZ(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var left = Avx.LoadVector256((Byte*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadVector256((Byte*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestZ(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var left = Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadAlignedVector256((Byte*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestZ(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new BooleanBinaryOpTest__TestZByte();
+            var result = Avx.TestZ(test._fld1, test._fld2);
+
+            ValidateResult(test._fld1, test._fld2, result);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.TestZ(_fld1, _fld2);
+
+            ValidateResult(_fld1, _fld2, result);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Byte> left, Vector256<Byte> right, bool result, [CallerMemberName] string method = "")
+        {
+            Byte[] inArray1 = new Byte[Op1ElementCount];
+            Byte[] inArray2 = new Byte[Op2ElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
+            Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
+        {
+            Byte[] inArray1 = new Byte[Op1ElementCount];
+            Byte[] inArray2 = new Byte[Op2ElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(Byte[] left, Byte[] right, bool result, [CallerMemberName] string method = "")
+        {
+            var expectedResult = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult &= ((left[i] & right[i]) == 0);
+            }
+
+            if (expectedResult != result)
+            {
+                Succeeded = false;
+
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.TestZ)}<Byte>(Vector256<Byte>, Vector256<Byte>): {method} failed:");
+                Console.WriteLine($"    left: ({string.Join(", ", left)})");
+                Console.WriteLine($"   right: ({string.Join(", ", right)})");
+                Console.WriteLine($"  result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Int16.cs
new file mode 100644 (file)
index 0000000..f347e27
--- /dev/null
@@ -0,0 +1,318 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void TestZInt16()
+        {
+            var test = new BooleanBinaryOpTest__TestZInt16();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class BooleanBinaryOpTest__TestZInt16
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Int16);
+        private const int Op2ElementCount = VectorSize / sizeof(Int16);
+
+        private static Int16[] _data1 = new Int16[Op1ElementCount];
+        private static Int16[] _data2 = new Int16[Op2ElementCount];
+
+        private static Vector256<Int16> _clsVar1;
+        private static Vector256<Int16> _clsVar2;
+
+        private Vector256<Int16> _fld1;
+        private Vector256<Int16> _fld2;
+
+        private BooleanBinaryOpTest__DataTable<Int16, Int16> _dataTable;
+
+        static BooleanBinaryOpTest__TestZInt16()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
+        }
+
+        public BooleanBinaryOpTest__TestZInt16()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _fld1), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+            _dataTable = new BooleanBinaryOpTest__DataTable<Int16, Int16>(_data1, _data2, VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.TestZ(
+                Unsafe.Read<Vector256<Int16>>(_dataTable.inArray1Ptr),
+                Unsafe.Read<Vector256<Int16>>(_dataTable.inArray2Ptr)
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.TestZ(
+                Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)),
+                Avx.LoadVector256((Int16*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.TestZ(
+                Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)),
+                Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256<Int16>), typeof(Vector256<Int16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Int16>>(_dataTable.inArray1Ptr),
+                                        Unsafe.Read<Vector256<Int16>>(_dataTable.inArray2Ptr)
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256<Int16>), typeof(Vector256<Int16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadVector256((Int16*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256<Int16>), typeof(Vector256<Int16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.TestZ(
+                _clsVar1,
+                _clsVar2
+            );
+
+            ValidateResult(_clsVar1, _clsVar2, result);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var left = Unsafe.Read<Vector256<Int16>>(_dataTable.inArray1Ptr);
+            var right = Unsafe.Read<Vector256<Int16>>(_dataTable.inArray2Ptr);
+            var result = Avx.TestZ(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var left = Avx.LoadVector256((Int16*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadVector256((Int16*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestZ(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var left = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadAlignedVector256((Int16*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestZ(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new BooleanBinaryOpTest__TestZInt16();
+            var result = Avx.TestZ(test._fld1, test._fld2);
+
+            ValidateResult(test._fld1, test._fld2, result);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.TestZ(_fld1, _fld2);
+
+            ValidateResult(_fld1, _fld2, result);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Int16> left, Vector256<Int16> right, bool result, [CallerMemberName] string method = "")
+        {
+            Int16[] inArray1 = new Int16[Op1ElementCount];
+            Int16[] inArray2 = new Int16[Op2ElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
+            Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
+        {
+            Int16[] inArray1 = new Int16[Op1ElementCount];
+            Int16[] inArray2 = new Int16[Op2ElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(Int16[] left, Int16[] right, bool result, [CallerMemberName] string method = "")
+        {
+            var expectedResult = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult &= ((left[i] & right[i]) == 0);
+            }
+
+            if (expectedResult != result)
+            {
+                Succeeded = false;
+
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.TestZ)}<Int16>(Vector256<Int16>, Vector256<Int16>): {method} failed:");
+                Console.WriteLine($"    left: ({string.Join(", ", left)})");
+                Console.WriteLine($"   right: ({string.Join(", ", right)})");
+                Console.WriteLine($"  result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Int32.cs
new file mode 100644 (file)
index 0000000..13983af
--- /dev/null
@@ -0,0 +1,318 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void TestZInt32()
+        {
+            var test = new BooleanBinaryOpTest__TestZInt32();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class BooleanBinaryOpTest__TestZInt32
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Int32);
+        private const int Op2ElementCount = VectorSize / sizeof(Int32);
+
+        private static Int32[] _data1 = new Int32[Op1ElementCount];
+        private static Int32[] _data2 = new Int32[Op2ElementCount];
+
+        private static Vector256<Int32> _clsVar1;
+        private static Vector256<Int32> _clsVar2;
+
+        private Vector256<Int32> _fld1;
+        private Vector256<Int32> _fld2;
+
+        private BooleanBinaryOpTest__DataTable<Int32, Int32> _dataTable;
+
+        static BooleanBinaryOpTest__TestZInt32()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
+        }
+
+        public BooleanBinaryOpTest__TestZInt32()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _fld1), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+            _dataTable = new BooleanBinaryOpTest__DataTable<Int32, Int32>(_data1, _data2, VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.TestZ(
+                Unsafe.Read<Vector256<Int32>>(_dataTable.inArray1Ptr),
+                Unsafe.Read<Vector256<Int32>>(_dataTable.inArray2Ptr)
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.TestZ(
+                Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)),
+                Avx.LoadVector256((Int32*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.TestZ(
+                Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)),
+                Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256<Int32>), typeof(Vector256<Int32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Int32>>(_dataTable.inArray1Ptr),
+                                        Unsafe.Read<Vector256<Int32>>(_dataTable.inArray2Ptr)
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256<Int32>), typeof(Vector256<Int32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadVector256((Int32*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256<Int32>), typeof(Vector256<Int32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.TestZ(
+                _clsVar1,
+                _clsVar2
+            );
+
+            ValidateResult(_clsVar1, _clsVar2, result);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var left = Unsafe.Read<Vector256<Int32>>(_dataTable.inArray1Ptr);
+            var right = Unsafe.Read<Vector256<Int32>>(_dataTable.inArray2Ptr);
+            var result = Avx.TestZ(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var left = Avx.LoadVector256((Int32*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadVector256((Int32*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestZ(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var left = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadAlignedVector256((Int32*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestZ(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new BooleanBinaryOpTest__TestZInt32();
+            var result = Avx.TestZ(test._fld1, test._fld2);
+
+            ValidateResult(test._fld1, test._fld2, result);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.TestZ(_fld1, _fld2);
+
+            ValidateResult(_fld1, _fld2, result);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Int32> left, Vector256<Int32> right, bool result, [CallerMemberName] string method = "")
+        {
+            Int32[] inArray1 = new Int32[Op1ElementCount];
+            Int32[] inArray2 = new Int32[Op2ElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
+            Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
+        {
+            Int32[] inArray1 = new Int32[Op1ElementCount];
+            Int32[] inArray2 = new Int32[Op2ElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(Int32[] left, Int32[] right, bool result, [CallerMemberName] string method = "")
+        {
+            var expectedResult = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult &= ((left[i] & right[i]) == 0);
+            }
+
+            if (expectedResult != result)
+            {
+                Succeeded = false;
+
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.TestZ)}<Int32>(Vector256<Int32>, Vector256<Int32>): {method} failed:");
+                Console.WriteLine($"    left: ({string.Join(", ", left)})");
+                Console.WriteLine($"   right: ({string.Join(", ", right)})");
+                Console.WriteLine($"  result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.Int64.cs
new file mode 100644 (file)
index 0000000..746ae11
--- /dev/null
@@ -0,0 +1,318 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void TestZInt64()
+        {
+            var test = new BooleanBinaryOpTest__TestZInt64();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class BooleanBinaryOpTest__TestZInt64
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(Int64);
+        private const int Op2ElementCount = VectorSize / sizeof(Int64);
+
+        private static Int64[] _data1 = new Int64[Op1ElementCount];
+        private static Int64[] _data2 = new Int64[Op2ElementCount];
+
+        private static Vector256<Int64> _clsVar1;
+        private static Vector256<Int64> _clsVar2;
+
+        private Vector256<Int64> _fld1;
+        private Vector256<Int64> _fld2;
+
+        private BooleanBinaryOpTest__DataTable<Int64, Int64> _dataTable;
+
+        static BooleanBinaryOpTest__TestZInt64()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
+        }
+
+        public BooleanBinaryOpTest__TestZInt64()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld1), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+            _dataTable = new BooleanBinaryOpTest__DataTable<Int64, Int64>(_data1, _data2, VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.TestZ(
+                Unsafe.Read<Vector256<Int64>>(_dataTable.inArray1Ptr),
+                Unsafe.Read<Vector256<Int64>>(_dataTable.inArray2Ptr)
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.TestZ(
+                Avx.LoadVector256((Int64*)(_dataTable.inArray1Ptr)),
+                Avx.LoadVector256((Int64*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.TestZ(
+                Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray1Ptr)),
+                Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256<Int64>), typeof(Vector256<Int64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<Int64>>(_dataTable.inArray1Ptr),
+                                        Unsafe.Read<Vector256<Int64>>(_dataTable.inArray2Ptr)
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256<Int64>), typeof(Vector256<Int64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadVector256((Int64*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadVector256((Int64*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256<Int64>), typeof(Vector256<Int64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.TestZ(
+                _clsVar1,
+                _clsVar2
+            );
+
+            ValidateResult(_clsVar1, _clsVar2, result);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var left = Unsafe.Read<Vector256<Int64>>(_dataTable.inArray1Ptr);
+            var right = Unsafe.Read<Vector256<Int64>>(_dataTable.inArray2Ptr);
+            var result = Avx.TestZ(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var left = Avx.LoadVector256((Int64*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadVector256((Int64*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestZ(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var left = Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadAlignedVector256((Int64*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestZ(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new BooleanBinaryOpTest__TestZInt64();
+            var result = Avx.TestZ(test._fld1, test._fld2);
+
+            ValidateResult(test._fld1, test._fld2, result);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.TestZ(_fld1, _fld2);
+
+            ValidateResult(_fld1, _fld2, result);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<Int64> left, Vector256<Int64> right, bool result, [CallerMemberName] string method = "")
+        {
+            Int64[] inArray1 = new Int64[Op1ElementCount];
+            Int64[] inArray2 = new Int64[Op2ElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
+            Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
+        {
+            Int64[] inArray1 = new Int64[Op1ElementCount];
+            Int64[] inArray2 = new Int64[Op2ElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Int64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(Int64[] left, Int64[] right, bool result, [CallerMemberName] string method = "")
+        {
+            var expectedResult = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult &= ((left[i] & right[i]) == 0);
+            }
+
+            if (expectedResult != result)
+            {
+                Succeeded = false;
+
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.TestZ)}<Int64>(Vector256<Int64>, Vector256<Int64>): {method} failed:");
+                Console.WriteLine($"    left: ({string.Join(", ", left)})");
+                Console.WriteLine($"   right: ({string.Join(", ", right)})");
+                Console.WriteLine($"  result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.SByte.cs
new file mode 100644 (file)
index 0000000..408ff47
--- /dev/null
@@ -0,0 +1,318 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void TestZSByte()
+        {
+            var test = new BooleanBinaryOpTest__TestZSByte();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class BooleanBinaryOpTest__TestZSByte
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(SByte);
+        private const int Op2ElementCount = VectorSize / sizeof(SByte);
+
+        private static SByte[] _data1 = new SByte[Op1ElementCount];
+        private static SByte[] _data2 = new SByte[Op2ElementCount];
+
+        private static Vector256<SByte> _clsVar1;
+        private static Vector256<SByte> _clsVar2;
+
+        private Vector256<SByte> _fld1;
+        private Vector256<SByte> _fld2;
+
+        private BooleanBinaryOpTest__DataTable<SByte, SByte> _dataTable;
+
+        static BooleanBinaryOpTest__TestZSByte()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
+        }
+
+        public BooleanBinaryOpTest__TestZSByte()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld1), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+            _dataTable = new BooleanBinaryOpTest__DataTable<SByte, SByte>(_data1, _data2, VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.TestZ(
+                Unsafe.Read<Vector256<SByte>>(_dataTable.inArray1Ptr),
+                Unsafe.Read<Vector256<SByte>>(_dataTable.inArray2Ptr)
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.TestZ(
+                Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)),
+                Avx.LoadVector256((SByte*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.TestZ(
+                Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)),
+                Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256<SByte>), typeof(Vector256<SByte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<SByte>>(_dataTable.inArray1Ptr),
+                                        Unsafe.Read<Vector256<SByte>>(_dataTable.inArray2Ptr)
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256<SByte>), typeof(Vector256<SByte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadVector256((SByte*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256<SByte>), typeof(Vector256<SByte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.TestZ(
+                _clsVar1,
+                _clsVar2
+            );
+
+            ValidateResult(_clsVar1, _clsVar2, result);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var left = Unsafe.Read<Vector256<SByte>>(_dataTable.inArray1Ptr);
+            var right = Unsafe.Read<Vector256<SByte>>(_dataTable.inArray2Ptr);
+            var result = Avx.TestZ(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var left = Avx.LoadVector256((SByte*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadVector256((SByte*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestZ(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var left = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadAlignedVector256((SByte*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestZ(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new BooleanBinaryOpTest__TestZSByte();
+            var result = Avx.TestZ(test._fld1, test._fld2);
+
+            ValidateResult(test._fld1, test._fld2, result);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.TestZ(_fld1, _fld2);
+
+            ValidateResult(_fld1, _fld2, result);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<SByte> left, Vector256<SByte> right, bool result, [CallerMemberName] string method = "")
+        {
+            SByte[] inArray1 = new SByte[Op1ElementCount];
+            SByte[] inArray2 = new SByte[Op2ElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
+            Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
+        {
+            SByte[] inArray1 = new SByte[Op1ElementCount];
+            SByte[] inArray2 = new SByte[Op2ElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(SByte[] left, SByte[] right, bool result, [CallerMemberName] string method = "")
+        {
+            var expectedResult = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult &= ((left[i] & right[i]) == 0);
+            }
+
+            if (expectedResult != result)
+            {
+                Succeeded = false;
+
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.TestZ)}<SByte>(Vector256<SByte>, Vector256<SByte>): {method} failed:");
+                Console.WriteLine($"    left: ({string.Join(", ", left)})");
+                Console.WriteLine($"   right: ({string.Join(", ", right)})");
+                Console.WriteLine($"  result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.UInt16.cs
new file mode 100644 (file)
index 0000000..d62277c
--- /dev/null
@@ -0,0 +1,318 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void TestZUInt16()
+        {
+            var test = new BooleanBinaryOpTest__TestZUInt16();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class BooleanBinaryOpTest__TestZUInt16
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+        private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+
+        private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+        private static UInt16[] _data2 = new UInt16[Op2ElementCount];
+
+        private static Vector256<UInt16> _clsVar1;
+        private static Vector256<UInt16> _clsVar2;
+
+        private Vector256<UInt16> _fld1;
+        private Vector256<UInt16> _fld2;
+
+        private BooleanBinaryOpTest__DataTable<UInt16, UInt16> _dataTable;
+
+        static BooleanBinaryOpTest__TestZUInt16()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
+        }
+
+        public BooleanBinaryOpTest__TestZUInt16()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _fld1), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+            _dataTable = new BooleanBinaryOpTest__DataTable<UInt16, UInt16>(_data1, _data2, VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.TestZ(
+                Unsafe.Read<Vector256<UInt16>>(_dataTable.inArray1Ptr),
+                Unsafe.Read<Vector256<UInt16>>(_dataTable.inArray2Ptr)
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.TestZ(
+                Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)),
+                Avx.LoadVector256((UInt16*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.TestZ(
+                Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)),
+                Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256<UInt16>), typeof(Vector256<UInt16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<UInt16>>(_dataTable.inArray1Ptr),
+                                        Unsafe.Read<Vector256<UInt16>>(_dataTable.inArray2Ptr)
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256<UInt16>), typeof(Vector256<UInt16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadVector256((UInt16*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256<UInt16>), typeof(Vector256<UInt16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.TestZ(
+                _clsVar1,
+                _clsVar2
+            );
+
+            ValidateResult(_clsVar1, _clsVar2, result);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var left = Unsafe.Read<Vector256<UInt16>>(_dataTable.inArray1Ptr);
+            var right = Unsafe.Read<Vector256<UInt16>>(_dataTable.inArray2Ptr);
+            var result = Avx.TestZ(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var left = Avx.LoadVector256((UInt16*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadVector256((UInt16*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestZ(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var left = Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadAlignedVector256((UInt16*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestZ(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new BooleanBinaryOpTest__TestZUInt16();
+            var result = Avx.TestZ(test._fld1, test._fld2);
+
+            ValidateResult(test._fld1, test._fld2, result);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.TestZ(_fld1, _fld2);
+
+            ValidateResult(_fld1, _fld2, result);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<UInt16> left, Vector256<UInt16> right, bool result, [CallerMemberName] string method = "")
+        {
+            UInt16[] inArray1 = new UInt16[Op1ElementCount];
+            UInt16[] inArray2 = new UInt16[Op2ElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
+            Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
+        {
+            UInt16[] inArray1 = new UInt16[Op1ElementCount];
+            UInt16[] inArray2 = new UInt16[Op2ElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt16, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(UInt16[] left, UInt16[] right, bool result, [CallerMemberName] string method = "")
+        {
+            var expectedResult = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult &= ((left[i] & right[i]) == 0);
+            }
+
+            if (expectedResult != result)
+            {
+                Succeeded = false;
+
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.TestZ)}<UInt16>(Vector256<UInt16>, Vector256<UInt16>): {method} failed:");
+                Console.WriteLine($"    left: ({string.Join(", ", left)})");
+                Console.WriteLine($"   right: ({string.Join(", ", right)})");
+                Console.WriteLine($"  result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.UInt32.cs
new file mode 100644 (file)
index 0000000..04d571c
--- /dev/null
@@ -0,0 +1,318 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void TestZUInt32()
+        {
+            var test = new BooleanBinaryOpTest__TestZUInt32();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class BooleanBinaryOpTest__TestZUInt32
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+        private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+
+        private static UInt32[] _data1 = new UInt32[Op1ElementCount];
+        private static UInt32[] _data2 = new UInt32[Op2ElementCount];
+
+        private static Vector256<UInt32> _clsVar1;
+        private static Vector256<UInt32> _clsVar2;
+
+        private Vector256<UInt32> _fld1;
+        private Vector256<UInt32> _fld2;
+
+        private BooleanBinaryOpTest__DataTable<UInt32, UInt32> _dataTable;
+
+        static BooleanBinaryOpTest__TestZUInt32()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
+        }
+
+        public BooleanBinaryOpTest__TestZUInt32()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld1), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+            _dataTable = new BooleanBinaryOpTest__DataTable<UInt32, UInt32>(_data1, _data2, VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.TestZ(
+                Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray1Ptr),
+                Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray2Ptr)
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.TestZ(
+                Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)),
+                Avx.LoadVector256((UInt32*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.TestZ(
+                Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)),
+                Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256<UInt32>), typeof(Vector256<UInt32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray1Ptr),
+                                        Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray2Ptr)
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256<UInt32>), typeof(Vector256<UInt32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadVector256((UInt32*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256<UInt32>), typeof(Vector256<UInt32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.TestZ(
+                _clsVar1,
+                _clsVar2
+            );
+
+            ValidateResult(_clsVar1, _clsVar2, result);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var left = Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray1Ptr);
+            var right = Unsafe.Read<Vector256<UInt32>>(_dataTable.inArray2Ptr);
+            var result = Avx.TestZ(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var left = Avx.LoadVector256((UInt32*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadVector256((UInt32*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestZ(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var left = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadAlignedVector256((UInt32*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestZ(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new BooleanBinaryOpTest__TestZUInt32();
+            var result = Avx.TestZ(test._fld1, test._fld2);
+
+            ValidateResult(test._fld1, test._fld2, result);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.TestZ(_fld1, _fld2);
+
+            ValidateResult(_fld1, _fld2, result);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<UInt32> left, Vector256<UInt32> right, bool result, [CallerMemberName] string method = "")
+        {
+            UInt32[] inArray1 = new UInt32[Op1ElementCount];
+            UInt32[] inArray2 = new UInt32[Op2ElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
+            Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
+        {
+            UInt32[] inArray1 = new UInt32[Op1ElementCount];
+            UInt32[] inArray2 = new UInt32[Op2ElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt32, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(UInt32[] left, UInt32[] right, bool result, [CallerMemberName] string method = "")
+        {
+            var expectedResult = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult &= ((left[i] & right[i]) == 0);
+            }
+
+            if (expectedResult != result)
+            {
+                Succeeded = false;
+
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.TestZ)}<UInt32>(Vector256<UInt32>, Vector256<UInt32>): {method} failed:");
+                Console.WriteLine($"    left: ({string.Join(", ", left)})");
+                Console.WriteLine($"   right: ({string.Join(", ", right)})");
+                Console.WriteLine($"  result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/TestZ.UInt64.cs
new file mode 100644 (file)
index 0000000..ddd3a96
--- /dev/null
@@ -0,0 +1,318 @@
+// 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.
+
+/******************************************************************************
+ * This file is auto-generated from a template file by the GenerateTests.csx  *
+ * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make    *
+ * changes, please update the corresponding template and run according to the *
+ * directions listed in the file.                                             *
+ ******************************************************************************/
+
+using System;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Runtime.Intrinsics;
+using System.Runtime.Intrinsics.X86;
+
+namespace JIT.HardwareIntrinsics.X86
+{
+    public static partial class Program
+    {
+        private static void TestZUInt64()
+        {
+            var test = new BooleanBinaryOpTest__TestZUInt64();
+
+            if (test.IsSupported)
+            {
+                // Validates basic functionality works, using Unsafe.Read
+                test.RunBasicScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates basic functionality works, using Load
+                    test.RunBasicScenario_Load();
+
+                    // Validates basic functionality works, using LoadAligned
+                    test.RunBasicScenario_LoadAligned();
+                }
+
+                // Validates calling via reflection works, using Unsafe.Read
+                test.RunReflectionScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates calling via reflection works, using Load
+                    test.RunReflectionScenario_Load();
+
+                    // Validates calling via reflection works, using LoadAligned
+                    test.RunReflectionScenario_LoadAligned();
+                }
+
+                // Validates passing a static member works
+                test.RunClsVarScenario();
+
+                // Validates passing a local works, using Unsafe.Read
+                test.RunLclVarScenario_UnsafeRead();
+
+                if (Avx.IsSupported)
+                {
+                    // Validates passing a local works, using Load
+                    test.RunLclVarScenario_Load();
+
+                    // Validates passing a local works, using LoadAligned
+                    test.RunLclVarScenario_LoadAligned();
+                }
+
+                // Validates passing the field of a local works
+                test.RunLclFldScenario();
+
+                // Validates passing an instance member works
+                test.RunFldScenario();
+            }
+            else
+            {
+                // Validates we throw on unsupported hardware
+                test.RunUnsupportedScenario();
+            }
+
+            if (!test.Succeeded)
+            {
+                throw new Exception("One or more scenarios did not complete as expected.");
+            }
+        }
+    }
+
+    public sealed unsafe class BooleanBinaryOpTest__TestZUInt64
+    {
+        private const int VectorSize = 32;
+
+        private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+        private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+
+        private static UInt64[] _data1 = new UInt64[Op1ElementCount];
+        private static UInt64[] _data2 = new UInt64[Op2ElementCount];
+
+        private static Vector256<UInt64> _clsVar1;
+        private static Vector256<UInt64> _clsVar2;
+
+        private Vector256<UInt64> _fld1;
+        private Vector256<UInt64> _fld2;
+
+        private BooleanBinaryOpTest__DataTable<UInt64, UInt64> _dataTable;
+
+        static BooleanBinaryOpTest__TestZUInt64()
+        {
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
+        }
+
+        public BooleanBinaryOpTest__TestZUInt64()
+        {
+            Succeeded = true;
+
+            var random = new Random();
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _fld1), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
+
+            for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+            for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+            _dataTable = new BooleanBinaryOpTest__DataTable<UInt64, UInt64>(_data1, _data2, VectorSize);
+        }
+
+        public bool IsSupported => Avx.IsSupported;
+
+        public bool Succeeded { get; set; }
+
+        public void RunBasicScenario_UnsafeRead()
+        {
+            var result = Avx.TestZ(
+                Unsafe.Read<Vector256<UInt64>>(_dataTable.inArray1Ptr),
+                Unsafe.Read<Vector256<UInt64>>(_dataTable.inArray2Ptr)
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_Load()
+        {
+            var result = Avx.TestZ(
+                Avx.LoadVector256((UInt64*)(_dataTable.inArray1Ptr)),
+                Avx.LoadVector256((UInt64*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunBasicScenario_LoadAligned()
+        {
+            var result = Avx.TestZ(
+                Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray1Ptr)),
+                Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray2Ptr))
+            );
+
+            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
+        }
+
+        public void RunReflectionScenario_UnsafeRead()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256<UInt64>), typeof(Vector256<UInt64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Unsafe.Read<Vector256<UInt64>>(_dataTable.inArray1Ptr),
+                                        Unsafe.Read<Vector256<UInt64>>(_dataTable.inArray2Ptr)
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_Load()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256<UInt64>), typeof(Vector256<UInt64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadVector256((UInt64*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadVector256((UInt64*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunReflectionScenario_LoadAligned()
+        {
+            var method = typeof(Avx).GetMethod(nameof(Avx.TestZ), new Type[] { typeof(Vector256<UInt64>), typeof(Vector256<UInt64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
+                                        Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray1Ptr)),
+                                        Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray2Ptr))
+                                     });
+
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
+        }
+
+        public void RunClsVarScenario()
+        {
+            var result = Avx.TestZ(
+                _clsVar1,
+                _clsVar2
+            );
+
+            ValidateResult(_clsVar1, _clsVar2, result);
+        }
+
+        public void RunLclVarScenario_UnsafeRead()
+        {
+            var left = Unsafe.Read<Vector256<UInt64>>(_dataTable.inArray1Ptr);
+            var right = Unsafe.Read<Vector256<UInt64>>(_dataTable.inArray2Ptr);
+            var result = Avx.TestZ(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_Load()
+        {
+            var left = Avx.LoadVector256((UInt64*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadVector256((UInt64*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestZ(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclVarScenario_LoadAligned()
+        {
+            var left = Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray1Ptr));
+            var right = Avx.LoadAlignedVector256((UInt64*)(_dataTable.inArray2Ptr));
+            var result = Avx.TestZ(left, right);
+
+            ValidateResult(left, right, result);
+        }
+
+        public void RunLclFldScenario()
+        {
+            var test = new BooleanBinaryOpTest__TestZUInt64();
+            var result = Avx.TestZ(test._fld1, test._fld2);
+
+            ValidateResult(test._fld1, test._fld2, result);
+        }
+
+        public void RunFldScenario()
+        {
+            var result = Avx.TestZ(_fld1, _fld2);
+
+            ValidateResult(_fld1, _fld2, result);
+        }
+
+        public void RunUnsupportedScenario()
+        {
+            Succeeded = false;
+
+            try
+            {
+                RunBasicScenario_UnsafeRead();
+            }
+            catch (PlatformNotSupportedException)
+            {
+                Succeeded = true;
+            }
+        }
+
+        private void ValidateResult(Vector256<UInt64> left, Vector256<UInt64> right, bool result, [CallerMemberName] string method = "")
+        {
+            UInt64[] inArray1 = new UInt64[Op1ElementCount];
+            UInt64[] inArray2 = new UInt64[Op2ElementCount];
+
+            Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
+            Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
+        {
+            UInt64[] inArray1 = new UInt64[Op1ElementCount];
+            UInt64[] inArray2 = new UInt64[Op2ElementCount];
+
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+            Unsafe.CopyBlockUnaligned(ref Unsafe.As<UInt64, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+
+            ValidateResult(inArray1, inArray2, result, method);
+        }
+
+        private void ValidateResult(UInt64[] left, UInt64[] right, bool result, [CallerMemberName] string method = "")
+        {
+            var expectedResult = true;
+
+            for (var i = 0; i < Op1ElementCount; i++)
+            {
+                expectedResult &= ((left[i] & right[i]) == 0);
+            }
+
+            if (expectedResult != result)
+            {
+                Succeeded = false;
+
+                Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.TestZ)}<UInt64>(Vector256<UInt64>, Vector256<UInt64>): {method} failed:");
+                Console.WriteLine($"    left: ({string.Join(", ", left)})");
+                Console.WriteLine($"   right: ({string.Join(", ", right)})");
+                Console.WriteLine($"  result: ({string.Join(", ", result)})");
+                Console.WriteLine();
+            }
+        }
+    }
+}
index 4eab3a1..6b6b728 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {{
-            var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>) }})
-                                     .Invoke(null, new object[] {{
+            var method = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>) }});
+            
+            if (method != null)
+            {{
+                var result = method.Invoke(null, new object[] {{
                                         Unsafe.Read<{5}<{6}>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<{7}<{8}>>(_dataTable.inArray2Ptr)
                                      }});
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }}
         }}
 
         public void RunReflectionScenario_Load()
         {{
-            var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>) }})
-                                     .Invoke(null, new object[] {{
+            var method = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>) }});
+            
+            if (method != null)
+            {{
+                var result = method.Invoke(null, new object[] {{
                                         {1}.Load{5}(({6}*)(_dataTable.inArray1Ptr)),
                                         {1}.Load{7}(({8}*)(_dataTable.inArray2Ptr))
                                      }});
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }}
         }}
 
         public void RunReflectionScenario_LoadAligned()
         {{
-            var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>) }})
-                                     .Invoke(null, new object[] {{
+            var method = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>) }});
+            
+            if (method != null)
+            {{
+                var result = method.Invoke(null, new object[] {{
                                         {1}.LoadAligned{5}(({6}*)(_dataTable.inArray1Ptr)),
                                         {1}.LoadAligned{7}(({8}*)(_dataTable.inArray2Ptr))
                                      }});
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }}
         }}
 
         public void RunClsVarScenario()
index 3d816c0..babd01d 100644 (file)
@@ -163,35 +163,46 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {{
-            var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>) }})
-                                     .Invoke(null, new object[] {{
+            var method = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>) }});
+            
+            if (method != null)
+            {{
+                var result = method.Invoke(null, new object[] {{
                                         Unsafe.Read<{5}<{6}>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<{7}<{8}>>(_dataTable.inArray2Ptr)
                                      }});
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }}
         }}
 
         public void RunReflectionScenario_Load()
         {{
-            var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>) }})
-                                     .Invoke(null, new object[] {{
+            var method = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>) }});
+            
+            if (method != null)
+            {{
+                var result = method.Invoke(null, new object[] {{
                                         {1}.Load{5}(({6}*)(_dataTable.inArray1Ptr)),
                                         {1}.Load{7}(({8}*)(_dataTable.inArray2Ptr))
                                      }});
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }}
         }}
 
         public void RunReflectionScenario_LoadAligned()
-        {{
-            var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>) }})
-                                     .Invoke(null, new object[] {{
+        {{var method = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>) }});
+            
+            if (method != null)
+            {{
+                var result = method.Invoke(null, new object[] {{
                                         {1}.LoadAligned{5}(({6}*)(_dataTable.inArray1Ptr)),
                                         {1}.LoadAligned{7}(({8}*)(_dataTable.inArray2Ptr))
                                      }});
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }}
         }}
 
         public void RunClsVarScenario()
index d680847..6192d9e 100644 (file)
@@ -348,35 +348,73 @@ private static readonly (string templateFileName, string[] templateData)[] Sse42
 };
 
 private static readonly (string templateFileName, string[] templateData)[] AvxInputs = new []
-{                                                                                                                                                                                                                                                                     
-    // TemplateName                              Isa,   LoadIsa, Method,                 RetVectorType, RetBaseType, Op1VectorType, Op1BaseType, Op2VectorType, Op2BaseType, Op3VectorType, Op3BaseType, VectorSize, NextValueOp1,                    NextValueOp2,                    NextValueOp3,                            ValidateFirstResult,                                                                                                                                                                                                                                  ValidateRemainingResults
-    ("SimpleBinOpTest.template",  new string[] { "Avx", "Avx",   "Add",                  "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",                                "32",       "(double)(random.NextDouble())", "(double)(random.NextDouble())",                                          "BitConverter.DoubleToInt64Bits(left[0] + right[0]) != BitConverter.DoubleToInt64Bits(result[0])",                                                                                                                                                    "BitConverter.DoubleToInt64Bits(left[i] + right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
-    ("SimpleBinOpTest.template",  new string[] { "Avx", "Avx",   "Add",                  "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",                                "32",       "(float)(random.NextDouble())",  "(float)(random.NextDouble())",                                           "BitConverter.SingleToInt32Bits(left[0] + right[0]) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                                                                    "BitConverter.SingleToInt32Bits(left[i] + right[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
-    ("SimpleBinOpTest.template",  new string[] { "Avx", "Avx",   "AddSubtract",          "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",                                "32",       "(double)(random.NextDouble())", "(double)(random.NextDouble())",                                          "BitConverter.DoubleToInt64Bits(left[0] - right[0]) != BitConverter.DoubleToInt64Bits(result[0])",                                                                                                                                                    "((i % 2 != 0) && (BitConverter.DoubleToInt64Bits(left[i] + right[i]) != BitConverter.DoubleToInt64Bits(result[i]))) || ((i % 2 == 0) && (BitConverter.DoubleToInt64Bits(left[i] - right[i]) != BitConverter.DoubleToInt64Bits(result[i])))"}),
-    ("SimpleBinOpTest.template",  new string[] { "Avx", "Avx",   "AddSubtract",          "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",                                "32",       "(float)(random.NextDouble())",  "(float)(random.NextDouble())",                                           "BitConverter.SingleToInt32Bits(left[0] - right[0]) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                                                                    "((i % 2 != 0) && (BitConverter.SingleToInt32Bits(left[i] + right[i]) != BitConverter.SingleToInt32Bits(result[i]))) || ((i % 2 == 0) && (BitConverter.SingleToInt32Bits(left[i] - right[i]) != BitConverter.SingleToInt32Bits(result[i])))"}),    
-    ("SimpleBinOpTest.template",  new string[] { "Avx", "Avx",   "And",                  "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",                                "32",       "(double)(random.NextDouble())", "(double)(random.NextDouble())",                                          "(BitConverter.DoubleToInt64Bits(left[0]) & BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])",                                                                                                                  "(BitConverter.DoubleToInt64Bits(left[i]) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
-    ("SimpleBinOpTest.template",  new string[] { "Avx", "Avx",   "And",                  "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",                                "32",       "(float)(random.NextDouble())",  "(float)(random.NextDouble())",                                           "(BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                                  "(BitConverter.SingleToInt32Bits(left[i]) & BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
-    ("SimpleBinOpTest.template",  new string[] { "Avx", "Avx",   "AndNot",               "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",                                "32",       "(double)(random.NextDouble())", "(double)(random.NextDouble())",                                          "((~BitConverter.DoubleToInt64Bits(left[0])) & BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])",                                                                                                               "((~BitConverter.DoubleToInt64Bits(left[i])) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
-    ("SimpleBinOpTest.template",  new string[] { "Avx", "Avx",   "AndNot",               "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",                                "32",       "(float)(random.NextDouble())",  "(float)(random.NextDouble())",                                           "((~BitConverter.SingleToInt32Bits(left[0])) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                               "((~BitConverter.SingleToInt32Bits(left[i])) & BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
-    ("SimpleTernOpTest.template", new string[] { "Avx", "Avx",   "BlendVariable",        "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",    "32",       "(double)(random.NextDouble())", "(double)(random.NextDouble())", "(double)(((i % 2) == 0) ? -0.0 : 1.0)", "((BitConverter.DoubleToInt64Bits(thirdOp[0]) >> 63) & 1) == 1 ? BitConverter.DoubleToInt64Bits(secondOp[0]) != BitConverter.DoubleToInt64Bits(result[0]) : BitConverter.DoubleToInt64Bits(firstOp[0]) != BitConverter.DoubleToInt64Bits(result[0])", "((BitConverter.DoubleToInt64Bits(thirdOp[i]) >> 63) & 1) == 1 ? BitConverter.DoubleToInt64Bits(secondOp[i]) != BitConverter.DoubleToInt64Bits(result[i]) : BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
-    ("SimpleTernOpTest.template", new string[] { "Avx", "Avx",   "BlendVariable",        "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",    "32",       "(float)(random.NextDouble())",  "(float)(random.NextDouble())",  "(float)(((i % 2) == 0) ? -0.0 : 1.0)",  "((BitConverter.SingleToInt32Bits(thirdOp[0]) >> 31) & 1) == 1 ? BitConverter.SingleToInt32Bits(secondOp[0]) != BitConverter.SingleToInt32Bits(result[0]) : BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[0])", "((BitConverter.SingleToInt32Bits(thirdOp[i]) >> 31) & 1) == 1 ? BitConverter.SingleToInt32Bits(secondOp[i]) != BitConverter.SingleToInt32Bits(result[i]) : BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
-    ("SimpleBinOpTest.template",  new string[] { "Avx", "Avx",   "Divide",               "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",                                "32",       "(double)(random.NextDouble())", "(double)(random.NextDouble())",                                          "BitConverter.DoubleToInt64Bits(left[0] / right[0]) != BitConverter.DoubleToInt64Bits(result[0])",                                                                                                                                                    "BitConverter.DoubleToInt64Bits(left[i] / right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
-    ("SimpleBinOpTest.template",  new string[] { "Avx", "Avx",   "Divide",               "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",                                "32",       "(float)(random.NextDouble())",  "(float)(random.NextDouble())",                                           "BitConverter.SingleToInt32Bits(left[0] / right[0]) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                                                                    "BitConverter.SingleToInt32Bits(left[i] / right[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
-    ("SimpleUnOpTest.template",   new string[] { "Avx", "Avx",   "DuplicateEvenIndexed", "Vector256",   "Double",    "Vector256",   "Double",                                                            "32",       "(double)(random.NextDouble())",                                                                           "BitConverter.DoubleToInt64Bits(firstOp[0]) != BitConverter.DoubleToInt64Bits(result[0])",                                                                                                                                                            "(i % 2 == 0) ? (BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i])) : (BitConverter.DoubleToInt64Bits(firstOp[i - 1]) != BitConverter.DoubleToInt64Bits(result[i]))"}),
-    ("SimpleUnOpTest.template",   new string[] { "Avx", "Avx",   "DuplicateEvenIndexed", "Vector256",   "Single",    "Vector256",   "Single",                                                            "32",       "(float)(random.NextDouble())",                                                                            "BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                                                                            "(i % 2 == 0) ? (BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])) : (BitConverter.SingleToInt32Bits(firstOp[i - 1]) != BitConverter.SingleToInt32Bits(result[i]))"}),
-    ("SimpleUnOpTest.template",   new string[] { "Avx", "Avx",   "DuplicateOddIndexed",  "Vector256",   "Single",    "Vector256",   "Single",                                                            "32",       "(float)(random.NextDouble())",                                                                            "BitConverter.SingleToInt32Bits(firstOp[1]) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                                                                            "(i % 2 == 0) ? (BitConverter.SingleToInt32Bits(firstOp[i + 1]) != BitConverter.SingleToInt32Bits(result[i])) : (BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i]))"}),
-    ("SimpleBinOpTest.template",  new string[] { "Avx", "Avx",   "Max",                  "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",                                "32",       "(double)(random.NextDouble())", "(double)(random.NextDouble())",                                          "BitConverter.DoubleToInt64Bits(Math.Max(left[0], right[0])) != BitConverter.DoubleToInt64Bits(result[0])",                                                                                                                                           "BitConverter.DoubleToInt64Bits(Math.Max(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
-    ("SimpleBinOpTest.template",  new string[] { "Avx", "Avx",   "Max",                  "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",                                "32",       "(float)(random.NextDouble())",  "(float)(random.NextDouble())",                                           "BitConverter.SingleToInt32Bits(MathF.Max(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                                                          "BitConverter.SingleToInt32Bits(MathF.Max(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
-    ("SimpleBinOpTest.template",  new string[] { "Avx", "Avx",   "Min",                  "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",                                "32",       "(double)(random.NextDouble())", "(double)(random.NextDouble())",                                          "BitConverter.DoubleToInt64Bits(Math.Min(left[0], right[0])) != BitConverter.DoubleToInt64Bits(result[0])",                                                                                                                                           "BitConverter.DoubleToInt64Bits(Math.Min(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
-    ("SimpleBinOpTest.template",  new string[] { "Avx", "Avx",   "Min",                  "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",                                "32",       "(float)(random.NextDouble())",  "(float)(random.NextDouble())",                                           "BitConverter.SingleToInt32Bits(MathF.Min(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                                                          "BitConverter.SingleToInt32Bits(MathF.Min(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
-    ("SimpleBinOpTest.template",  new string[] { "Avx", "Avx",   "Multiply",             "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",                                "32",       "(double)(random.NextDouble())", "(double)(random.NextDouble())",                                          "BitConverter.DoubleToInt64Bits(left[0] * right[0]) != BitConverter.DoubleToInt64Bits(result[0])",                                                                                                                                                    "BitConverter.DoubleToInt64Bits(left[i] * right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
-    ("SimpleBinOpTest.template",  new string[] { "Avx", "Avx",   "Multiply",             "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",                                "32",       "(float)(random.NextDouble())",  "(float)(random.NextDouble())",                                           "BitConverter.SingleToInt32Bits(left[0] * right[0]) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                                                                    "BitConverter.SingleToInt32Bits(left[i] * right[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
-    ("SimpleBinOpTest.template",  new string[] { "Avx", "Avx",   "Or",                   "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",                                "32",       "(double)(random.NextDouble())", "(double)(random.NextDouble())",                                          "(BitConverter.DoubleToInt64Bits(left[0]) | BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])",                                                                                                                  "(BitConverter.DoubleToInt64Bits(left[i]) | BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
-    ("SimpleBinOpTest.template",  new string[] { "Avx", "Avx",   "Or",                   "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",                                "32",       "(float)(random.NextDouble())",  "(float)(random.NextDouble())",                                           "(BitConverter.SingleToInt32Bits(left[0]) | BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                                  "(BitConverter.SingleToInt32Bits(left[i]) | BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
-    ("SimpleBinOpTest.template",  new string[] { "Avx", "Avx",   "Subtract",             "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",                                "32",       "(double)(random.NextDouble())", "(double)(random.NextDouble())",                                          "BitConverter.DoubleToInt64Bits(left[0] - right[0]) != BitConverter.DoubleToInt64Bits(result[0])",                                                                                                                                                    "BitConverter.DoubleToInt64Bits(left[i] - right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
-    ("SimpleBinOpTest.template",  new string[] { "Avx", "Avx",   "Subtract",             "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",                                "32",       "(float)(random.NextDouble())",  "(float)(random.NextDouble())",                                           "BitConverter.SingleToInt32Bits(left[0] - right[0]) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                                                                    "BitConverter.SingleToInt32Bits(left[i] - right[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
-    ("SimpleBinOpTest.template",  new string[] { "Avx", "Avx",   "Xor",                  "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",                                "32",       "(double)(random.NextDouble())", "(double)(random.NextDouble())",                                          "(BitConverter.DoubleToInt64Bits(left[0]) ^ BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])",                                                                                                                  "(BitConverter.DoubleToInt64Bits(left[i]) ^ BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
-    ("SimpleBinOpTest.template",  new string[] { "Avx", "Avx",   "Xor",                  "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",                                "32",       "(float)(random.NextDouble())",  "(float)(random.NextDouble())",                                           "(BitConverter.SingleToInt32Bits(left[0]) ^ BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                                  "(BitConverter.SingleToInt32Bits(left[i]) ^ BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
+{                                                                                                                                                                                                                                                                                                                                          
+    // TemplateName                                 Isa,   LoadIsa, Method,                    RetVectorType, RetBaseType, Op1VectorType, Op1BaseType, Op2VectorType, Op2BaseType, Op3VectorType, Op3BaseType, VectorSize, NextValueOp1,                                           NextValueOp2,                    NextValueOp3,                            ValidateFirstResult,                                                                                                                                                                                                                                  ValidateRemainingResults
+    ("SimpleBinOpTest.template",     new string[] { "Avx", "Avx",   "Add",                     "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",                                "32",       "(double)(random.NextDouble())",                        "(double)(random.NextDouble())",                                          "BitConverter.DoubleToInt64Bits(left[0] + right[0]) != BitConverter.DoubleToInt64Bits(result[0])",                                                                                                                                                    "BitConverter.DoubleToInt64Bits(left[i] + right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
+    ("SimpleBinOpTest.template",     new string[] { "Avx", "Avx",   "Add",                     "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",                                "32",       "(float)(random.NextDouble())",                         "(float)(random.NextDouble())",                                           "BitConverter.SingleToInt32Bits(left[0] + right[0]) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                                                                    "BitConverter.SingleToInt32Bits(left[i] + right[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+    ("SimpleBinOpTest.template",     new string[] { "Avx", "Avx",   "AddSubtract",             "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",                                "32",       "(double)(random.NextDouble())",                        "(double)(random.NextDouble())",                                          "BitConverter.DoubleToInt64Bits(left[0] - right[0]) != BitConverter.DoubleToInt64Bits(result[0])",                                                                                                                                                    "((i % 2 != 0) && (BitConverter.DoubleToInt64Bits(left[i] + right[i]) != BitConverter.DoubleToInt64Bits(result[i]))) || ((i % 2 == 0) && (BitConverter.DoubleToInt64Bits(left[i] - right[i]) != BitConverter.DoubleToInt64Bits(result[i])))"}),
+    ("SimpleBinOpTest.template",     new string[] { "Avx", "Avx",   "AddSubtract",             "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",                                "32",       "(float)(random.NextDouble())",                         "(float)(random.NextDouble())",                                           "BitConverter.SingleToInt32Bits(left[0] - right[0]) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                                                                    "((i % 2 != 0) && (BitConverter.SingleToInt32Bits(left[i] + right[i]) != BitConverter.SingleToInt32Bits(result[i]))) || ((i % 2 == 0) && (BitConverter.SingleToInt32Bits(left[i] - right[i]) != BitConverter.SingleToInt32Bits(result[i])))"}),    
+    ("SimpleBinOpTest.template",     new string[] { "Avx", "Avx",   "And",                     "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",                                "32",       "(double)(random.NextDouble())",                        "(double)(random.NextDouble())",                                          "(BitConverter.DoubleToInt64Bits(left[0]) & BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])",                                                                                                                  "(BitConverter.DoubleToInt64Bits(left[i]) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
+    ("SimpleBinOpTest.template",     new string[] { "Avx", "Avx",   "And",                     "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",                                "32",       "(float)(random.NextDouble())",                         "(float)(random.NextDouble())",                                           "(BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                                  "(BitConverter.SingleToInt32Bits(left[i]) & BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
+    ("SimpleBinOpTest.template",     new string[] { "Avx", "Avx",   "AndNot",                  "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",                                "32",       "(double)(random.NextDouble())",                        "(double)(random.NextDouble())",                                          "((~BitConverter.DoubleToInt64Bits(left[0])) & BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])",                                                                                                               "((~BitConverter.DoubleToInt64Bits(left[i])) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
+    ("SimpleBinOpTest.template",     new string[] { "Avx", "Avx",   "AndNot",                  "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",                                "32",       "(float)(random.NextDouble())",                         "(float)(random.NextDouble())",                                           "((~BitConverter.SingleToInt32Bits(left[0])) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                               "((~BitConverter.SingleToInt32Bits(left[i])) & BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
+    ("SimpleTernOpTest.template",    new string[] { "Avx", "Avx",   "BlendVariable",           "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",    "32",       "(double)(random.NextDouble())",                        "(double)(random.NextDouble())", "(double)(((i % 2) == 0) ? -0.0 : 1.0)", "((BitConverter.DoubleToInt64Bits(thirdOp[0]) >> 63) & 1) == 1 ? BitConverter.DoubleToInt64Bits(secondOp[0]) != BitConverter.DoubleToInt64Bits(result[0]) : BitConverter.DoubleToInt64Bits(firstOp[0]) != BitConverter.DoubleToInt64Bits(result[0])", "((BitConverter.DoubleToInt64Bits(thirdOp[i]) >> 63) & 1) == 1 ? BitConverter.DoubleToInt64Bits(secondOp[i]) != BitConverter.DoubleToInt64Bits(result[i]) : BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
+    ("SimpleTernOpTest.template",    new string[] { "Avx", "Avx",   "BlendVariable",           "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",    "32",       "(float)(random.NextDouble())",                         "(float)(random.NextDouble())",  "(float)(((i % 2) == 0) ? -0.0 : 1.0)",  "((BitConverter.SingleToInt32Bits(thirdOp[0]) >> 31) & 1) == 1 ? BitConverter.SingleToInt32Bits(secondOp[0]) != BitConverter.SingleToInt32Bits(result[0]) : BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[0])", "((BitConverter.SingleToInt32Bits(thirdOp[i]) >> 31) & 1) == 1 ? BitConverter.SingleToInt32Bits(secondOp[i]) != BitConverter.SingleToInt32Bits(result[i]) : BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+    ("SimpleUnOpTest.template",      new string[] { "Avx", "Avx",   "Ceiling",                 "Vector256",   "Double",    "Vector256",   "Double",                                                            "32",       "(double)(random.NextDouble())",                                                                                                  "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(firstOp[0]))",                                                                                                                                              "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(firstOp[i]))"}),
+    ("SimpleUnOpTest.template",      new string[] { "Avx", "Avx",   "Ceiling",                 "Vector256",   "Single",    "Vector256",   "Single",                                                            "32",       "(float)(random.NextDouble())",                                                                                                   "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(firstOp[0]))",                                                                                                                                             "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(firstOp[i]))"}),
+    ("SimpleBinOpTest.template",     new string[] { "Avx", "Avx",   "Divide",                  "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",                                "32",       "(double)(random.NextDouble())",                        "(double)(random.NextDouble())",                                          "BitConverter.DoubleToInt64Bits(left[0] / right[0]) != BitConverter.DoubleToInt64Bits(result[0])",                                                                                                                                                    "BitConverter.DoubleToInt64Bits(left[i] / right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
+    ("SimpleBinOpTest.template",     new string[] { "Avx", "Avx",   "Divide",                  "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",                                "32",       "(float)(random.NextDouble())",                         "(float)(random.NextDouble())",                                           "BitConverter.SingleToInt32Bits(left[0] / right[0]) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                                                                    "BitConverter.SingleToInt32Bits(left[i] / right[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+    ("SimpleUnOpTest.template",      new string[] { "Avx", "Avx",   "DuplicateEvenIndexed",    "Vector256",   "Double",    "Vector256",   "Double",                                                            "32",       "(double)(random.NextDouble())",                                                                                                  "BitConverter.DoubleToInt64Bits(firstOp[0]) != BitConverter.DoubleToInt64Bits(result[0])",                                                                                                                                                            "(i % 2 == 0) ? (BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i])) : (BitConverter.DoubleToInt64Bits(firstOp[i - 1]) != BitConverter.DoubleToInt64Bits(result[i]))"}),
+    ("SimpleUnOpTest.template",      new string[] { "Avx", "Avx",   "DuplicateEvenIndexed",    "Vector256",   "Single",    "Vector256",   "Single",                                                            "32",       "(float)(random.NextDouble())",                                                                                                   "BitConverter.SingleToInt32Bits(firstOp[0]) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                                                                            "(i % 2 == 0) ? (BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])) : (BitConverter.SingleToInt32Bits(firstOp[i - 1]) != BitConverter.SingleToInt32Bits(result[i]))"}),
+    ("SimpleUnOpTest.template",      new string[] { "Avx", "Avx",   "DuplicateOddIndexed",     "Vector256",   "Single",    "Vector256",   "Single",                                                            "32",       "(float)(random.NextDouble())",                                                                                                   "BitConverter.SingleToInt32Bits(firstOp[1]) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                                                                            "(i % 2 == 0) ? (BitConverter.SingleToInt32Bits(firstOp[i + 1]) != BitConverter.SingleToInt32Bits(result[i])) : (BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i]))"}),
+    ("SimpleUnOpTest.template",      new string[] { "Avx", "Avx",   "Floor",                   "Vector256",   "Double",    "Vector256",   "Double",                                                            "32",       "(double)(random.NextDouble())",                                                                                                  "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[0]))",                                                                                                                                                "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[i]))"}),
+    ("SimpleUnOpTest.template",      new string[] { "Avx", "Avx",   "Floor",                   "Vector256",   "Single",    "Vector256",   "Single",                                                            "32",       "(float)(random.NextDouble())",                                                                                                   "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[0]))",                                                                                                                                               "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[i]))"}),
+    ("SimpleBinOpTest.template",     new string[] { "Avx", "Avx",   "Max",                     "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",                                "32",       "(double)(random.NextDouble())",                        "(double)(random.NextDouble())",                                          "BitConverter.DoubleToInt64Bits(Math.Max(left[0], right[0])) != BitConverter.DoubleToInt64Bits(result[0])",                                                                                                                                           "BitConverter.DoubleToInt64Bits(Math.Max(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
+    ("SimpleBinOpTest.template",     new string[] { "Avx", "Avx",   "Max",                     "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",                                "32",       "(float)(random.NextDouble())",                         "(float)(random.NextDouble())",                                           "BitConverter.SingleToInt32Bits(MathF.Max(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                                                          "BitConverter.SingleToInt32Bits(MathF.Max(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
+    ("SimpleBinOpTest.template",     new string[] { "Avx", "Avx",   "Min",                     "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",                                "32",       "(double)(random.NextDouble())",                        "(double)(random.NextDouble())",                                          "BitConverter.DoubleToInt64Bits(Math.Min(left[0], right[0])) != BitConverter.DoubleToInt64Bits(result[0])",                                                                                                                                           "BitConverter.DoubleToInt64Bits(Math.Min(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
+    ("SimpleBinOpTest.template",     new string[] { "Avx", "Avx",   "Min",                     "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",                                "32",       "(float)(random.NextDouble())",                         "(float)(random.NextDouble())",                                           "BitConverter.SingleToInt32Bits(MathF.Min(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                                                          "BitConverter.SingleToInt32Bits(MathF.Min(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
+    ("SimpleBinOpTest.template",     new string[] { "Avx", "Avx",   "Multiply",                "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",                                "32",       "(double)(random.NextDouble())",                        "(double)(random.NextDouble())",                                          "BitConverter.DoubleToInt64Bits(left[0] * right[0]) != BitConverter.DoubleToInt64Bits(result[0])",                                                                                                                                                    "BitConverter.DoubleToInt64Bits(left[i] * right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
+    ("SimpleBinOpTest.template",     new string[] { "Avx", "Avx",   "Multiply",                "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",                                "32",       "(float)(random.NextDouble())",                         "(float)(random.NextDouble())",                                           "BitConverter.SingleToInt32Bits(left[0] * right[0]) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                                                                    "BitConverter.SingleToInt32Bits(left[i] * right[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+    ("SimpleBinOpTest.template",     new string[] { "Avx", "Avx",   "Or",                      "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",                                "32",       "(double)(random.NextDouble())",                        "(double)(random.NextDouble())",                                          "(BitConverter.DoubleToInt64Bits(left[0]) | BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])",                                                                                                                  "(BitConverter.DoubleToInt64Bits(left[i]) | BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
+    ("SimpleBinOpTest.template",     new string[] { "Avx", "Avx",   "Or",                      "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",                                "32",       "(float)(random.NextDouble())",                         "(float)(random.NextDouble())",                                           "(BitConverter.SingleToInt32Bits(left[0]) | BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                                  "(BitConverter.SingleToInt32Bits(left[i]) | BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
+    ("SimpleUnOpTest.template",      new string[] { "Avx", "Avx",   "RoundCurrentDirection",   "Vector256",   "Double",    "Vector256",   "Double",                                                            "32",       "(double)(random.NextDouble())",                                                                                                  "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Round(firstOp[0]))",                                                                                                                                                "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Round(firstOp[i]))"}),
+    ("SimpleUnOpTest.template",      new string[] { "Avx", "Avx",   "RoundCurrentDirection",   "Vector256",   "Single",    "Vector256",   "Single",                                                            "32",       "(float)(random.NextDouble())",                                                                                                   "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Round(firstOp[0]))",                                                                                                                                               "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Round(firstOp[i]))"}),
+    ("SimpleUnOpTest.template",      new string[] { "Avx", "Avx",   "RoundToNearestInteger",   "Vector256",   "Double",    "Vector256",   "Double",                                                            "32",       "(double)(random.NextDouble())",                                                                                                  "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Round(firstOp[0], MidpointRounding.AwayFromZero))",                                                                                                                 "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Round(firstOp[i], MidpointRounding.AwayFromZero))"}),
+    ("SimpleUnOpTest.template",      new string[] { "Avx", "Avx",   "RoundToNearestInteger",   "Vector256",   "Single",    "Vector256",   "Single",                                                            "32",       "(float)(random.NextDouble())",                                                                                                   "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Round(firstOp[0], MidpointRounding.AwayFromZero))",                                                                                                                "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Round(firstOp[i], MidpointRounding.AwayFromZero))"}),
+    ("SimpleUnOpTest.template",      new string[] { "Avx", "Avx",   "RoundToNegativeInfinity", "Vector256",   "Double",    "Vector256",   "Double",                                                            "32",       "(double)(random.NextDouble())",                                                                                                  "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[0]))",                                                                                                                                                "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Floor(firstOp[i]))"}),
+    ("SimpleUnOpTest.template",      new string[] { "Avx", "Avx",   "RoundToNegativeInfinity", "Vector256",   "Single",    "Vector256",   "Single",                                                            "32",       "(float)(random.NextDouble())",                                                                                                   "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[0]))",                                                                                                                                               "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Floor(firstOp[i]))"}),
+    ("SimpleUnOpTest.template",      new string[] { "Avx", "Avx",   "RoundToPositiveInfinity", "Vector256",   "Double",    "Vector256",   "Double",                                                            "32",       "(double)(random.NextDouble())",                                                                                                  "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(firstOp[0]))",                                                                                                                                              "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits(Math.Ceiling(firstOp[i]))"}),
+    ("SimpleUnOpTest.template",      new string[] { "Avx", "Avx",   "RoundToPositiveInfinity", "Vector256",   "Single",    "Vector256",   "Single",                                                            "32",       "(float)(random.NextDouble())",                                                                                                   "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(firstOp[0]))",                                                                                                                                             "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits(MathF.Ceiling(firstOp[i]))"}),
+    ("SimpleUnOpTest.template",      new string[] { "Avx", "Avx",   "RoundToZero",             "Vector256",   "Double",    "Vector256",   "Double",                                                            "32",       "(double)(random.NextDouble())",                                                                                                  "BitConverter.DoubleToInt64Bits(result[0]) != BitConverter.DoubleToInt64Bits((firstOp[0] > 0) ? Math.Floor(firstOp[0]) : Math.Ceiling(firstOp[0]))",                                                                                                  "BitConverter.DoubleToInt64Bits(result[i]) != BitConverter.DoubleToInt64Bits((firstOp[i] > 0) ? Math.Floor(firstOp[i]) : Math.Ceiling(firstOp[i]))"}),
+    ("SimpleUnOpTest.template",      new string[] { "Avx", "Avx",   "RoundToZero",             "Vector256",   "Single",    "Vector256",   "Single",                                                            "32",       "(float)(random.NextDouble())",                                                                                                   "BitConverter.SingleToInt32Bits(result[0]) != BitConverter.SingleToInt32Bits((firstOp[0] > 0) ? MathF.Floor(firstOp[0]) : MathF.Ceiling(firstOp[0]))",                                                                                                "BitConverter.SingleToInt32Bits(result[i]) != BitConverter.SingleToInt32Bits((firstOp[i] > 0) ? MathF.Floor(firstOp[i]) : MathF.Ceiling(firstOp[i]))"}),
+    ("SimpleBinOpTest.template",     new string[] { "Avx", "Avx",   "Subtract",                "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",                                "32",       "(double)(random.NextDouble())",                        "(double)(random.NextDouble())",                                          "BitConverter.DoubleToInt64Bits(left[0] - right[0]) != BitConverter.DoubleToInt64Bits(result[0])",                                                                                                                                                    "BitConverter.DoubleToInt64Bits(left[i] - right[i]) != BitConverter.DoubleToInt64Bits(result[i])"}),
+    ("SimpleBinOpTest.template",     new string[] { "Avx", "Avx",   "Subtract",                "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",                                "32",       "(float)(random.NextDouble())",                         "(float)(random.NextDouble())",                                           "BitConverter.SingleToInt32Bits(left[0] - right[0]) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                                                                    "BitConverter.SingleToInt32Bits(left[i] - right[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+    ("BooleanBinOpTest.template",    new string[] { "Avx", "Avx",   "TestC",                   "Vector256",   "Byte",      "Vector256",   "Byte",      "Vector256",   "Byte",                                  "32",       "(byte)(random.Next(0, byte.MaxValue))",                "(byte)(random.Next(0, byte.MaxValue))",                                  "(~left[i] & right[i]) == 0"}),
+    ("BooleanBinOpTest.template",    new string[] { "Avx", "Avx",   "TestC",                   "Vector256",   "Int16",     "Vector256",   "Int16",     "Vector256",   "Int16",                                 "32",       "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))",                   "(~left[i] & right[i]) == 0"}),
+    ("BooleanBinOpTest.template",    new string[] { "Avx", "Avx",   "TestC",                   "Vector256",   "Int32",     "Vector256",   "Int32",     "Vector256",   "Int32",                                 "32",       "(int)(random.Next(int.MinValue, int.MaxValue))",       "(int)(random.Next(int.MinValue, int.MaxValue))",                         "(~left[i] & right[i]) == 0"}),
+    ("BooleanBinOpTest.template",    new string[] { "Avx", "Avx",   "TestC",                   "Vector256",   "Int64",     "Vector256",   "Int64",     "Vector256",   "Int64",                                 "32",       "(long)(random.Next(int.MinValue, int.MaxValue))",      "(long)(random.Next(int.MinValue, int.MaxValue))",                        "(~left[i] & right[i]) == 0"}),
+    ("BooleanBinOpTest.template",    new string[] { "Avx", "Avx",   "TestC",                   "Vector256",   "SByte",     "Vector256",   "SByte",     "Vector256",   "SByte",                                 "32",       "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))",                   "(~left[i] & right[i]) == 0"}),
+    ("BooleanBinOpTest.template",    new string[] { "Avx", "Avx",   "TestC",                   "Vector256",   "UInt16",    "Vector256",   "UInt16",    "Vector256",   "UInt16",                                "32",       "(ushort)(random.Next(0, ushort.MaxValue))",            "(ushort)(random.Next(0, ushort.MaxValue))",                              "(~left[i] & right[i]) == 0"}),
+    ("BooleanBinOpTest.template",    new string[] { "Avx", "Avx",   "TestC",                   "Vector256",   "UInt32",    "Vector256",   "UInt32",    "Vector256",   "UInt32",                                "32",       "(uint)(random.Next(0, int.MaxValue))",                 "(uint)(random.Next(0, int.MaxValue))",                                   "(~left[i] & right[i]) == 0"}),
+    ("BooleanBinOpTest.template",    new string[] { "Avx", "Avx",   "TestC",                   "Vector256",   "UInt64",    "Vector256",   "UInt64",    "Vector256",   "UInt64",                                "32",       "(ulong)(random.Next(0, int.MaxValue))",                "(ulong)(random.Next(0, int.MaxValue))",                                  "(~left[i] & right[i]) == 0"}),
+    ("BooleanTwoCmpOpTest.template", new string[] { "Avx", "Avx",   "TestNotZAndNotC",         "Vector256",   "Byte",      "Vector256",   "Byte",      "Vector256",   "Byte",                                  "32",       "(byte)(random.Next(0, byte.MaxValue))",                "(byte)(random.Next(0, byte.MaxValue))",                                  "((left[i] & right[i]) == 0)",                                                                                                                                                                                                                        "((~left[i] & right[i]) == 0)"}),
+    ("BooleanTwoCmpOpTest.template", new string[] { "Avx", "Avx",   "TestNotZAndNotC",         "Vector256",   "Int16",     "Vector256",   "Int16",     "Vector256",   "Int16",                                 "32",       "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))",                   "((left[i] & right[i]) == 0)",                                                                                                                                                                                                                        "((~left[i] & right[i]) == 0)"}),
+    ("BooleanTwoCmpOpTest.template", new string[] { "Avx", "Avx",   "TestNotZAndNotC",         "Vector256",   "Int32",     "Vector256",   "Int32",     "Vector256",   "Int32",                                 "32",       "(int)(random.Next(int.MinValue, int.MaxValue))",       "(int)(random.Next(int.MinValue, int.MaxValue))",                         "((left[i] & right[i]) == 0)",                                                                                                                                                                                                                        "((~left[i] & right[i]) == 0)"}),
+    ("BooleanTwoCmpOpTest.template", new string[] { "Avx", "Avx",   "TestNotZAndNotC",         "Vector256",   "Int64",     "Vector256",   "Int64",     "Vector256",   "Int64",                                 "32",       "(long)(random.Next(int.MinValue, int.MaxValue))",      "(long)(random.Next(int.MinValue, int.MaxValue))",                        "((left[i] & right[i]) == 0)",                                                                                                                                                                                                                        "((~left[i] & right[i]) == 0)"}),
+    ("BooleanTwoCmpOpTest.template", new string[] { "Avx", "Avx",   "TestNotZAndNotC",         "Vector256",   "SByte",     "Vector256",   "SByte",     "Vector256",   "SByte",                                 "32",       "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))",                   "((left[i] & right[i]) == 0)",                                                                                                                                                                                                                        "((~left[i] & right[i]) == 0)"}),
+    ("BooleanTwoCmpOpTest.template", new string[] { "Avx", "Avx",   "TestNotZAndNotC",         "Vector256",   "UInt16",    "Vector256",   "UInt16",    "Vector256",   "UInt16",                                "32",       "(ushort)(random.Next(0, ushort.MaxValue))",            "(ushort)(random.Next(0, ushort.MaxValue))",                              "((left[i] & right[i]) == 0)",                                                                                                                                                                                                                        "((~left[i] & right[i]) == 0)"}),
+    ("BooleanTwoCmpOpTest.template", new string[] { "Avx", "Avx",   "TestNotZAndNotC",         "Vector256",   "UInt32",    "Vector256",   "UInt32",    "Vector256",   "UInt32",                                "32",       "(uint)(random.Next(0, int.MaxValue))",                 "(uint)(random.Next(0, int.MaxValue))",                                   "((left[i] & right[i]) == 0)",                                                                                                                                                                                                                        "((~left[i] & right[i]) == 0)"}),
+    ("BooleanTwoCmpOpTest.template", new string[] { "Avx", "Avx",   "TestNotZAndNotC",         "Vector256",   "UInt64",    "Vector256",   "UInt64",    "Vector256",   "UInt64",                                "32",       "(ulong)(random.Next(0, int.MaxValue))",                "(ulong)(random.Next(0, int.MaxValue))",                                  "((left[i] & right[i]) == 0)",                                                                                                                                                                                                                        "((~left[i] & right[i]) == 0)"}),
+    ("BooleanBinOpTest.template",    new string[] { "Avx", "Avx",   "TestZ",                   "Vector256",   "Byte",      "Vector256",   "Byte",      "Vector256",   "Byte",                                  "32",       "(byte)(random.Next(0, byte.MaxValue))",                "(byte)(random.Next(0, byte.MaxValue))",                                  "(left[i] & right[i]) == 0"}),
+    ("BooleanBinOpTest.template",    new string[] { "Avx", "Avx",   "TestZ",                   "Vector256",   "Int16",     "Vector256",   "Int16",     "Vector256",   "Int16",                                 "32",       "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))",                   "(left[i] & right[i]) == 0"}),
+    ("BooleanBinOpTest.template",    new string[] { "Avx", "Avx",   "TestZ",                   "Vector256",   "Int32",     "Vector256",   "Int32",     "Vector256",   "Int32",                                 "32",       "(int)(random.Next(int.MinValue, int.MaxValue))",       "(int)(random.Next(int.MinValue, int.MaxValue))",                         "(left[i] & right[i]) == 0"}),
+    ("BooleanBinOpTest.template",    new string[] { "Avx", "Avx",   "TestZ",                   "Vector256",   "Int64",     "Vector256",   "Int64",     "Vector256",   "Int64",                                 "32",       "(long)(random.Next(int.MinValue, int.MaxValue))",      "(long)(random.Next(int.MinValue, int.MaxValue))",                        "(left[i] & right[i]) == 0"}),
+    ("BooleanBinOpTest.template",    new string[] { "Avx", "Avx",   "TestZ",                   "Vector256",   "SByte",     "Vector256",   "SByte",     "Vector256",   "SByte",                                 "32",       "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))",                   "(left[i] & right[i]) == 0"}),
+    ("BooleanBinOpTest.template",    new string[] { "Avx", "Avx",   "TestZ",                   "Vector256",   "UInt16",    "Vector256",   "UInt16",    "Vector256",   "UInt16",                                "32",       "(ushort)(random.Next(0, ushort.MaxValue))",            "(ushort)(random.Next(0, ushort.MaxValue))",                              "(left[i] & right[i]) == 0"}),
+    ("BooleanBinOpTest.template",    new string[] { "Avx", "Avx",   "TestZ",                   "Vector256",   "UInt32",    "Vector256",   "UInt32",    "Vector256",   "UInt32",                                "32",       "(uint)(random.Next(0, int.MaxValue))",                 "(uint)(random.Next(0, int.MaxValue))",                                   "(left[i] & right[i]) == 0"}),
+    ("BooleanBinOpTest.template",    new string[] { "Avx", "Avx",   "TestZ",                   "Vector256",   "UInt64",    "Vector256",   "UInt64",    "Vector256",   "UInt64",                                "32",       "(ulong)(random.Next(0, int.MaxValue))",                "(ulong)(random.Next(0, int.MaxValue))",                                  "(left[i] & right[i]) == 0"}),
+    ("SimpleBinOpTest.template",     new string[] { "Avx", "Avx",   "Xor",                     "Vector256",   "Double",    "Vector256",   "Double",    "Vector256",   "Double",                                "32",       "(double)(random.NextDouble())",                        "(double)(random.NextDouble())",                                          "(BitConverter.DoubleToInt64Bits(left[0]) ^ BitConverter.DoubleToInt64Bits(right[0])) != BitConverter.DoubleToInt64Bits(result[0])",                                                                                                                  "(BitConverter.DoubleToInt64Bits(left[i]) ^ BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i])"}),
+    ("SimpleBinOpTest.template",     new string[] { "Avx", "Avx",   "Xor",                     "Vector256",   "Single",    "Vector256",   "Single",    "Vector256",   "Single",                                "32",       "(float)(random.NextDouble())",                         "(float)(random.NextDouble())",                                           "(BitConverter.SingleToInt32Bits(left[0]) ^ BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])",                                                                                                                  "(BitConverter.SingleToInt32Bits(left[i]) ^ BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
 };
 
 private static readonly (string templateFileName, string[] templateData)[] Avx2Inputs = new []
index 1975166..87c213d 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<Byte>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((Byte*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((Byte*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index dc59464..aa7cf28 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<Int16>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<Int16>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((Int16*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((Int16*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index 230901a..0f5bc9f 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<Int32>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<Int32>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((Int32*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((Int32*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index e392513..0625e05 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<Int64>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((Int64*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((Int64*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((Int64*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((Int64*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index 37387aa..27b59ee 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<SByte>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<SByte>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((SByte*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((SByte*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((SByte*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((SByte*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index 28f92b8..c0cf917 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<UInt16>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<UInt16>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((UInt16*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((UInt16*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((UInt16*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((UInt16*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index bc7e223..83a0c46 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index 03b3a2a..4612b35 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((UInt64*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((UInt64*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestAllZeros), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((UInt64*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((UInt64*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index 52e2001..56d9f9a 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<Byte>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((Byte*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((Byte*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index be483c1..1d025d9 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<Int16>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<Int16>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((Int16*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((Int16*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index b6e6004..cbbb29a 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<Int32>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<Int32>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((Int32*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((Int32*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index 55e1261..a901ab0 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<Int64>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((Int64*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((Int64*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((Int64*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((Int64*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index 474bc52..f3e20b3 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<SByte>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<SByte>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((SByte*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((SByte*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((SByte*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((SByte*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index 6f75a47..982d213 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<UInt16>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<UInt16>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((UInt16*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((UInt16*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((UInt16*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((UInt16*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index 5c7b289..042a6c4 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index 85a5b38..0e61879 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((UInt64*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((UInt64*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestC), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((UInt64*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((UInt64*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index d08d0c1..f3c2225 100644 (file)
@@ -163,35 +163,46 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<Byte>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((Byte*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((Byte*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
-        {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) })
-                                     .Invoke(null, new object[] {
+        {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index ef5d086..88ef85f 100644 (file)
@@ -163,35 +163,46 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<Int16>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<Int16>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((Int16*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((Int16*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
-        {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) })
-                                     .Invoke(null, new object[] {
+        {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index e67b4bc..ff18aeb 100644 (file)
@@ -163,35 +163,46 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<Int32>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<Int32>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((Int32*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((Int32*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
-        {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) })
-                                     .Invoke(null, new object[] {
+        {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index 0fec963..09d2c78 100644 (file)
@@ -163,35 +163,46 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<Int64>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((Int64*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((Int64*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
-        {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) })
-                                     .Invoke(null, new object[] {
+        {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((Int64*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((Int64*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index cc4853d..85e65ac 100644 (file)
@@ -163,35 +163,46 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<SByte>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<SByte>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((SByte*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((SByte*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
-        {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) })
-                                     .Invoke(null, new object[] {
+        {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((SByte*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((SByte*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index d0282f8..aa3bdac 100644 (file)
@@ -163,35 +163,46 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<UInt16>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<UInt16>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((UInt16*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((UInt16*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
-        {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) })
-                                     .Invoke(null, new object[] {
+        {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((UInt16*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((UInt16*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index cc60c2f..24194ea 100644 (file)
@@ -163,35 +163,46 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
-        {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) })
-                                     .Invoke(null, new object[] {
+        {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index 4d9915b..3e6acc7 100644 (file)
@@ -163,35 +163,46 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((UInt64*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((UInt64*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
-        {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) })
-                                     .Invoke(null, new object[] {
+        {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestMixOnesZeros), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((UInt64*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((UInt64*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index 1bb8e75..fc62e87 100644 (file)
@@ -163,35 +163,46 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<Byte>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((Byte*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((Byte*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
-        {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) })
-                                     .Invoke(null, new object[] {
+        {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index 6528e37..25102e4 100644 (file)
@@ -163,35 +163,46 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<Int16>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<Int16>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((Int16*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((Int16*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
-        {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) })
-                                     .Invoke(null, new object[] {
+        {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index f8fd520..93de213 100644 (file)
@@ -163,35 +163,46 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<Int32>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<Int32>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((Int32*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((Int32*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
-        {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) })
-                                     .Invoke(null, new object[] {
+        {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index 1d1066e..7bcc0c2 100644 (file)
@@ -163,35 +163,46 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<Int64>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((Int64*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((Int64*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
-        {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) })
-                                     .Invoke(null, new object[] {
+        {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((Int64*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((Int64*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index 87d0d9e..923d950 100644 (file)
@@ -163,35 +163,46 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<SByte>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<SByte>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((SByte*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((SByte*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
-        {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) })
-                                     .Invoke(null, new object[] {
+        {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((SByte*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((SByte*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index 9e5d756..1c27aca 100644 (file)
@@ -163,35 +163,46 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<UInt16>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<UInt16>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((UInt16*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((UInt16*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
-        {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) })
-                                     .Invoke(null, new object[] {
+        {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((UInt16*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((UInt16*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index 4730e23..4d9c0d5 100644 (file)
@@ -163,35 +163,46 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
-        {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) })
-                                     .Invoke(null, new object[] {
+        {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index 41935ff..323d04b 100644 (file)
@@ -163,35 +163,46 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((UInt64*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((UInt64*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
-        {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) })
-                                     .Invoke(null, new object[] {
+        {var method = typeof(Sse41).GetMethod(nameof(Sse41.TestNotZAndNotC), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((UInt64*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((UInt64*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index c5c8f43..33743f4 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<Byte>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<Byte>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((Byte*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((Byte*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Byte>), typeof(Vector128<Byte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((Byte*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index 779e3f4..03331d9 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<Int16>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<Int16>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((Int16*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((Int16*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Int16>), typeof(Vector128<Int16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((Int16*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index 2a81fd7..71db570 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<Int32>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<Int32>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((Int32*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((Int32*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Int32>), typeof(Vector128<Int32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((Int32*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index 61dea99..2702727 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<Int64>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<Int64>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((Int64*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((Int64*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<Int64>), typeof(Vector128<Int64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((Int64*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((Int64*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index 4eb54e5..fb50f56 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<SByte>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<SByte>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((SByte*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((SByte*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<SByte>), typeof(Vector128<SByte>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((SByte*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((SByte*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index 39319c2..261ff21 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<UInt16>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<UInt16>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((UInt16*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((UInt16*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<UInt16>), typeof(Vector128<UInt16>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((UInt16*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((UInt16*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index f40495f..6127ee3 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<UInt32>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((UInt32*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((UInt32*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<UInt32>), typeof(Vector128<UInt32>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((UInt32*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index e71b9f7..e7c2a11 100644 (file)
@@ -163,35 +163,47 @@ namespace JIT.HardwareIntrinsics.X86
 
         public void RunReflectionScenario_UnsafeRead()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray1Ptr),
                                         Unsafe.Read<Vector128<UInt64>>(_dataTable.inArray2Ptr)
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_Load()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadVector128((UInt64*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadVector128((UInt64*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunReflectionScenario_LoadAligned()
         {
-            var result = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) })
-                                     .Invoke(null, new object[] {
+            var method = typeof(Sse41).GetMethod(nameof(Sse41.TestZ), new Type[] { typeof(Vector128<UInt64>), typeof(Vector128<UInt64>) });
+            
+            if (method != null)
+            {
+                var result = method.Invoke(null, new object[] {
                                         Sse2.LoadAlignedVector128((UInt64*)(_dataTable.inArray1Ptr)),
                                         Sse2.LoadAlignedVector128((UInt64*)(_dataTable.inArray2Ptr))
                                      });
 
-            ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+                ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
+            }
         }
 
         public void RunClsVarScenario()
index daa39d6..6bb138b 100644 (file)
@@ -31,7 +31,6 @@
       <DisabledProjects Include="Performance\Scenario\JitBench\unofficial_dotnet\JitBench.csproj" /> <!-- no official build support for SDK-style netcoreapp2.0 projects -->
       <DisabledProjects Include="Loader\classloader\generics\regressions\DD117522\Test.csproj" />
       <DisabledProjects Include="Loader\classloader\generics\GenericMethods\VSW491668.csproj" /> <!-- issue 5501 -->
-      <DisabledProjects Include="tracing\eventsource*\**" /> <!-- issue 15924 -->
     </ItemGroup>
     
     <ItemGroup>
index fa47281..be147db 100755 (executable)
@@ -4,6 +4,15 @@ namespace Tracing.Tests.Common
 {
     public static class Assert
     {
+        public static void True(string name, bool condition)
+        {
+            if (!condition)
+            {
+                throw new Exception(
+                    string.Format("Condition '{0}' is not true", name));
+            }
+        }
+
         public static void Equal<T>(string name, T left, T right) where T : IEquatable<T>
         {
             if (left == null && right != null)
diff --git a/tests/src/tracing/eventpipesmoke/EventPipeSmoke.cs b/tests/src/tracing/eventpipesmoke/EventPipeSmoke.cs
deleted file mode 100644 (file)
index 370d082..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-using System;
-using System.IO;
-using Tracing.Tests.Common;
-
-namespace Tracing.Tests
-{
-    class EventPipeSmoke
-    {
-        private static int allocIterations = 10000;
-        private static bool zapDisabled = Int32.Parse(Environment.GetEnvironmentVariable("COMPlus_ZapDisable") ?? "0") > 0;
-        private static int trivialSize = zapDisabled ? 64 * 1024 : 1 * 1024 * 1024;
-
-        static int Main(string[] args)
-        {
-            using (var netPerfFile = NetPerfFile.Create(args))
-            {
-                Console.WriteLine("\tStart: Enable tracing.");
-                TraceControl.EnableDefault(netPerfFile.Path);
-                Console.WriteLine("\tEnd: Enable tracing.\n");
-
-                Console.WriteLine("\tStart: Allocation.");
-                // Allocate for allocIterations iterations.
-                for (int i = 0; i < allocIterations; i++)
-                {
-                    GC.KeepAlive(new object());
-                }
-                Console.WriteLine("\tEnd: Allocation.\n");
-
-                Console.WriteLine("\tStart: Disable tracing.");
-                TraceControl.Disable();
-                Console.WriteLine("\tEnd: Disable tracing.\n");
-
-                FileInfo outputMeta = new FileInfo(netPerfFile.Path);
-                Console.WriteLine("\tExpecting at least {0} bytes of data", trivialSize);
-                Console.WriteLine("\tCreated {0} bytes of data", outputMeta.Length);
-
-                return outputMeta.Length > trivialSize ? 100 : 0;
-            }
-        }
-    }
-}
diff --git a/tests/src/tracing/eventsourcesmoke/EventSourceSmoke.cs b/tests/src/tracing/eventsourcesmoke/EventSourceSmoke.cs
deleted file mode 100644 (file)
index f0873bc..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-using System;
-using System.IO;
-using System.Diagnostics.Tracing;
-using Tracing.Tests.Common;
-
-namespace Tracing.Tests
-{
-    [EventSource(Name = "SimpleEventSource")]
-    class SimpleEventSource : EventSource
-    {
-        public SimpleEventSource() : base(true) { }
-
-        [Event(1)]
-        internal void MathResult(int x, int y, int z, string formula) { this.WriteEvent(1, x, y, z, formula); }
-    }
-
-    class EventPipeSmoke
-    {
-        private static int messageIterations = 10000;
-        private static int trivialSize = 0x100000;
-
-        public static TraceConfiguration GetConfig(EventSource eventSource, string outputFile="default.netperf")
-        {
-            // Setup the configuration values.
-            uint circularBufferMB = 1024; // 1 GB
-            uint level = 5;//(uint)EventLevel.Informational;
-            TimeSpan profSampleDelay = TimeSpan.FromMilliseconds(1);
-
-            // Create a new instance of EventPipeConfiguration.
-            TraceConfiguration config = new TraceConfiguration(outputFile, circularBufferMB);
-            // Setup the provider values.
-            // Public provider.
-            string providerName = eventSource.Name;
-            UInt64 keywords = 0xffffffffffffffff;
-
-            // Enable the provider.
-            config.EnableProvider(providerName, keywords, level);
-
-            // Set the sampling rate.
-            config.SetSamplingRate(profSampleDelay);
-
-            return config;
-        }
-
-        static int Main(string[] args)
-        {
-            using (var netPerfFile = NetPerfFile.Create(args))
-            {
-                SimpleEventSource eventSource = new SimpleEventSource();
-
-                Console.WriteLine("\tStart: Enable tracing.");
-                TraceControl.Enable(GetConfig(eventSource, netPerfFile.Path));
-                Console.WriteLine("\tEnd: Enable tracing.\n");
-
-                Console.WriteLine("\tStart: Messaging.");
-                // Send messages
-                // Use random numbers and addition as a simple, human readble checksum
-                Random generator = new Random();
-                for (int i = 0; i < messageIterations; i++)
-                {
-                    int x = generator.Next(1, 1000);
-                    int y = generator.Next(1, 1000);
-                    string formula = String.Format("{0} + {1} = {2}", x, y, x + y);
-
-                    eventSource.MathResult(x, y, x + y, formula);
-                }
-                Console.WriteLine("\tEnd: Messaging.\n");
-
-                Console.WriteLine("\tStart: Disable tracing.");
-                TraceControl.Disable();
-                Console.WriteLine("\tEnd: Disable tracing.\n");
-
-                FileInfo outputMeta = new FileInfo(netPerfFile.Path);
-                Console.WriteLine("\tCreated {0} bytes of data", outputMeta.Length);
-
-                return outputMeta.Length > trivialSize ? 100 : -1;
-            }
-        }
-    }
-}
index 2fbaad1..3c91359 100644 (file)
@@ -4,6 +4,7 @@ using System.Collections.Generic;
 using Tracing.Tests.Common;
 using System.Diagnostics.Tracing;
 using Microsoft.Diagnostics.Tracing;
+using Microsoft.Diagnostics.Tracing.Etlx;
 using Microsoft.Diagnostics.Tracing.Parsers;
 using Microsoft.Diagnostics.Tracing.Parsers.Clr;
 
@@ -77,7 +78,7 @@ namespace Tracing.Tests
 
                 Console.WriteLine("\tStart: Processing events from file.");
                 int msgCount = 0;
-                using (var trace = TraceEventDispatcher.GetDispatcherFromFileName(netPerfFile.Path))
+                using (var trace = new TraceLog(TraceLog.CreateFromEventPipeDataFile(netPerfFile.Path)).Events.GetSource())
                 {
                     var names = new HashSet<string>();
 
index 833146e..0bf6d8f 100644 (file)
@@ -12,7 +12,7 @@
     <CLRTestKind>BuildAndRun</CLRTestKind>
     <DefineConstants>$(DefineConstants);STATIC</DefineConstants>
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
-    <CLRTestPriority>1</CLRTestPriority>
+    <CLRTestPriority>0</CLRTestPriority>
   </PropertyGroup>
   <!-- Default configurations to help VS understand the configurations -->
   <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'"></PropertyGroup>
diff --git a/tests/src/tracing/tracevalidation/rundown/Rundown.cs b/tests/src/tracing/tracevalidation/rundown/Rundown.cs
new file mode 100644 (file)
index 0000000..6b064d2
--- /dev/null
@@ -0,0 +1,73 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using Tracing.Tests.Common;
+using Microsoft.Diagnostics.Tracing;
+using Microsoft.Diagnostics.Tracing.Parsers;
+using Microsoft.Diagnostics.Tracing.Parsers.Clr;
+
+namespace Tracing.Tests
+{
+    public static class TraceValidationRundown
+    {
+        public static int Main(string[] args)
+        {
+            // Additional assemblies will be seen, but these are ones we must see
+            string[] AssembliesExpected = new string[] {
+                "rundown", // this assembly
+                "System.Runtime",
+                "Microsoft.Diagnostics.Tracing.TraceEvent",
+                "System.Diagnostics.Tracing",
+                "System.Private.CoreLib"
+            };
+
+            using (var netPerfFile = NetPerfFile.Create(args))
+            {
+                Console.WriteLine("\tStart: Enable tracing.");
+                TraceControl.EnableDefault(netPerfFile.Path);
+                Console.WriteLine("\tEnd: Enable tracing.\n");
+
+                // Since all we care about is rundown, there is nothing to do there
+
+                Console.WriteLine("\tStart: Disable tracing.");
+                TraceControl.Disable();
+                Console.WriteLine("\tEnd: Disable tracing.\n");
+
+                Console.WriteLine("\tStart: Process the trace file.");
+
+                var assembliesLoaded = new HashSet<string>();
+                int nonMatchingEventCount = 0;
+
+                using (var trace = TraceEventDispatcher.GetDispatcherFromFileName(netPerfFile.Path))
+                {
+                    var rundownParser = new ClrRundownTraceEventParser(trace);
+
+                    rundownParser.LoaderAssemblyDCStop += delegate(AssemblyLoadUnloadTraceData data)
+                    {
+                        var nameIndex = Array.IndexOf(data.PayloadNames, ("FullyQualifiedAssemblyName"));
+                        if(nameIndex >= 0)
+                        {
+                            // Add the assembly name to a set to verify later
+                            assembliesLoaded.Add(((string)data.PayloadValue(nameIndex)).Split(',')[0]);
+                        }
+                        else
+                        {
+                            nonMatchingEventCount++;
+                        }
+                    };
+
+                    trace.Process();
+                }
+                Console.WriteLine("\tEnd: Processing events from file.\n");
+
+                foreach (var name in AssembliesExpected)
+                {
+                    Assert.True($"Assembly {name} in loaded assemblies", assembliesLoaded.Contains(name));
+                }
+                Assert.Equal(nameof(nonMatchingEventCount), nonMatchingEventCount, 0);
+            }
+
+            return 100;
+        }
+    }
+}
@@ -11,7 +11,6 @@
     <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
     <CLRTestKind>BuildAndRun</CLRTestKind>
     <DefineConstants>$(DefineConstants);STATIC</DefineConstants>
-    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <CLRTestPriority>0</CLRTestPriority>
   </PropertyGroup>
   <!-- Default configurations to help VS understand the configurations -->
@@ -23,8 +22,8 @@
     </CodeAnalysisDependentAssemblyPaths>
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="EventPipeSmoke.cs" />
-    <ProjectReference Include="../common/common.csproj" />
+    <Compile Include="Rundown.cs" />
+    <ProjectReference Include="../../common/common.csproj" />
   </ItemGroup>
   <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
 </Project>
\ No newline at end of file