summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanner Gooding <tagoo@outlook.com>2018-02-16 23:10:18 -0800
committerTanner Gooding <tagoo@outlook.com>2018-02-21 22:42:13 -0800
commit7c90b467d072b11c08804a3bb33f3d71f67a6e49 (patch)
treeb0b31a5698a5d39847f72633451102d76e851ca6
parent9f08404d97b0c1ee0d1bcabb8046e3efb49163c0 (diff)
downloadcoreclr-7c90b467d072b11c08804a3bb33f3d71f67a6e49.tar.gz
coreclr-7c90b467d072b11c08804a3bb33f3d71f67a6e49.tar.bz2
coreclr-7c90b467d072b11c08804a3bb33f3d71f67a6e49.zip
Updating the x86 hardware intrinsic test templates to allow more configurability
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/Add.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/Add.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/AddSubtract.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/AddSubtract.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/And.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/And.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/AndNot.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/AndNot.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj16
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj16
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/BlendVariable.Double.cs91
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/BlendVariable.Single.cs91
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/Divide.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/Divide.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateEvenIndexed.Double.cs65
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateEvenIndexed.Single.cs65
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateOddIndexed.Single.cs65
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/Max.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/Max.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/Min.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/Min.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/Multiply.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/Multiply.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/Or.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/Or.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/Program.Avx.cs4
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/Subtract.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/Subtract.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/Xor.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx/Xor.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Byte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.SByte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Byte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.SByte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Byte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.SByte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Average.Byte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Average.UInt16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/BlendVariable.Byte.cs91
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/BlendVariable.SByte.cs91
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Byte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.SByte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.SByte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Byte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.SByte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Program.Avx2.cs2
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Byte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.SByte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Byte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.SByte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanCmpOpTest.template146
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanCmpOpTest_DataTable.cs10
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx480
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleBinOpTest.template165
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleBinOpTest_DataTable.cs11
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleTernOpTest.template211
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleTernOpTest_DataTable.cs14
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleUnOpTest.template131
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleUnOpTest_DataTable.cs8
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/Add.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/AddScalar.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/And.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/AndNot.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqual.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualOrderedScalar.Boolean.cs (renamed from tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualOrderedScalar.Single.cs)80
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualScalar.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualUnorderedScalar.Boolean.cs (renamed from tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualUnorderedScalar.Single.cs)80
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThan.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqual.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualOrderedScalar.Boolean.cs (renamed from tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualOrderedScalar.Single.cs)80
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualScalar.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualUnorderedScalar.Boolean.cs (renamed from tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualUnorderedScalar.Single.cs)80
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrderedScalar.Boolean.cs (renamed from tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrderedScalar.Single.cs)80
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanScalar.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanUnorderedScalar.Boolean.cs (renamed from tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanUnorderedScalar.Single.cs)80
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThan.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqual.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualOrderedScalar.Boolean.cs (renamed from tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualOrderedScalar.Single.cs)80
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualScalar.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualUnorderedScalar.Boolean.cs (renamed from tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualUnorderedScalar.Single.cs)80
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrderedScalar.Boolean.cs (renamed from tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrderedScalar.Single.cs)80
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanScalar.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanUnorderedScalar.Boolean.cs (renamed from tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanUnorderedScalar.Single.cs)80
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqual.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualOrderedScalar.Boolean.cs (renamed from tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualOrderedScalar.Single.cs)80
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualScalar.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualUnorderedScalar.Boolean.cs (renamed from tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualUnorderedScalar.Single.cs)80
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThan.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqual.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqualScalar.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanScalar.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThan.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqual.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqualScalar.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanScalar.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrdered.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrderedScalar.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnordered.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnorderedScalar.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/Divide.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/DivideScalar.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/Max.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/MaxScalar.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/Min.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/MinScalar.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/Multiply.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/MultiplyScalar.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/Or.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/Program.Sse.cs24
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/Sse_r.csproj24
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/Sse_ro.csproj24
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/Subtract.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/SubtractScalar.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse/Xor.Single.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Byte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.SByte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Byte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.SByte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Byte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.SByte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Byte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Int16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Int32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.SByte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.UInt16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.UInt32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Int16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Int32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.SByte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThanOrEqual.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Int16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Int32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.SByte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThanOrEqual.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotEqual.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThan.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThanOrEqual.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThan.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThanOrEqual.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareOrdered.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareUnordered.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Divide.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Byte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Int16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Byte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Int16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Multiply.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Byte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.SByte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Byte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.SByte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Byte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Double.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.SByte.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt16.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt32.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse41/CompareEqual.Int64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse41/CompareEqual.UInt64.cs75
-rw-r--r--tests/src/JIT/HardwareIntrinsics/X86/Sse42/CompareGreaterThan.Int64.cs75
248 files changed, 11163 insertions, 7617 deletions
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Add.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Add.Double.cs
index d959ba4c69..797828aa5e 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Add.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Add.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AddDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Double> _fld1;
private Vector256<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__AddDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Double> left, Vector256<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(left[i] + right[i]) != BitConverter.DoubleToInt64Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Add)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Add)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Add.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Add.Single.cs
index d5e9952075..12a068fbdb 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Add.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Add.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AddSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector256<Single> _clsVar1;
private static Vector256<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Single> _fld1;
private Vector256<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__AddSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Single> left, Vector256<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i] + right[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Add)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Add)}<Single>(Vector256<Single>, Vector256<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/AddSubtract.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/AddSubtract.Double.cs
index ef0429fe31..19b16438ef 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/AddSubtract.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/AddSubtract.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AddSubtractDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Double> _fld1;
private Vector256<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__AddSubtractDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddSubtractDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Double> left, Vector256<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (((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]))))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.AddSubtract)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.AddSubtract)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/AddSubtract.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/AddSubtract.Single.cs
index 1baab98c3b..dcea453e43 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/AddSubtract.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/AddSubtract.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AddSubtractSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector256<Single> _clsVar1;
private static Vector256<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Single> _fld1;
private Vector256<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__AddSubtractSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddSubtractSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Single> left, Vector256<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (((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]))))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.AddSubtract)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.AddSubtract)}<Single>(Vector256<Single>, Vector256<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/And.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/And.Double.cs
index ca134aa271..6869532508 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/And.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/And.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Double> _fld1;
private Vector256<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__AndDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Double> left, Vector256<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((BitConverter.DoubleToInt64Bits(left[i]) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.And)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.And)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/And.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/And.Single.cs
index ecbb3612f1..1172954115 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/And.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/And.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector256<Single> _clsVar1;
private static Vector256<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Single> _fld1;
private Vector256<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__AndSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Single> left, Vector256<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((BitConverter.SingleToInt32Bits(left[i]) & BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.And)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.And)}<Single>(Vector256<Single>, Vector256<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/AndNot.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/AndNot.Double.cs
index f15a56060c..d41872c0a2 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/AndNot.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/AndNot.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndNotDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Double> _fld1;
private Vector256<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__AndNotDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Double> left, Vector256<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (((~BitConverter.DoubleToInt64Bits(left[i])) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.AndNot)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.AndNot)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/AndNot.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/AndNot.Single.cs
index 692cc8dda3..afa57f1981 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/AndNot.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/AndNot.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndNotSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector256<Single> _clsVar1;
private static Vector256<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Single> _fld1;
private Vector256<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__AndNotSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Single> left, Vector256<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (((~BitConverter.SingleToInt32Bits(left[i])) & BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.AndNot)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.AndNot)}<Single>(Vector256<Single>, Vector256<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj
index eee332db94..7b93bec63f 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_r.csproj
@@ -30,30 +30,30 @@
<Compile Include="Add.Double.cs" />
<Compile Include="Add.Single.cs" />
<Compile Include="AddSubtract.Double.cs" />
- <Compile Include="AddSubtract.Single.cs" />
+ <Compile Include="AddSubtract.Single.cs" />
<Compile Include="And.Double.cs" />
<Compile Include="And.Single.cs" />
<Compile Include="AndNot.Double.cs" />
<Compile Include="AndNot.Single.cs" />
<Compile Include="BlendVariable.Double.cs" />
- <Compile Include="BlendVariable.Single.cs" />
+ <Compile Include="BlendVariable.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="DuplicateEvenIndexed.Single.cs" />
+ <Compile Include="DuplicateOddIndexed.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="Subtract.Double.cs" />
<Compile Include="Subtract.Single.cs" />
<Compile Include="Xor.Double.cs"/>
<Compile Include="Xor.Single.cs"/>
- <Compile Include="Divide.Double.cs"/>
- <Compile Include="Divide.Single.cs"/>
- <Compile Include="Or.Double.cs"/>
- <Compile Include="Or.Single.cs"/>
<Compile Include="Program.Avx.cs" />
<Compile Include="..\Shared\Program.cs" />
<Compile Include="..\Shared\SimpleBinOpTest_DataTable.cs" />
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj
index a0f0cc49a7..672241dc90 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Avx_ro.csproj
@@ -30,30 +30,30 @@
<Compile Include="Add.Double.cs" />
<Compile Include="Add.Single.cs" />
<Compile Include="AddSubtract.Double.cs" />
- <Compile Include="AddSubtract.Single.cs" />
+ <Compile Include="AddSubtract.Single.cs" />
<Compile Include="And.Double.cs" />
<Compile Include="And.Single.cs" />
<Compile Include="AndNot.Double.cs" />
<Compile Include="AndNot.Single.cs" />
<Compile Include="BlendVariable.Double.cs" />
- <Compile Include="BlendVariable.Single.cs" />
+ <Compile Include="BlendVariable.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="DuplicateEvenIndexed.Single.cs" />
+ <Compile Include="DuplicateOddIndexed.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="Subtract.Double.cs" />
<Compile Include="Subtract.Single.cs" />
<Compile Include="Xor.Double.cs"/>
<Compile Include="Xor.Single.cs"/>
- <Compile Include="Divide.Double.cs"/>
- <Compile Include="Divide.Single.cs"/>
- <Compile Include="Or.Double.cs"/>
- <Compile Include="Or.Single.cs"/>
<Compile Include="Program.Avx.cs" />
<Compile Include="..\Shared\Program.cs" />
<Compile Include="..\Shared\SimpleBinOpTest_DataTable.cs" />
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/BlendVariable.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/BlendVariable.Double.cs
index 02a21c8526..5e5270e42a 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/BlendVariable.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/BlendVariable.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,11 +86,15 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleTernaryOpTest__BlendVariableDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
- private static Double[] _data3 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int Op3ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
+ private static Double[] _data3 = new Double[Op3ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
@@ -91,15 +104,17 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Double> _fld2;
private Vector256<Double> _fld3;
- private SimpleTernaryOpTest__DataTable<Double> _dataTable;
+ private SimpleTernaryOpTest__DataTable<Double, Double, Double, Double> _dataTable;
static SimpleTernaryOpTest__BlendVariableDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); _data3[i] = (double)(((i % 2) == 0) ? -0.0 : 1.0); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
+ for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(((i % 2) == 0) ? -0.0 : 1.0); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar3), ref Unsafe.As<Double, byte>(ref _data3[0]), VectorSize);
}
@@ -109,13 +124,17 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); _data3[i] = (double)(((i % 2) == 0) ? -0.0 : 1.0); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
+ for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(((i % 2) == 0) ? -0.0 : 1.0); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld3), ref Unsafe.As<Double, byte>(ref _data3[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); _data3[i] = (double)(((i % 2) == 0) ? -0.0 : 1.0); }
- _dataTable = new SimpleTernaryOpTest__DataTable<Double>(_data1, _data2, _data3, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (double)(((i % 2) == 0) ? -0.0 : 1.0); }
+ _dataTable = new SimpleTernaryOpTest__DataTable<Double, Double, Double, Double>(_data1, _data2, _data3, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
@@ -275,10 +294,10 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Double> firstOp, Vector256<Double> secondOp, Vector256<Double> thirdOp, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] inArray3 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] inArray3 = new Double[Op3ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), firstOp);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), secondOp);
@@ -290,10 +309,10 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* firstOp, void* secondOp, void* thirdOp, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] inArray3 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] inArray3 = new Double[Op3ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(secondOp), VectorSize);
@@ -311,7 +330,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < firstOp.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (((BitConverter.DoubleToInt64Bits(thirdOp[i]) >> 63) & 1) == 1 ? BitConverter.DoubleToInt64Bits(secondOp[i]) != BitConverter.DoubleToInt64Bits(result[i]) : BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i]))
{
@@ -323,11 +342,11 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.BlendVariable)}<Double>: {method} failed:");
- Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
- Console.WriteLine($" secondOp: ({string.Join(", ", secondOp)})");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.BlendVariable)}<Double>(Vector256<Double>, Vector256<Double>, Vector256<Double>): {method} failed:");
+ Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
+ Console.WriteLine($" secondOp: ({string.Join(", ", secondOp)})");
Console.WriteLine($" thirdOp: ({string.Join(", ", thirdOp)})");
- Console.WriteLine($" result: ({string.Join(", ", result)})");
+ Console.WriteLine($" result: ({string.Join(", ", result)})");
Console.WriteLine();
}
}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/BlendVariable.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/BlendVariable.Single.cs
index 975370a51a..e3540d85ca 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/BlendVariable.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/BlendVariable.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,11 +86,15 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleTernaryOpTest__BlendVariableSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
- private static Single[] _data3 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int Op3ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
+ private static Single[] _data3 = new Single[Op3ElementCount];
private static Vector256<Single> _clsVar1;
private static Vector256<Single> _clsVar2;
@@ -91,15 +104,17 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Single> _fld2;
private Vector256<Single> _fld3;
- private SimpleTernaryOpTest__DataTable<Single> _dataTable;
+ private SimpleTernaryOpTest__DataTable<Single, Single, Single, Single> _dataTable;
static SimpleTernaryOpTest__BlendVariableSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); _data3[i] = (float)(((i % 2) == 0) ? -0.0 : 1.0); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
+ for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(((i % 2) == 0) ? -0.0 : 1.0); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar3), ref Unsafe.As<Single, byte>(ref _data3[0]), VectorSize);
}
@@ -109,13 +124,17 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); _data3[i] = (float)(((i % 2) == 0) ? -0.0 : 1.0); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
+ for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(((i % 2) == 0) ? -0.0 : 1.0); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld3), ref Unsafe.As<Single, byte>(ref _data3[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); _data3[i] = (float)(((i % 2) == 0) ? -0.0 : 1.0); }
- _dataTable = new SimpleTernaryOpTest__DataTable<Single>(_data1, _data2, _data3, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (float)(((i % 2) == 0) ? -0.0 : 1.0); }
+ _dataTable = new SimpleTernaryOpTest__DataTable<Single, Single, Single, Single>(_data1, _data2, _data3, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
@@ -275,10 +294,10 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Single> firstOp, Vector256<Single> secondOp, Vector256<Single> thirdOp, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] inArray3 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] inArray3 = new Single[Op3ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), firstOp);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), secondOp);
@@ -290,10 +309,10 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* firstOp, void* secondOp, void* thirdOp, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] inArray3 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] inArray3 = new Single[Op3ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(secondOp), VectorSize);
@@ -311,7 +330,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < firstOp.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (((BitConverter.SingleToInt32Bits(thirdOp[i]) >> 31) & 1) == 1 ? BitConverter.SingleToInt32Bits(secondOp[i]) != BitConverter.SingleToInt32Bits(result[i]) : BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -323,11 +342,11 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.BlendVariable)}<Single>: {method} failed:");
- Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
- Console.WriteLine($" secondOp: ({string.Join(", ", secondOp)})");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.BlendVariable)}<Single>(Vector256<Single>, Vector256<Single>, Vector256<Single>): {method} failed:");
+ Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
+ Console.WriteLine($" secondOp: ({string.Join(", ", secondOp)})");
Console.WriteLine($" thirdOp: ({string.Join(", ", thirdOp)})");
- Console.WriteLine($" result: ({string.Join(", ", result)})");
+ Console.WriteLine($" result: ({string.Join(", ", result)})");
Console.WriteLine();
}
}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Divide.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Divide.Double.cs
index 83404d052b..93fbf1e844 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Divide.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Divide.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__DivideDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Double> _fld1;
private Vector256<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__DivideDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__DivideDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Double> left, Vector256<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(left[i] / right[i]) != BitConverter.DoubleToInt64Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Divide)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Divide)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Divide.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Divide.Single.cs
index 19cb9d1077..cd77bf07e0 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Divide.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Divide.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__DivideSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector256<Single> _clsVar1;
private static Vector256<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Single> _fld1;
private Vector256<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__DivideSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__DivideSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Single> left, Vector256<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i] / right[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Divide)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Divide)}<Single>(Vector256<Single>, Vector256<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateEvenIndexed.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateEvenIndexed.Double.cs
index c00c1a802f..282e821626 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateEvenIndexed.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateEvenIndexed.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,21 +86,23 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleUnaryOpTest__DuplicateEvenIndexedDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data = new Double[ElementCount];
+ 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> _dataTable;
+ private SimpleUnaryOpTest__DataTable<Double, Double> _dataTable;
static SimpleUnaryOpTest__DuplicateEvenIndexedDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+ 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);
}
@@ -101,11 +112,11 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
+ 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 < ElementCount; i++) { _data[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleUnaryOpTest__DataTable<Double>(_data, new Double[ElementCount], 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;
@@ -245,8 +256,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Double> firstOp, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ 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);
@@ -256,8 +267,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ 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);
@@ -273,7 +284,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < firstOp.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((i % 2 == 0) ? (BitConverter.DoubleToInt64Bits(firstOp[i]) != BitConverter.DoubleToInt64Bits(result[i])) : (BitConverter.DoubleToInt64Bits(firstOp[i - 1]) != BitConverter.DoubleToInt64Bits(result[i])))
{
@@ -285,9 +296,9 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.DuplicateEvenIndexed)}<Double>: {method} failed:");
- Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
- Console.WriteLine($" result: ({string.Join(", ", result)})");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.DuplicateEvenIndexed)}<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/DuplicateEvenIndexed.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateEvenIndexed.Single.cs
index a8e98a8755..e27647475d 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateEvenIndexed.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateEvenIndexed.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,21 +86,23 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleUnaryOpTest__DuplicateEvenIndexedSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data = new Single[ElementCount];
+ 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> _dataTable;
+ private SimpleUnaryOpTest__DataTable<Single, Single> _dataTable;
static SimpleUnaryOpTest__DuplicateEvenIndexedSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+ 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);
}
@@ -101,11 +112,11 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+ 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 < ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleUnaryOpTest__DataTable<Single>(_data, new Single[ElementCount], 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;
@@ -245,8 +256,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Single> firstOp, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ 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);
@@ -256,8 +267,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ 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);
@@ -273,7 +284,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < firstOp.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((i % 2 == 0) ? (BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])) : (BitConverter.SingleToInt32Bits(firstOp[i - 1]) != BitConverter.SingleToInt32Bits(result[i])))
{
@@ -285,9 +296,9 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.DuplicateEvenIndexed)}<Single>: {method} failed:");
- Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
- Console.WriteLine($" result: ({string.Join(", ", result)})");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.DuplicateEvenIndexed)}<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/DuplicateOddIndexed.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateOddIndexed.Single.cs
index 61d9f47cd8..bcfb0bae67 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateOddIndexed.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/DuplicateOddIndexed.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,21 +86,23 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleUnaryOpTest__DuplicateOddIndexedSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data = new Single[ElementCount];
+ 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> _dataTable;
+ private SimpleUnaryOpTest__DataTable<Single, Single> _dataTable;
static SimpleUnaryOpTest__DuplicateOddIndexedSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+ 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);
}
@@ -101,11 +112,11 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
+ 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 < ElementCount; i++) { _data[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleUnaryOpTest__DataTable<Single>(_data, new Single[ElementCount], 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;
@@ -245,8 +256,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Single> firstOp, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ 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);
@@ -256,8 +267,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ 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);
@@ -273,7 +284,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < firstOp.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((i % 2 == 0) ? (BitConverter.SingleToInt32Bits(firstOp[i + 1]) != BitConverter.SingleToInt32Bits(result[i])) : (BitConverter.SingleToInt32Bits(firstOp[i]) != BitConverter.SingleToInt32Bits(result[i])))
{
@@ -285,9 +296,9 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.DuplicateOddIndexed)}<Single>: {method} failed:");
- Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
- Console.WriteLine($" result: ({string.Join(", ", result)})");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.DuplicateOddIndexed)}<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/Max.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Max.Double.cs
index 635c3ac57f..93ab3211a8 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Max.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Max.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__MaxDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Double> _fld1;
private Vector256<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__MaxDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MaxDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Double> left, Vector256<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(Math.Max(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Max)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Max)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Max.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Max.Single.cs
index e0aa936360..7f123d213f 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Max.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Max.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__MaxSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector256<Single> _clsVar1;
private static Vector256<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Single> _fld1;
private Vector256<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__MaxSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MaxSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Single> left, Vector256<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(MathF.Max(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Max)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Max)}<Single>(Vector256<Single>, Vector256<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Min.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Min.Double.cs
index a658223853..0bcaf5e6d3 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Min.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Min.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__MinDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Double> _fld1;
private Vector256<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__MinDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MinDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Double> left, Vector256<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(Math.Min(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Min)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Min)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Min.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Min.Single.cs
index f3114c2cc4..077cb78764 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Min.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Min.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__MinSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector256<Single> _clsVar1;
private static Vector256<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Single> _fld1;
private Vector256<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__MinSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MinSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Single> left, Vector256<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(MathF.Min(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Min)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Min)}<Single>(Vector256<Single>, Vector256<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Multiply.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Multiply.Double.cs
index ef71aa02cf..9a54d57587 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Multiply.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Multiply.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__MultiplyDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Double> _fld1;
private Vector256<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__MultiplyDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MultiplyDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Double> left, Vector256<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(left[i] * right[i]) != BitConverter.DoubleToInt64Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Multiply)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Multiply)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Multiply.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Multiply.Single.cs
index ca8c02093c..026186b4de 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Multiply.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Multiply.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__MultiplySingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector256<Single> _clsVar1;
private static Vector256<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Single> _fld1;
private Vector256<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__MultiplySingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MultiplySingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Single> left, Vector256<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i] * right[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Multiply)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Multiply)}<Single>(Vector256<Single>, Vector256<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Or.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Or.Double.cs
index 8de2d96a46..dd39908c17 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Or.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Or.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__OrDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Double> _fld1;
private Vector256<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__OrDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Double> left, Vector256<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((BitConverter.DoubleToInt64Bits(left[i]) | BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Or)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Or)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Or.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Or.Single.cs
index 46d732481d..682db8f5aa 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Or.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Or.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__OrSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector256<Single> _clsVar1;
private static Vector256<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Single> _fld1;
private Vector256<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__OrSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Single> left, Vector256<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((BitConverter.SingleToInt32Bits(left[i]) | BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Or)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Or)}<Single>(Vector256<Single>, Vector256<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Program.Avx.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Program.Avx.cs
index e1aa5d0f3f..bfe07b8809 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Program.Avx.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Program.Avx.cs
@@ -22,11 +22,11 @@ namespace JIT.HardwareIntrinsics.X86
["AndNot.Single"] = AndNotSingle,
["BlendVariable.Double"] = BlendVariableDouble,
["BlendVariable.Single"] = BlendVariableSingle,
+ ["Divide.Double"] = DivideDouble,
+ ["Divide.Single"] = DivideSingle,
["DuplicateEvenIndexed.Double"] = DuplicateEvenIndexedDouble,
["DuplicateEvenIndexed.Single"] = DuplicateEvenIndexedSingle,
["DuplicateOddIndexed.Single"] = DuplicateOddIndexedSingle,
- ["Divide.Double"] = DivideDouble,
- ["Divide.Single"] = DivideSingle,
["Max.Double"] = MaxDouble,
["Max.Single"] = MaxSingle,
["Min.Double"] = MinDouble,
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Subtract.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Subtract.Double.cs
index cf26d5593d..6354cd2338 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Subtract.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Subtract.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__SubtractDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Double> _fld1;
private Vector256<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__SubtractDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Double> left, Vector256<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(left[i] - right[i]) != BitConverter.DoubleToInt64Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Subtract)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Subtract)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Subtract.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Subtract.Single.cs
index 8b0f7956c1..e99ae8c63f 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Subtract.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Subtract.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__SubtractSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector256<Single> _clsVar1;
private static Vector256<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Single> _fld1;
private Vector256<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__SubtractSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Single> left, Vector256<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i] - right[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Subtract)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Subtract)}<Single>(Vector256<Single>, Vector256<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Xor.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Xor.Double.cs
index ea5a3c6e45..7cecba5d15 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Xor.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Xor.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__XorDouble
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector256<Double> _clsVar1;
private static Vector256<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Double> _fld1;
private Vector256<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__XorDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Double> left, Vector256<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((BitConverter.DoubleToInt64Bits(left[i]) ^ BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Xor)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Xor)}<Double>(Vector256<Double>, Vector256<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Xor.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Xor.Single.cs
index 1543cbeccb..6e7ee76d14 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx/Xor.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx/Xor.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__XorSingle
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector256<Single> _clsVar1;
private static Vector256<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Single> _fld1;
private Vector256<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__XorSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Avx.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Single> left, Vector256<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((BitConverter.SingleToInt32Bits(left[i]) ^ BitConverter.SingleToInt32Bits(right[i])) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Xor)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx)}.{nameof(Avx.Xor)}<Single>(Vector256<Single>, Vector256<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Byte.cs
index 4b9d0156c1..ebc9e612e0 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Byte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Byte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AddByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Byte> _fld1;
private Vector256<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__AddByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AddByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], 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 SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Byte> left, Vector256<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)(left[i] + right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int16.cs
index dad7c0ce30..b0669b58e3 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AddInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Int16> _fld1;
private Vector256<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__AddInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AddInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Int16> left, Vector256<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((short)(left[i] + right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int32.cs
index d7c82a5c90..2d09a5e2cb 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AddInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Int32> _fld1;
private Vector256<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__AddInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AddInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Int32> left, Vector256<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((int)(left[i] + right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int64.cs
index 54995ce0bf..f15961c5c2 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.Int64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AddInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Int64> _fld1;
private Vector256<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__AddInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AddInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Int64> left, Vector256<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((long)(left[i] + right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.SByte.cs
index 329cd939e7..828f12bd3e 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.SByte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.SByte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AddSByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<SByte> _fld1;
private Vector256<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__AddSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AddSByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], 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 SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<SByte> left, Vector256<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((sbyte)(left[i] + right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt16.cs
index 7dcce389aa..bc2576bfe8 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AddUInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<UInt16> _fld1;
private Vector256<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__AddUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AddUInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<UInt16> left, Vector256<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)(left[i] + right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt32.cs
index d181b3752e..4a31709b16 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AddUInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<UInt32> _fld1;
private Vector256<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__AddUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AddUInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<UInt32> left, Vector256<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((uint)(left[i] + right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt64.cs
index 718e1bc44c..ee588fc61b 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Add.UInt64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AddUInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<UInt64> _fld1;
private Vector256<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__AddUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AddUInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<UInt64> left, Vector256<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ulong)(left[i] + right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Add)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Byte.cs
index b5da02bda8..4978ea8751 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Byte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Byte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Byte> _fld1;
private Vector256<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__AndByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AndByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], 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 SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Byte> left, Vector256<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)(left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int16.cs
index 131f039639..5ae85bda6a 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Int16> _fld1;
private Vector256<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__AndInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AndInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Int16> left, Vector256<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((short)(left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int32.cs
index 8439e64fe3..f33c3b1caa 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Int32> _fld1;
private Vector256<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__AndInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AndInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Int32> left, Vector256<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((int)(left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int64.cs
index f731442158..b197174e88 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.Int64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Int64> _fld1;
private Vector256<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__AndInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AndInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Int64> left, Vector256<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((long)(left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.SByte.cs
index 3e8db26777..19661540ab 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.SByte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.SByte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndSByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<SByte> _fld1;
private Vector256<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__AndSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AndSByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], 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 SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<SByte> left, Vector256<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((sbyte)(left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt16.cs
index 966f809bcf..80e9d0fa17 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndUInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<UInt16> _fld1;
private Vector256<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__AndUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AndUInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<UInt16> left, Vector256<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)(left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt32.cs
index 6a4e5c8518..b8d9296094 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndUInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<UInt32> _fld1;
private Vector256<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__AndUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AndUInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<UInt32> left, Vector256<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((uint)(left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt64.cs
index b8123df194..e3051aa2d9 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/And.UInt64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndUInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<UInt64> _fld1;
private Vector256<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__AndUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AndUInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<UInt64> left, Vector256<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ulong)(left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.And)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Byte.cs
index a77d3c6c51..f2016ae596 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Byte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Byte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndNotByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Byte> _fld1;
private Vector256<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__AndNotByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AndNotByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], 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 SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Byte> left, Vector256<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)(~left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int16.cs
index 155f217453..0f9aa8da60 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndNotInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Int16> _fld1;
private Vector256<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__AndNotInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AndNotInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Int16> left, Vector256<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((short)(~left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int32.cs
index 1cf28a2318..a6ad3c04b9 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndNotInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Int32> _fld1;
private Vector256<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__AndNotInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AndNotInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Int32> left, Vector256<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((int)(~left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int64.cs
index 93167c534e..d6fd1d2e02 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.Int64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndNotInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Int64> _fld1;
private Vector256<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__AndNotInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AndNotInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Int64> left, Vector256<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((long)(~left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.SByte.cs
index 14e97cc10e..2a6a14d245 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.SByte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.SByte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndNotSByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<SByte> _fld1;
private Vector256<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__AndNotSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AndNotSByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], 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 SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<SByte> left, Vector256<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((sbyte)(~left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt16.cs
index e639399d18..28950d63b3 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndNotUInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<UInt16> _fld1;
private Vector256<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__AndNotUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AndNotUInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<UInt16> left, Vector256<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)(~left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt32.cs
index 9b8d04c906..279b8d2ed9 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndNotUInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<UInt32> _fld1;
private Vector256<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__AndNotUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AndNotUInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<UInt32> left, Vector256<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((uint)(~left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt64.cs
index 2304d30448..6a28bcbfba 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/AndNot.UInt64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndNotUInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<UInt64> _fld1;
private Vector256<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__AndNotUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AndNotUInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<UInt64> left, Vector256<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ulong)(~left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.AndNot)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Average.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Average.Byte.cs
index 255946625d..f919d19e7e 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Average.Byte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Average.Byte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AverageByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Byte> _fld1;
private Vector256<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__AverageByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__AverageByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], 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 SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Byte> left, Vector256<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)((left[i] + right[i] + 1) >> 1) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Average)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Average)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Average.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Average.UInt16.cs
index 88d8b3757f..d8895402a7 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Average.UInt16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Average.UInt16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AverageUInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<UInt16> _fld1;
private Vector256<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__AverageUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (ushort)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(short.MinValue, short.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(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AverageUInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (ushort)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(short.MinValue, short.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(short.MinValue, short.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 < ElementCount; i++) { _data1[i] = (ushort)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (ushort)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (ushort)(random.Next(short.MinValue, short.MaxValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<UInt16> left, Vector256<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)((left[i] + right[i] + 1) >> 1) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Average)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Average)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BlendVariable.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BlendVariable.Byte.cs
index 59831cf384..0ae9c7a97a 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BlendVariable.Byte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BlendVariable.Byte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,11 +86,15 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleTernaryOpTest__BlendVariableByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
- private static Byte[] _data3 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int Op3ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
+ private static Byte[] _data3 = new Byte[Op3ElementCount];
private static Vector256<Byte> _clsVar1;
private static Vector256<Byte> _clsVar2;
@@ -91,15 +104,17 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Byte> _fld2;
private Vector256<Byte> _fld3;
- private SimpleTernaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleTernaryOpTest__DataTable<Byte, Byte, Byte, Byte> _dataTable;
static SimpleTernaryOpTest__BlendVariableByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); _data3[i] = (byte)(((i % 2) == 0) ? 128 : 1); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ 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);
+ for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (byte)(((i % 2) == 0) ? 128 : 1); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar3), ref Unsafe.As<Byte, byte>(ref _data3[0]), VectorSize);
}
@@ -109,13 +124,17 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); _data3[i] = (byte)(((i % 2) == 0) ? 128 : 1); }
+ 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 < Op3ElementCount; i++) { _data3[i] = (byte)(((i % 2) == 0) ? 128 : 1); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _fld3), ref Unsafe.As<Byte, byte>(ref _data3[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); _data3[i] = (byte)(((i % 2) == 0) ? 128 : 1); }
- _dataTable = new SimpleTernaryOpTest__DataTable<Byte>(_data1, _data2, _data3, new Byte[ElementCount], 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)); }
+ for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (byte)(((i % 2) == 0) ? 128 : 1); }
+ _dataTable = new SimpleTernaryOpTest__DataTable<Byte, Byte, Byte, Byte>(_data1, _data2, _data3, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -275,10 +294,10 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Byte> firstOp, Vector256<Byte> secondOp, Vector256<Byte> thirdOp, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] inArray3 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] inArray3 = new Byte[Op3ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), firstOp);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), secondOp);
@@ -290,10 +309,10 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* firstOp, void* secondOp, void* thirdOp, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] inArray3 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] inArray3 = new Byte[Op3ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Byte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(secondOp), VectorSize);
@@ -311,7 +330,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < firstOp.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (((thirdOp[i] >> 7) & 1) == 1 ? secondOp[i] != result[i] : firstOp[i] != result[i])
{
@@ -323,11 +342,11 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.BlendVariable)}<Byte>: {method} failed:");
- Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
- Console.WriteLine($" secondOp: ({string.Join(", ", secondOp)})");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.BlendVariable)}<Byte>(Vector256<Byte>, Vector256<Byte>, Vector256<Byte>): {method} failed:");
+ Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
+ Console.WriteLine($" secondOp: ({string.Join(", ", secondOp)})");
Console.WriteLine($" thirdOp: ({string.Join(", ", thirdOp)})");
- Console.WriteLine($" result: ({string.Join(", ", result)})");
+ Console.WriteLine($" result: ({string.Join(", ", result)})");
Console.WriteLine();
}
}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BlendVariable.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BlendVariable.SByte.cs
index 3b29d78702..4beb856bb5 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BlendVariable.SByte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/BlendVariable.SByte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,11 +86,15 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleTernaryOpTest__BlendVariableSByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
- private static SByte[] _data3 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int Op3ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
+ private static SByte[] _data3 = new SByte[Op3ElementCount];
private static Vector256<SByte> _clsVar1;
private static Vector256<SByte> _clsVar2;
@@ -91,15 +104,17 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<SByte> _fld2;
private Vector256<SByte> _fld3;
- private SimpleTernaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleTernaryOpTest__DataTable<SByte, SByte, SByte, SByte> _dataTable;
static SimpleTernaryOpTest__BlendVariableSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data3[i] = (sbyte)(((i % 2) == 0) ? -128 : 1); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ 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);
+ for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (sbyte)(((i % 2) == 0) ? -128 : 1); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar3), ref Unsafe.As<SByte, byte>(ref _data3[0]), VectorSize);
}
@@ -109,13 +124,17 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data3[i] = (sbyte)(((i % 2) == 0) ? -128 : 1); }
+ 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 < Op3ElementCount; i++) { _data3[i] = (sbyte)(((i % 2) == 0) ? -128 : 1); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _fld3), ref Unsafe.As<SByte, byte>(ref _data3[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data3[i] = (sbyte)(((i % 2) == 0) ? -128 : 1); }
- _dataTable = new SimpleTernaryOpTest__DataTable<SByte>(_data1, _data2, _data3, new SByte[ElementCount], 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)); }
+ for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = (sbyte)(((i % 2) == 0) ? -128 : 1); }
+ _dataTable = new SimpleTernaryOpTest__DataTable<SByte, SByte, SByte, SByte>(_data1, _data2, _data3, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -275,10 +294,10 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<SByte> firstOp, Vector256<SByte> secondOp, Vector256<SByte> thirdOp, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] inArray3 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] inArray3 = new SByte[Op3ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), firstOp);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), secondOp);
@@ -290,10 +309,10 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* firstOp, void* secondOp, void* thirdOp, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] inArray3 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] inArray3 = new SByte[Op3ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<SByte, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(secondOp), VectorSize);
@@ -311,7 +330,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < firstOp.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (((thirdOp[i] >> 7) & 1) == 1 ? secondOp[i] != result[i] : firstOp[i] != result[i])
{
@@ -323,11 +342,11 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.BlendVariable)}<SByte>: {method} failed:");
- Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
- Console.WriteLine($" secondOp: ({string.Join(", ", secondOp)})");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.BlendVariable)}<SByte>(Vector256<SByte>, Vector256<SByte>, Vector256<SByte>): {method} failed:");
+ Console.WriteLine($" firstOp: ({string.Join(", ", firstOp)})");
+ Console.WriteLine($" secondOp: ({string.Join(", ", secondOp)})");
Console.WriteLine($" thirdOp: ({string.Join(", ", thirdOp)})");
- Console.WriteLine($" result: ({string.Join(", ", result)})");
+ Console.WriteLine($" result: ({string.Join(", ", result)})");
Console.WriteLine();
}
}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Byte.cs
index 6cb863dfef..dd20210f2a 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Byte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Byte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareEqualByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Byte> _fld1;
private Vector256<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__CompareEqualByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__CompareEqualByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], 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 SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Byte> left, Vector256<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((byte)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int16.cs
index 6d0b082cd2..945535b401 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareEqualInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Int16> _fld1;
private Vector256<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__CompareEqualInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__CompareEqualInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Int16> left, Vector256<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((short)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int32.cs
index 0de2ff23cf..cf82a0fd9e 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareEqualInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Int32> _fld1;
private Vector256<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__CompareEqualInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__CompareEqualInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Int32> left, Vector256<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((int)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int64.cs
index f87a109f68..14d7d7d01b 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.Int64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareEqualInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Int64> _fld1;
private Vector256<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__CompareEqualInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__CompareEqualInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Int64> left, Vector256<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((long)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.SByte.cs
index 970035daa1..dd8d09c421 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.SByte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.SByte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareEqualSByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<SByte> _fld1;
private Vector256<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__CompareEqualSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__CompareEqualSByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], 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 SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<SByte> left, Vector256<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((sbyte)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt16.cs
index df817dc9ae..dbb3e8e6e2 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareEqualUInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<UInt16> _fld1;
private Vector256<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__CompareEqualUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__CompareEqualUInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<UInt16> left, Vector256<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((ushort)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt32.cs
index fe0bb91028..14d6fdee69 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareEqualUInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<UInt32> _fld1;
private Vector256<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__CompareEqualUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__CompareEqualUInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<UInt32> left, Vector256<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((uint)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt64.cs
index b8c1a89555..e419d9d50d 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareEqual.UInt64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareEqualUInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<UInt64> _fld1;
private Vector256<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__CompareEqualUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__CompareEqualUInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<UInt64> left, Vector256<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((ulong)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareEqual)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int16.cs
index be3ebf2aec..0023989b3b 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Int16> _fld1;
private Vector256<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__CompareGreaterThanInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Int16> left, Vector256<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] > right[i]) ? unchecked((short)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareGreaterThan)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareGreaterThan)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int32.cs
index 0af2511cab..e921b601e1 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Int32> _fld1;
private Vector256<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__CompareGreaterThanInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Int32> left, Vector256<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] > right[i]) ? unchecked((int)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareGreaterThan)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareGreaterThan)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int64.cs
index 5d294b05cc..5ac1316ad1 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.Int64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Int64> _fld1;
private Vector256<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__CompareGreaterThanInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Int64> left, Vector256<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] > right[i]) ? unchecked((long)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareGreaterThan)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareGreaterThan)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.SByte.cs
index 63b2941941..3b3eed6914 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.SByte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/CompareGreaterThan.SByte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanSByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<SByte> _fld1;
private Vector256<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__CompareGreaterThanSByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], 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 SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<SByte> left, Vector256<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] > right[i]) ? unchecked((sbyte)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareGreaterThan)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.CompareGreaterThan)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Byte.cs
index f40d225bdc..f18d55b594 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Byte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Byte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__OrByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Byte> _fld1;
private Vector256<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__OrByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__OrByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], 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 SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Byte> left, Vector256<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)(left[i] | right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int16.cs
index 53d834e609..d74fbdf53e 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__OrInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Int16> _fld1;
private Vector256<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__OrInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__OrInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Int16> left, Vector256<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((short)(left[i] | right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int32.cs
index 14c9b228a7..b34a427820 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__OrInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Int32> _fld1;
private Vector256<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__OrInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__OrInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Int32> left, Vector256<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((int)(left[i] | right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int64.cs
index ebf4f354e7..178237473d 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.Int64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__OrInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Int64> _fld1;
private Vector256<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__OrInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__OrInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Int64> left, Vector256<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((long)(left[i] | right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.SByte.cs
index a1f9f14948..fa7e9c54cb 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.SByte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.SByte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__OrSByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<SByte> _fld1;
private Vector256<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__OrSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__OrSByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], 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 SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<SByte> left, Vector256<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((sbyte)(left[i] | right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt16.cs
index 980e1e8e19..a5f48f5550 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__OrUInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<UInt16> _fld1;
private Vector256<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__OrUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__OrUInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<UInt16> left, Vector256<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)(left[i] | right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt32.cs
index c68f7b3e9b..289d048511 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__OrUInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<UInt32> _fld1;
private Vector256<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__OrUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__OrUInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<UInt32> left, Vector256<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((uint)(left[i] | right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt64.cs
index 766ac31a0f..98e2349c71 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Or.UInt64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__OrUInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<UInt64> _fld1;
private Vector256<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__OrUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__OrUInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<UInt64> left, Vector256<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ulong)(left[i] | right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Or)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Program.Avx2.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Program.Avx2.cs
index 7349091bd5..df966962b8 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Program.Avx2.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Program.Avx2.cs
@@ -38,6 +38,8 @@ namespace JIT.HardwareIntrinsics.X86
["AndNot.UInt64"] = AndNotUInt64,
["Average.Byte"] = AverageByte,
["Average.UInt16"] = AverageUInt16,
+ ["BlendVariable.Byte"] = BlendVariableByte,
+ ["BlendVariable.SByte"] = BlendVariableSByte,
["CompareEqual.Byte"] = CompareEqualByte,
["CompareEqual.Int16"] = CompareEqualInt16,
["CompareEqual.Int32"] = CompareEqualInt32,
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Byte.cs
index 225fe1f4fe..17c4065edb 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Byte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Byte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__SubtractByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Byte> _fld1;
private Vector256<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__SubtractByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__SubtractByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], 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 SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Byte> left, Vector256<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)(left[i] - right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int16.cs
index bb55accbfc..75e824a81f 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__SubtractInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Int16> _fld1;
private Vector256<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__SubtractInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__SubtractInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Int16> left, Vector256<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((short)(left[i] - right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int32.cs
index 6c7cefa7bc..b1135f71a4 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__SubtractInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Int32> _fld1;
private Vector256<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__SubtractInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__SubtractInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Int32> left, Vector256<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((int)(left[i] - right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int64.cs
index 0810b77aa9..ae319c8eaa 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.Int64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__SubtractInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Int64> _fld1;
private Vector256<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__SubtractInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__SubtractInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Int64> left, Vector256<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((long)(left[i] - right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.SByte.cs
index 672127c6ee..32b6fd0dbf 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.SByte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.SByte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__SubtractSByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<SByte> _fld1;
private Vector256<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__SubtractSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__SubtractSByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], 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 SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<SByte> left, Vector256<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((sbyte)(left[i] - right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt16.cs
index b041a3f48a..9ff706862b 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__SubtractUInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<UInt16> _fld1;
private Vector256<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__SubtractUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__SubtractUInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<UInt16> left, Vector256<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)(left[i] - right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt32.cs
index ce33dca254..adf1dd7cf8 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__SubtractUInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<UInt32> _fld1;
private Vector256<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__SubtractUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__SubtractUInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<UInt32> left, Vector256<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((uint)(left[i] - right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt64.cs
index 7c701917cc..868a810104 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Subtract.UInt64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__SubtractUInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<UInt64> _fld1;
private Vector256<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__SubtractUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__SubtractUInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<UInt64> left, Vector256<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ulong)(left[i] - right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Subtract)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Byte.cs
index dd4afb88a1..9f978854ad 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Byte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Byte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__XorByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Byte> _fld1;
private Vector256<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__XorByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__XorByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], 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 SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Byte> left, Vector256<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)(left[i] ^ right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int16.cs
index b50a6c54dc..051d37d02a 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__XorInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Int16> _fld1;
private Vector256<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__XorInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__XorInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Int16> left, Vector256<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((short)(left[i] ^ right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int32.cs
index 27480880f9..232765e01f 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__XorInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Int32> _fld1;
private Vector256<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__XorInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__XorInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Int32> left, Vector256<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((int)(left[i] ^ right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int64.cs
index 97ea4e15a9..358ea889a4 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.Int64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__XorInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<Int64> _fld1;
private Vector256<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__XorInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__XorInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<Int64> left, Vector256<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((long)(left[i] ^ right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.SByte.cs
index 504091f1f7..6cd6442e3a 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.SByte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.SByte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__XorSByte
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<SByte> _fld1;
private Vector256<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__XorSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__XorSByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], 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 SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<SByte> left, Vector256<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((sbyte)(left[i] ^ right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt16.cs
index b0ef51d8e1..2a1d24dbca 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__XorUInt16
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<UInt16> _fld1;
private Vector256<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__XorUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__XorUInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<UInt16> left, Vector256<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)(left[i] ^ right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt32.cs
index 8038b1c5a5..1e1b9185fa 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__XorUInt32
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<UInt32> _fld1;
private Vector256<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__XorUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__XorUInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<UInt32> left, Vector256<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((uint)(left[i] ^ right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt64.cs
index 84dfe7ada2..9415610619 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Avx2/Xor.UInt64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Avx.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ 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 a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__XorUInt64
{
private const int VectorSize = 32;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = 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;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector256<UInt64> _fld1;
private Vector256<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__XorUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector256<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ 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 SimpleBinaryOpTest__XorUInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ 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 < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Avx2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector256<UInt64> left, Vector256<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ulong)(left[i] ^ right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Avx2)}.{nameof(Avx2.Xor)}<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)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanCmpOpTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanCmpOpTest.template
index a3d275190a..58df4e18b5 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanCmpOpTest.template
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanCmpOpTest.template
@@ -19,29 +19,35 @@ namespace JIT.HardwareIntrinsics.X86
{{
public static partial class Program
{{
- private static void {2}{3}()
+ private static void {2}{4}()
{{
- var test = new BooleanComparisonOpTest__{2}{3}();
+ var test = new BooleanComparisonOpTest__{2}{4}();
if (test.IsSupported)
{{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if ({1}.IsSupported)
+ {{
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }}
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if ({1}.IsSupported)
+ {{
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }}
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if ({1}.IsSupported)
+ {{
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }}
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -74,43 +83,48 @@ namespace JIT.HardwareIntrinsics.X86
}}
}}
- public sealed unsafe class BooleanComparisonOpTest__{2}{3}
+ public sealed unsafe class BooleanComparisonOpTest__{2}{4}
{{
- private const int VectorSize = {5};
- private const int ElementCount = VectorSize / sizeof({3});
+ private const int VectorSize = {9};
- private static {3}[] _data1 = new {3}[ElementCount];
- private static {3}[] _data2 = new {3}[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof({6});
+ private const int Op2ElementCount = VectorSize / sizeof({8});
- private static {4}<{3}> _clsVar1;
- private static {4}<{3}> _clsVar2;
+ private static {6}[] _data1 = new {6}[Op1ElementCount];
+ private static {8}[] _data2 = new {8}[Op2ElementCount];
- private {4}<{3}> _fld1;
- private {4}<{3}> _fld2;
+ private static {5}<{6}> _clsVar1;
+ private static {7}<{8}> _clsVar2;
- private BooleanComparisonOpTest__DataTable<{3}> _dataTable;
+ private {5}<{6}> _fld1;
+ private {7}<{8}> _fld2;
- static BooleanComparisonOpTest__{2}{3}()
+ private BooleanComparisonOpTest__DataTable<{6}, {8}> _dataTable;
+
+ static BooleanComparisonOpTest__{2}{4}()
{{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) {{ _data1[i] = {6}; _data2[i] = {6}; }}
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _clsVar1), ref Unsafe.As<{3}, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _clsVar2), ref Unsafe.As<{3}, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) {{ _data1[i] = {10}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{5}<{6}>, byte>(ref _clsVar1), ref Unsafe.As<{6}, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) {{ _data2[i] = {11}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{7}<{8}>, byte>(ref _clsVar2), ref Unsafe.As<{8}, byte>(ref _data2[0]), VectorSize);
}}
- public BooleanComparisonOpTest__{2}{3}()
+ public BooleanComparisonOpTest__{2}{4}()
{{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) {{ _data1[i] = {6}; _data2[i] = {6}; }}
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _fld1), ref Unsafe.As<{3}, byte>(ref _data1[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _fld2), ref Unsafe.As<{3}, byte>(ref _data2[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) {{ _data1[i] = {10}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{5}<{6}>, byte>(ref _fld1), ref Unsafe.As<{6}, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) {{ _data2[i] = {11}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{7}<{8}>, byte>(ref _fld2), ref Unsafe.As<{8}, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) {{ _data1[i] = {6}; _data2[i] = {6}; }}
- _dataTable = new BooleanComparisonOpTest__DataTable<{3}>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) {{ _data1[i] = {10}; }}
+ for (var i = 0; i < Op2ElementCount; i++) {{ _data2[i] = {11}; }}
+ _dataTable = new BooleanComparisonOpTest__DataTable<{6}, {8}>(_data1, _data2, VectorSize);
}}
public bool IsSupported => {0}.IsSupported;
@@ -120,8 +134,8 @@ namespace JIT.HardwareIntrinsics.X86
public void RunBasicScenario_UnsafeRead()
{{
var result = {0}.{2}(
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray1Ptr),
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray2Ptr)
+ Unsafe.Read<{5}<{6}>>(_dataTable.inArray1Ptr),
+ Unsafe.Read<{7}<{8}>>(_dataTable.inArray2Ptr)
);
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
@@ -130,8 +144,8 @@ namespace JIT.HardwareIntrinsics.X86
public void RunBasicScenario_Load()
{{
var result = {0}.{2}(
- {1}.Load{4}(({3}*)(_dataTable.inArray1Ptr)),
- {1}.Load{4}(({3}*)(_dataTable.inArray2Ptr))
+ {1}.Load{5}(({6}*)(_dataTable.inArray1Ptr)),
+ {1}.Load{7}(({8}*)(_dataTable.inArray2Ptr))
);
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
@@ -140,8 +154,8 @@ namespace JIT.HardwareIntrinsics.X86
public void RunBasicScenario_LoadAligned()
{{
var result = {0}.{2}(
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray1Ptr)),
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray2Ptr))
+ {1}.LoadAligned{5}(({6}*)(_dataTable.inArray1Ptr)),
+ {1}.LoadAligned{7}(({8}*)(_dataTable.inArray2Ptr))
);
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, result);
@@ -149,10 +163,10 @@ namespace JIT.HardwareIntrinsics.X86
public void RunReflectionScenario_UnsafeRead()
{{
- var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({4}<{3}>), typeof({4}<{3}>) }})
+ var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>) }})
.Invoke(null, new object[] {{
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray1Ptr),
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray2Ptr)
+ Unsafe.Read<{5}<{6}>>(_dataTable.inArray1Ptr),
+ Unsafe.Read<{7}<{8}>>(_dataTable.inArray2Ptr)
}});
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
@@ -160,10 +174,10 @@ namespace JIT.HardwareIntrinsics.X86
public void RunReflectionScenario_Load()
{{
- var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({4}<{3}>), typeof({4}<{3}>) }})
+ var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>) }})
.Invoke(null, new object[] {{
- {1}.Load{4}(({3}*)(_dataTable.inArray1Ptr)),
- {1}.Load{4}(({3}*)(_dataTable.inArray2Ptr))
+ {1}.Load{5}(({6}*)(_dataTable.inArray1Ptr)),
+ {1}.Load{7}(({8}*)(_dataTable.inArray2Ptr))
}});
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
@@ -171,10 +185,10 @@ namespace JIT.HardwareIntrinsics.X86
public void RunReflectionScenario_LoadAligned()
{{
- var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({4}<{3}>), typeof({4}<{3}>) }})
+ var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>) }})
.Invoke(null, new object[] {{
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray1Ptr)),
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray2Ptr))
+ {1}.LoadAligned{5}(({6}*)(_dataTable.inArray1Ptr)),
+ {1}.LoadAligned{7}(({8}*)(_dataTable.inArray2Ptr))
}});
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, (bool)(result));
@@ -192,8 +206,8 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclVarScenario_UnsafeRead()
{{
- var left = Unsafe.Read<{4}<{3}>>(_dataTable.inArray1Ptr);
- var right = Unsafe.Read<{4}<{3}>>(_dataTable.inArray2Ptr);
+ var left = Unsafe.Read<{5}<{6}>>(_dataTable.inArray1Ptr);
+ var right = Unsafe.Read<{7}<{8}>>(_dataTable.inArray2Ptr);
var result = {0}.{2}(left, right);
ValidateResult(left, right, result);
@@ -201,8 +215,8 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclVarScenario_Load()
{{
- var left = {1}.Load{4}(({3}*)(_dataTable.inArray1Ptr));
- var right = {1}.Load{4}(({3}*)(_dataTable.inArray2Ptr));
+ var left = {1}.Load{5}(({6}*)(_dataTable.inArray1Ptr));
+ var right = {1}.Load{7}(({8}*)(_dataTable.inArray2Ptr));
var result = {0}.{2}(left, right);
ValidateResult(left, right, result);
@@ -210,8 +224,8 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclVarScenario_LoadAligned()
{{
- var left = {1}.LoadAligned{4}(({3}*)(_dataTable.inArray1Ptr));
- var right = {1}.LoadAligned{4}(({3}*)(_dataTable.inArray2Ptr));
+ var left = {1}.LoadAligned{5}(({6}*)(_dataTable.inArray1Ptr));
+ var right = {1}.LoadAligned{7}(({8}*)(_dataTable.inArray2Ptr));
var result = {0}.{2}(left, right);
ValidateResult(left, right, result);
@@ -219,7 +233,7 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclFldScenario()
{{
- var test = new BooleanComparisonOpTest__{2}{3}();
+ var test = new BooleanComparisonOpTest__{2}{4}();
var result = {0}.{2}(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
@@ -246,10 +260,10 @@ namespace JIT.HardwareIntrinsics.X86
}}
}}
- private void ValidateResult({4}<{3}> left, {4}<{3}> right, bool result, [CallerMemberName] string method = "")
+ private void ValidateResult({5}<{6}> left, {7}<{8}> right, bool result, [CallerMemberName] string method = "")
{{
- {3}[] inArray1 = new {3}[ElementCount];
- {3}[] inArray2 = new {3}[ElementCount];
+ {6}[] inArray1 = new {6}[Op1ElementCount];
+ {8}[] inArray2 = new {8}[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -259,22 +273,22 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{{
- {3}[] inArray1 = new {3}[ElementCount];
- {3}[] inArray2 = new {3}[ElementCount];
+ {6}[] inArray1 = new {6}[Op1ElementCount];
+ {8}[] inArray2 = new {8}[Op2ElementCount];
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{6}, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{8}, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
ValidateResult(inArray1, inArray2, result, method);
}}
- private void ValidateResult({3}[] left, {3}[] right, bool result, [CallerMemberName] string method = "")
+ private void ValidateResult({6}[] left, {8}[] right, bool result, [CallerMemberName] string method = "")
{{
- if ({7})
+ if ({12})
{{
Succeeded = false;
- Console.WriteLine($"{{nameof({0})}}.{{nameof({0}.{2})}}<{3}>: {{method}} failed:");
+ Console.WriteLine($"{{nameof({0})}}.{{nameof({0}.{2})}}<{4}>({5}<{6}>, {7}<{8}>): {{method}} failed:");
Console.WriteLine($" left: ({{string.Join(", ", left)}})");
Console.WriteLine($" right: ({{string.Join(", ", right)}})");
Console.WriteLine($" result: ({{string.Join(", ", result)}})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanCmpOpTest_DataTable.cs b/tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanCmpOpTest_DataTable.cs
index 1315624e37..320c20f1dc 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanCmpOpTest_DataTable.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/BooleanCmpOpTest_DataTable.cs
@@ -10,7 +10,9 @@ using System.Runtime.Intrinsics.X86;
namespace JIT.HardwareIntrinsics.X86
{
- public unsafe struct BooleanComparisonOpTest__DataTable<T> : IDisposable where T : struct
+ public unsafe struct BooleanComparisonOpTest__DataTable<TOp1, TOp2> : IDisposable
+ where TOp1 : struct
+ where TOp2 : struct
{
private byte[] inArray1;
private byte[] inArray2;
@@ -20,7 +22,7 @@ namespace JIT.HardwareIntrinsics.X86
private byte simdSize;
- public BooleanComparisonOpTest__DataTable(T[] inArray1, T[] inArray2, int simdSize)
+ public BooleanComparisonOpTest__DataTable(TOp1[] inArray1, TOp2[] inArray2, int simdSize)
{
this.inArray1 = new byte[simdSize * 2];
this.inArray2 = new byte[simdSize * 2];
@@ -30,8 +32,8 @@ namespace JIT.HardwareIntrinsics.X86
this.simdSize = unchecked((byte)(simdSize));
- Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<T, byte>(ref inArray1[0]), this.simdSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<T, byte>(ref inArray2[0]), this.simdSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<TOp1, byte>(ref inArray1[0]), this.simdSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<TOp2, byte>(ref inArray2[0]), this.simdSize);
}
public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), simdSize);
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx b/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx
index 4a28eb3c68..2827f95b4d 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/GenerateTests.csx
@@ -20,262 +20,264 @@ using System.IO;
private static readonly (string templateFileName, string[] templateData)[] SseInputs = new []
{
- // TemplateName Isa, LoadIsa, Method, BaseType, VectorType, VectorSize, NextValue, ValidateFirstResult, ValidateRemainingResults
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Add", "Single", "Vector128", "16", "(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[] { "Sse", "Sse", "AddScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] + right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "And", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", "(BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "AndNot", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(~BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", "(~BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareEqual", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] == right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] == right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareEqualScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] == right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareEqualOrderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(left[0] == right[0]) != result"}),
- ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareEqualUnorderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(left[0] == right[0]) != result"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThan", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] > right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] > right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] > right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanOrderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(left[0] > right[0]) != result"}),
- ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanUnorderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(left[0] > right[0]) != result"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanOrEqual", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] >= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] >= right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanOrEqualScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] >= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanOrEqualOrderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(left[0] >= right[0]) != result"}),
- ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanOrEqualUnorderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(left[0] >= right[0]) != result"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareLessThan", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] < right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] < right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] < right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanOrderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(left[0] < right[0]) != result"}),
- ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanUnorderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(left[0] < right[0]) != result"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanOrEqual", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] <= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] <= right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanOrEqualScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] <= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanOrEqualOrderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(left[0] <= right[0]) != result"}),
- ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanOrEqualUnorderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(left[0] <= right[0]) != result"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotEqual", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] != right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] != right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotEqualScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] != right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareNotEqualOrderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(left[0] != right[0]) != result"}),
- ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareNotEqualUnorderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(left[0] != right[0]) != result"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotGreaterThan", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] > right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] > right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotGreaterThanScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] > right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotGreaterThanOrEqual", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] >= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] >= right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotGreaterThanOrEqualScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] >= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotLessThan", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] < right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] < right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotLessThanScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] < right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotLessThanOrEqual", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] <= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] <= right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotLessThanOrEqualScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] <= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareOrdered", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((!float.IsNaN(left[0]) && !float.IsNaN(right[0])) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((!float.IsNaN(left[i]) && !float.IsNaN(right[i])) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareOrderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((!float.IsNaN(left[0]) && !float.IsNaN(right[0])) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareUnordered", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((float.IsNaN(left[0]) || float.IsNaN(right[0])) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((float.IsNaN(left[i]) || float.IsNaN(right[i])) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareUnorderedScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((float.IsNaN(left[0]) || float.IsNaN(right[0])) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Divide", "Single", "Vector128", "16", "(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[] { "Sse", "Sse", "DivideScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] / right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Max", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(Math.Max(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(Math.Max(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "MaxScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(Math.Max(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Min", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(Math.Min(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(Math.Min(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "MinScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(Math.Min(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Multiply", "Single", "Vector128", "16", "(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[] { "Sse", "Sse", "MultiplyScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] * right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Or", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(BitConverter.SingleToInt32Bits(left[0]) | BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", "(BitConverter.SingleToInt32Bits(left[0]) | BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Subtract", "Single", "Vector128", "16", "(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[] { "Sse", "Sse", "SubtractScalar", "Single", "Vector128", "16", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] - right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
- ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Xor", "Single", "Vector128", "16", "(float)(random.NextDouble())", "(BitConverter.SingleToInt32Bits(left[0]) ^ BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", "(BitConverter.SingleToInt32Bits(left[0]) ^ BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])"}),
+ // TemplateName Isa, LoadIsa, Method, RetVectorType RetBaseType, Op1VectorType, Op1BaseType, Op2VectorType, Op2BaseType, Op3VectorType, Op3TBaseype, VectorSize, NextValueOp1, NextValueOp2, NextValueOp3, ValidateFirstResult, ValidateRemainingResults
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Add", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(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[] { "Sse", "Sse", "AddScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] + right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "And", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", "(BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "AndNot", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(~BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", "(~BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareEqual", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] == right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] == right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareEqualScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] == right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareEqualOrderedScalar", "Vector128", "Boolean", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(left[0] == right[0]) != result"}),
+ ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareEqualUnorderedScalar", "Vector128", "Boolean", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(left[0] == right[0]) != result"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThan", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] > right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] > right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] > right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanOrderedScalar", "Vector128", "Boolean", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(left[0] > right[0]) != result"}),
+ ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanUnorderedScalar", "Vector128", "Boolean", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(left[0] > right[0]) != result"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanOrEqual", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] >= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] >= right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanOrEqualScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] >= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanOrEqualOrderedScalar", "Vector128", "Boolean", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(left[0] >= right[0]) != result"}),
+ ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareGreaterThanOrEqualUnorderedScalar", "Vector128", "Boolean", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(left[0] >= right[0]) != result"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareLessThan", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] < right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] < right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] < right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanOrderedScalar", "Vector128", "Boolean", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(left[0] < right[0]) != result"}),
+ ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanUnorderedScalar", "Vector128", "Boolean", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(left[0] < right[0]) != result"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanOrEqual", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] <= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] <= right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanOrEqualScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] <= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanOrEqualOrderedScalar", "Vector128", "Boolean", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(left[0] <= right[0]) != result"}),
+ ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareLessThanOrEqualUnorderedScalar", "Vector128", "Boolean", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(left[0] <= right[0]) != result"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotEqual", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] != right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((left[i] != right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotEqualScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((left[0] != right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareNotEqualOrderedScalar", "Vector128", "Boolean", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(left[0] != right[0]) != result"}),
+ ("BooleanCmpOpTest.template", new string[] { "Sse", "Sse", "CompareNotEqualUnorderedScalar", "Vector128", "Boolean", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(left[0] != right[0]) != result"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotGreaterThan", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] > right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] > right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotGreaterThanScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] > right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotGreaterThanOrEqual", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] >= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] >= right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotGreaterThanOrEqualScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] >= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotLessThan", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] < right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] < right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotLessThanScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] < right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotLessThanOrEqual", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] <= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] <= right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareNotLessThanOrEqualScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != (!(left[0] <= right[0]) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareOrdered", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((!float.IsNaN(left[0]) && !float.IsNaN(right[0])) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((!float.IsNaN(left[i]) && !float.IsNaN(right[i])) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareOrderedScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((!float.IsNaN(left[0]) && !float.IsNaN(right[0])) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareUnordered", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((float.IsNaN(left[0]) || float.IsNaN(right[0])) ? -1 : 0)", "BitConverter.SingleToInt32Bits(result[i]) != ((float.IsNaN(left[i]) || float.IsNaN(right[i])) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "CompareUnorderedScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(result[0]) != ((float.IsNaN(left[0]) || float.IsNaN(right[0])) ? -1 : 0)", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Divide", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(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[] { "Sse", "Sse", "DivideScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] / right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Max", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(Math.Max(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(Math.Max(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "MaxScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(Math.Max(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Min", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(Math.Min(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(Math.Min(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "MinScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(Math.Min(left[0], right[0])) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Multiply", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(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[] { "Sse", "Sse", "MultiplyScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] * right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Or", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(BitConverter.SingleToInt32Bits(left[0]) | BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", "(BitConverter.SingleToInt32Bits(left[0]) | BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Subtract", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(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[] { "Sse", "Sse", "SubtractScalar", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "BitConverter.SingleToInt32Bits(left[0] - right[0]) != BitConverter.SingleToInt32Bits(result[0])", "BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i])"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse", "Sse", "Xor", "Vector128", "Single", "Vector128", "Single", "Vector128", "Single", "16", "(float)(random.NextDouble())", "(float)(random.NextDouble())", "(BitConverter.SingleToInt32Bits(left[0]) ^ BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])", "(BitConverter.SingleToInt32Bits(left[0]) ^ BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0])"}),
};
private static readonly (string templateFileName, string[] templateData)[] Sse2Inputs = new []
{
- // TemplateName Isa, LoadIsa, Method, BaseType, VectorType, VectorSize, NextValue, ValidateFirstResult, ValidateRemainingResults
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Double", "Vector128", "16", "(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[] { "Sse2", "Sse2", "Add", "Byte", "Vector128", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] + right[0]) != result[0]", "(byte)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Int16", "Vector128", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] + right[0]) != result[0]", "(short)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Int32", "Vector128", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] + right[0]) != result[0]", "(int)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Int64", "Vector128", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] + right[0]) != result[0]", "(long)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "SByte", "Vector128", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] + right[0]) != result[0]", "(sbyte)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "UInt16", "Vector128", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] + right[0]) != result[0]", "(ushort)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "UInt32", "Vector128", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] + right[0]) != result[0]", "(uint)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "UInt64", "Vector128", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] + right[0]) != result[0]", "(ulong)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Double", "Vector128", "16", "(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[] { "Sse2", "Sse2", "And", "Byte", "Vector128", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] & right[0]) != result[0]", "(byte)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Int16", "Vector128", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] & right[0]) != result[0]", "(short)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Int32", "Vector128", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] & right[0]) != result[0]", "(int)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Int64", "Vector128", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] & right[0]) != result[0]", "(long)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "SByte", "Vector128", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] & right[0]) != result[0]", "(sbyte)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "UInt16", "Vector128", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] & right[0]) != result[0]", "(ushort)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "UInt32", "Vector128", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] & right[0]) != result[0]", "(uint)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "UInt64", "Vector128", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] & right[0]) != result[0]", "(ulong)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Double", "Vector128", "16", "(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[] { "Sse2", "Sse2", "AndNot", "Byte", "Vector128", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(~left[0] & right[0]) != result[0]", "(byte)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Int16", "Vector128", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(~left[0] & right[0]) != result[0]", "(short)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Int32", "Vector128", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(~left[0] & right[0]) != result[0]", "(int)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Int64", "Vector128", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(~left[0] & right[0]) != result[0]", "(long)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "SByte", "Vector128", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(~left[0] & right[0]) != result[0]", "(sbyte)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "UInt16", "Vector128", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(~left[0] & right[0]) != result[0]", "(ushort)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "UInt32", "Vector128", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(~left[0] & right[0]) != result[0]", "(uint)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "UInt64", "Vector128", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(~left[0] & right[0]) != result[0]", "(ulong)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] == right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] == right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "Byte", "Vector128", "16", "(byte)(random.Next(0, byte.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((byte)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((byte)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "Int16", "Vector128", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((short)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((short)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "Int32", "Vector128", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((int)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((int)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "SByte", "Vector128", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((sbyte)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((sbyte)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "UInt16", "Vector128", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((ushort)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((ushort)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "UInt32", "Vector128", "16", "(uint)(random.Next(0, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((uint)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((uint)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareGreaterThan", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] > right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] > right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareGreaterThan", "Int16", "Vector128", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((short)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((short)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareGreaterThan", "Int32", "Vector128", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((int)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((int)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareGreaterThan", "SByte", "Vector128", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((sbyte)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((sbyte)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareGreaterThanOrEqual", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] >= right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] >= right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareLessThan", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] < right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] < right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareLessThan", "Int16", "Vector128", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "result[0] != ((left[0] < right[0]) ? unchecked((short)(-1)) : 0)", "result[i] != ((left[i] < right[i]) ? unchecked((short)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareLessThan", "Int32", "Vector128", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] < right[0]) ? unchecked((int)(-1)) : 0)", "result[i] != ((left[i] < right[i]) ? unchecked((int)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareLessThan", "SByte", "Vector128", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "result[0] != ((left[0] < right[0]) ? unchecked((sbyte)(-1)) : 0)", "result[i] != ((left[i] < right[i]) ? unchecked((sbyte)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareLessThanOrEqual", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] <= right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] <= right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareNotEqual", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] != right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] != right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareNotGreaterThan", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != (!(left[0] > right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] > right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareNotGreaterThanOrEqual", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != (!(left[0] >= right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] >= right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareNotLessThan", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != (!(left[0] < right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] < right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareNotLessThanOrEqual", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != (!(left[0] <= right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] <= right[i]) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareOrdered", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((!double.IsNaN(left[0]) && !double.IsNaN(right[0])) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((!double.IsNaN(left[i]) && !double.IsNaN(right[i])) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareUnordered", "Double", "Vector128", "16", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((double.IsNaN(left[0]) || double.IsNaN(right[0])) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((double.IsNaN(left[i]) || double.IsNaN(right[i])) ? -1 : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Divide", "Double", "Vector128", "16", "(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[] { "Sse2", "Sse2", "Max", "Double", "Vector128", "16", "(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[] { "Sse2", "Sse2", "Max", "Byte", "Vector128", "16", "(byte)(random.Next(0, byte.MaxValue))", "Math.Max(left[0], right[0]) != result[0]", "Math.Max(left[i], right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Max", "Int16", "Vector128", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "Math.Max(left[0], right[0]) != result[0]", "Math.Max(left[i], right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Min", "Double", "Vector128", "16", "(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[] { "Sse2", "Sse2", "Min", "Byte", "Vector128", "16", "(byte)(random.Next(0, byte.MinValue))", "Math.Min(left[0], right[0]) != result[0]", "Math.Min(left[i], right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Min", "Int16", "Vector128", "16", "(short)(random.Next(short.MinValue, short.MinValue))", "Math.Min(left[0], right[0]) != result[0]", "Math.Min(left[i], right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Multiply", "Double", "Vector128", "16", "(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[] { "Sse2", "Sse2", "Or", "Double", "Vector128", "16", "(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[] { "Sse2", "Sse2", "Or", "Byte", "Vector128", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] | right[0]) != result[0]", "(byte)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "Int16", "Vector128", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] | right[0]) != result[0]", "(short)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "Int32", "Vector128", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] | right[0]) != result[0]", "(int)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "Int64", "Vector128", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] | right[0]) != result[0]", "(long)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "SByte", "Vector128", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] | right[0]) != result[0]", "(sbyte)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "UInt16", "Vector128", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] | right[0]) != result[0]", "(ushort)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "UInt32", "Vector128", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] | right[0]) != result[0]", "(uint)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "UInt64", "Vector128", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] | right[0]) != result[0]", "(ulong)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Double", "Vector128", "16", "(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[] { "Sse2", "Sse2", "Subtract", "Byte", "Vector128", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] - right[0]) != result[0]", "(byte)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Int16", "Vector128", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] - right[0]) != result[0]", "(short)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Int32", "Vector128", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] - right[0]) != result[0]", "(int)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Int64", "Vector128", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] - right[0]) != result[0]", "(long)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "SByte", "Vector128", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] - right[0]) != result[0]", "(sbyte)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "UInt16", "Vector128", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] - right[0]) != result[0]", "(ushort)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "UInt32", "Vector128", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] - right[0]) != result[0]", "(uint)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "UInt64", "Vector128", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] - right[0]) != result[0]", "(ulong)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Double", "Vector128", "16", "(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[] { "Sse2", "Sse2", "Xor", "Byte", "Vector128", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] ^ right[0]) != result[0]", "(byte)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Int16", "Vector128", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] ^ right[0]) != result[0]", "(short)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Int32", "Vector128", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] ^ right[0]) != result[0]", "(int)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Int64", "Vector128", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] ^ right[0]) != result[0]", "(long)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "SByte", "Vector128", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] ^ right[0]) != result[0]", "(sbyte)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "UInt16", "Vector128", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] ^ right[0]) != result[0]", "(ushort)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "UInt32", "Vector128", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] ^ right[0]) != result[0]", "(uint)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "UInt64", "Vector128", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] ^ right[0]) != result[0]", "(ulong)(left[i] ^ right[i]) != result[i]"}),
+ // TemplateName Isa, LoadIsa, Method, RetVectorType, RetBaseType, Op1VectorType, Op1BaseType, Op2VectorType, Op2BaseType, Op3VectorType, Op3BaseType, VectorSize, NextValueOp1, NextValueOp2, NextValueOp3, ValidateFirstResult, ValidateRemainingResults
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(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[] { "Sse2", "Sse2", "Add", "Vector128", "Byte", "Vector128", "Byte", "Vector128", "Byte", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] + right[0]) != result[0]", "(byte)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Vector128", "Int16", "Vector128", "Int16", "Vector128", "Int16", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] + right[0]) != result[0]", "(short)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Vector128", "Int32", "Vector128", "Int32", "Vector128", "Int32", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] + right[0]) != result[0]", "(int)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Vector128", "Int64", "Vector128", "Int64", "Vector128", "Int64", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] + right[0]) != result[0]", "(long)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Vector128", "SByte", "Vector128", "SByte", "Vector128", "SByte", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] + right[0]) != result[0]", "(sbyte)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Vector128", "UInt16", "Vector128", "UInt16", "Vector128", "UInt16", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] + right[0]) != result[0]", "(ushort)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Vector128", "UInt32", "Vector128", "UInt32", "Vector128", "UInt32", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] + right[0]) != result[0]", "(uint)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Add", "Vector128", "UInt64", "Vector128", "UInt64", "Vector128", "UInt64", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] + right[0]) != result[0]", "(ulong)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(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[] { "Sse2", "Sse2", "And", "Vector128", "Byte", "Vector128", "Byte", "Vector128", "Byte", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] & right[0]) != result[0]", "(byte)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Vector128", "Int16", "Vector128", "Int16", "Vector128", "Int16", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] & right[0]) != result[0]", "(short)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Vector128", "Int32", "Vector128", "Int32", "Vector128", "Int32", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] & right[0]) != result[0]", "(int)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Vector128", "Int64", "Vector128", "Int64", "Vector128", "Int64", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] & right[0]) != result[0]", "(long)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Vector128", "SByte", "Vector128", "SByte", "Vector128", "SByte", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] & right[0]) != result[0]", "(sbyte)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Vector128", "UInt16", "Vector128", "UInt16", "Vector128", "UInt16", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] & right[0]) != result[0]", "(ushort)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Vector128", "UInt32", "Vector128", "UInt32", "Vector128", "UInt32", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] & right[0]) != result[0]", "(uint)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "And", "Vector128", "UInt64", "Vector128", "UInt64", "Vector128", "UInt64", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] & right[0]) != result[0]", "(ulong)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(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[] { "Sse2", "Sse2", "AndNot", "Vector128", "Byte", "Vector128", "Byte", "Vector128", "Byte", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(~left[0] & right[0]) != result[0]", "(byte)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Vector128", "Int16", "Vector128", "Int16", "Vector128", "Int16", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(~left[0] & right[0]) != result[0]", "(short)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Vector128", "Int32", "Vector128", "Int32", "Vector128", "Int32", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(~left[0] & right[0]) != result[0]", "(int)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Vector128", "Int64", "Vector128", "Int64", "Vector128", "Int64", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(~left[0] & right[0]) != result[0]", "(long)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Vector128", "SByte", "Vector128", "SByte", "Vector128", "SByte", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(~left[0] & right[0]) != result[0]", "(sbyte)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Vector128", "UInt16", "Vector128", "UInt16", "Vector128", "UInt16", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(~left[0] & right[0]) != result[0]", "(ushort)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Vector128", "UInt32", "Vector128", "UInt32", "Vector128", "UInt32", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "(uint)(~left[0] & right[0]) != result[0]", "(uint)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "AndNot", "Vector128", "UInt64", "Vector128", "UInt64", "Vector128", "UInt64", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(~left[0] & right[0]) != result[0]", "(ulong)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] == right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] == right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "Vector128", "Byte", "Vector128", "Byte", "Vector128", "Byte", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((byte)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((byte)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "Vector128", "Int16", "Vector128", "Int16", "Vector128", "Int16", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((short)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((short)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "Vector128", "Int32", "Vector128", "Int32", "Vector128", "Int32", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((int)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((int)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "Vector128", "SByte", "Vector128", "SByte", "Vector128", "SByte", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((sbyte)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((sbyte)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "Vector128", "UInt16", "Vector128", "UInt16", "Vector128", "UInt16", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((ushort)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((ushort)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareEqual", "Vector128", "UInt32", "Vector128", "UInt32", "Vector128", "UInt32", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((uint)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((uint)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareGreaterThan", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] > right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] > right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareGreaterThan", "Vector128", "Int16", "Vector128", "Int16", "Vector128", "Int16", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((short)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((short)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareGreaterThan", "Vector128", "Int32", "Vector128", "Int32", "Vector128", "Int32", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((int)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((int)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareGreaterThan", "Vector128", "SByte", "Vector128", "SByte", "Vector128", "SByte", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((sbyte)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((sbyte)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareGreaterThanOrEqual", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] >= right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] >= right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareLessThan", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] < right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] < right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareLessThan", "Vector128", "Int16", "Vector128", "Int16", "Vector128", "Int16", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "result[0] != ((left[0] < right[0]) ? unchecked((short)(-1)) : 0)", "result[i] != ((left[i] < right[i]) ? unchecked((short)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareLessThan", "Vector128", "Int32", "Vector128", "Int32", "Vector128", "Int32", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] < right[0]) ? unchecked((int)(-1)) : 0)", "result[i] != ((left[i] < right[i]) ? unchecked((int)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareLessThan", "Vector128", "SByte", "Vector128", "SByte", "Vector128", "SByte", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "result[0] != ((left[0] < right[0]) ? unchecked((sbyte)(-1)) : 0)", "result[i] != ((left[i] < right[i]) ? unchecked((sbyte)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareLessThanOrEqual", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] <= right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] <= right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareNotEqual", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((left[0] != right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] != right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareNotGreaterThan", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != (!(left[0] > right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] > right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareNotGreaterThanOrEqual", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != (!(left[0] >= right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] >= right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareNotLessThan", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != (!(left[0] < right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] < right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareNotLessThanOrEqual", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != (!(left[0] <= right[0]) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] <= right[i]) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareOrdered", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((!double.IsNaN(left[0]) && !double.IsNaN(right[0])) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((!double.IsNaN(left[i]) && !double.IsNaN(right[i])) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "CompareUnordered", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(double)(random.NextDouble())", "(double)(random.NextDouble())", "BitConverter.DoubleToInt64Bits(result[0]) != ((double.IsNaN(left[0]) || double.IsNaN(right[0])) ? -1 : 0)", "BitConverter.DoubleToInt64Bits(result[i]) != ((double.IsNaN(left[i]) || double.IsNaN(right[i])) ? -1 : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Divide", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(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[] { "Sse2", "Sse2", "Max", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(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[] { "Sse2", "Sse2", "Max", "Vector128", "Byte", "Vector128", "Byte", "Vector128", "Byte", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "Math.Max(left[0], right[0]) != result[0]", "Math.Max(left[i], right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Max", "Vector128", "Int16", "Vector128", "Int16", "Vector128", "Int16", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "Math.Max(left[0], right[0]) != result[0]", "Math.Max(left[i], right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Min", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(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[] { "Sse2", "Sse2", "Min", "Vector128", "Byte", "Vector128", "Byte", "Vector128", "Byte", "16", "(byte)(random.Next(0, byte.MinValue))", "(byte)(random.Next(0, byte.MinValue))", "Math.Min(left[0], right[0]) != result[0]", "Math.Min(left[i], right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Min", "Vector128", "Int16", "Vector128", "Int16", "Vector128", "Int16", "16", "(short)(random.Next(short.MinValue, short.MinValue))", "(short)(random.Next(short.MinValue, short.MinValue))", "Math.Min(left[0], right[0]) != result[0]", "Math.Min(left[i], right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Multiply", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(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[] { "Sse2", "Sse2", "Or", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(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[] { "Sse2", "Sse2", "Or", "Vector128", "Byte", "Vector128", "Byte", "Vector128", "Byte", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] | right[0]) != result[0]", "(byte)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "Vector128", "Int16", "Vector128", "Int16", "Vector128", "Int16", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] | right[0]) != result[0]", "(short)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "Vector128", "Int32", "Vector128", "Int32", "Vector128", "Int32", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] | right[0]) != result[0]", "(int)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "Vector128", "Int64", "Vector128", "Int64", "Vector128", "Int64", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] | right[0]) != result[0]", "(long)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "Vector128", "SByte", "Vector128", "SByte", "Vector128", "SByte", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] | right[0]) != result[0]", "(sbyte)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "Vector128", "UInt16", "Vector128", "UInt16", "Vector128", "UInt16", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] | right[0]) != result[0]", "(ushort)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "Vector128", "UInt32", "Vector128", "UInt32", "Vector128", "UInt32", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] | right[0]) != result[0]", "(uint)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Or", "Vector128", "UInt64", "Vector128", "UInt64", "Vector128", "UInt64", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] | right[0]) != result[0]", "(ulong)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(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[] { "Sse2", "Sse2", "Subtract", "Vector128", "Byte", "Vector128", "Byte", "Vector128", "Byte", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] - right[0]) != result[0]", "(byte)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Vector128", "Int16", "Vector128", "Int16", "Vector128", "Int16", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] - right[0]) != result[0]", "(short)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Vector128", "Int32", "Vector128", "Int32", "Vector128", "Int32", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] - right[0]) != result[0]", "(int)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Vector128", "Int64", "Vector128", "Int64", "Vector128", "Int64", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] - right[0]) != result[0]", "(long)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Vector128", "SByte", "Vector128", "SByte", "Vector128", "SByte", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] - right[0]) != result[0]", "(sbyte)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Vector128", "UInt16", "Vector128", "UInt16", "Vector128", "UInt16", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] - right[0]) != result[0]", "(ushort)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Vector128", "UInt32", "Vector128", "UInt32", "Vector128", "UInt32", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] - right[0]) != result[0]", "(uint)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Subtract", "Vector128", "UInt64", "Vector128", "UInt64", "Vector128", "UInt64", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] - right[0]) != result[0]", "(ulong)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Vector128", "Double", "Vector128", "Double", "Vector128", "Double", "16", "(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[] { "Sse2", "Sse2", "Xor", "Vector128", "Byte", "Vector128", "Byte", "Vector128", "Byte", "16", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] ^ right[0]) != result[0]", "(byte)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Vector128", "Int16", "Vector128", "Int16", "Vector128", "Int16", "16", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] ^ right[0]) != result[0]", "(short)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Vector128", "Int32", "Vector128", "Int32", "Vector128", "Int32", "16", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] ^ right[0]) != result[0]", "(int)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Vector128", "Int64", "Vector128", "Int64", "Vector128", "Int64", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] ^ right[0]) != result[0]", "(long)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Vector128", "SByte", "Vector128", "SByte", "Vector128", "SByte", "16", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] ^ right[0]) != result[0]", "(sbyte)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Vector128", "UInt16", "Vector128", "UInt16", "Vector128", "UInt16", "16", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] ^ right[0]) != result[0]", "(ushort)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Vector128", "UInt32", "Vector128", "UInt32", "Vector128", "UInt32", "16", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] ^ right[0]) != result[0]", "(uint)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse2", "Sse2", "Xor", "Vector128", "UInt64", "Vector128", "UInt64", "Vector128", "UInt64", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] ^ right[0]) != result[0]", "(ulong)(left[i] ^ right[i]) != result[i]"}),
};
private static readonly (string templateFileName, string[] templateData)[] Sse41Inputs = new []
{
- // TemplateName Isa, LoadIsa, Method, BaseType, VectorType, VectorSize, NextValue, ValidateFirstResult, ValidateRemainingResults
- ("SimpleBinOpTest.template", new string[] { "Sse41", "Sse2", "CompareEqual", "Int64", "Vector128", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((long)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((long)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Sse41", "Sse2", "CompareEqual", "UInt64", "Vector128", "16", "(ulong)(random.Next(0, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((ulong)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((ulong)(-1)) : 0)"}),
+ // TemplateName Isa, LoadIsa, Method, RetVectorType, RetBaseType, Op1VectorType, Op1BaseType, Op2VectorType, Op2BaseType, Op3VectorType, Op3BaseType, VectorSize, NextValueOp1, NextValueOp2, NextValueOp3, ValidateFirstResult, ValidateRemainingResults
+ ("SimpleBinOpTest.template", new string[] { "Sse41", "Sse2", "CompareEqual", "Vector128", "Int64", "Vector128", "Int64", "Vector128", "Int64", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((long)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((long)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Sse41", "Sse2", "CompareEqual", "Vector128", "UInt64", "Vector128", "UInt64", "Vector128", "UInt64", "16", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((ulong)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((ulong)(-1)) : 0)"}),
};
private static readonly (string templateFileName, string[] templateData)[] Sse42Inputs = new []
{
- // TemplateName Isa, LoadIsa, Method, BaseType, VectorType, VectorSize, NextValue, ValidateFirstResult, ValidateRemainingResults
- ("SimpleBinOpTest.template", new string[] { "Sse42", "Sse2", "CompareGreaterThan","Int64", "Vector128", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((long)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((long)(-1)) : 0)"}),
+ // TemplateName Isa, LoadIsa, Method, RetVectorType, RetBaseType, Op1VectorType, Op1BaseType, Op2VectorType, Op2BaseType, Op3VectorType, Op3BaseType, VectorSize, NextValueOp1, NextValueOp2, NextValueOp3, ValidateFirstResult, ValidateRemainingResults
+ ("SimpleBinOpTest.template", new string[] { "Sse42", "Sse2", "CompareGreaterThan", "Vector128", "Int64", "Vector128", "Int64", "Vector128", "Int64", "16", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((long)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((long)(-1)) : 0)"}),
};
private static readonly (string templateFileName, string[] templateData)[] AvxInputs = new []
-{
- // TemplateName Isa, LoadIsa, Method, BaseType, VectorType, VectorSize, NextValue, ValidateFirstResult, ValidateRemainingResults
- ("SimpleBinOpTest.template", new string[] { "Avx", "Avx", "Add", "Double", "Vector256", "32", "(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", "Single", "Vector256", "32", "(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", "Double", "Vector256", "32", "(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", "Single", "Vector256", "32", "(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", "Double", "Vector256", "32", "(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", "Single", "Vector256", "32", "(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", "Double", "Vector256", "32", "(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", "Single", "Vector256", "32", "(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", "Double", "Vector256", "32", "(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", "Single", "Vector256", "32", "(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", "DuplicateEvenIndexed","Double", "Vector256", "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","Single", "Vector256", "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", "Single", "Vector256", "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", "Divide", "Double", "Vector256", "32", "(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", "Single", "Vector256", "32", "(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", "Max", "Double", "Vector256", "32", "(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", "Single", "Vector256", "32", "(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", "Double", "Vector256", "32", "(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", "Single", "Vector256", "32", "(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", "Double", "Vector256", "32", "(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", "Single", "Vector256", "32", "(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", "Double", "Vector256", "32", "(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", "Single", "Vector256", "32", "(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", "Double", "Vector256", "32", "(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", "Single", "Vector256", "32", "(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", "Double", "Vector256", "32", "(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", "Single", "Vector256", "32", "(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])"}),
+ ("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])"}),
};
private static readonly (string templateFileName, string[] templateData)[] Avx2Inputs = new []
{
- // TemplateName Isa, LoadIsa, Method, BaseType, VectorType, VectorSize, NextValue, ValidateFirstResult, ValidateRemainingResults
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "Byte", "Vector256", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] + right[0]) != result[0]", "(byte)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "Int16", "Vector256", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] + right[0]) != result[0]", "(short)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "Int32", "Vector256", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] + right[0]) != result[0]", "(int)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "Int64", "Vector256", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] + right[0]) != result[0]", "(long)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "SByte", "Vector256", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] + right[0]) != result[0]", "(sbyte)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "UInt16", "Vector256", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] + right[0]) != result[0]", "(ushort)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "UInt32", "Vector256", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] + right[0]) != result[0]", "(uint)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "UInt64", "Vector256", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] + right[0]) != result[0]", "(ulong)(left[i] + right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "Byte", "Vector256", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] & right[0]) != result[0]", "(byte)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "Int16", "Vector256", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] & right[0]) != result[0]", "(short)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "Int32", "Vector256", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] & right[0]) != result[0]", "(int)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "Int64", "Vector256", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] & right[0]) != result[0]", "(long)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "SByte", "Vector256", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] & right[0]) != result[0]", "(sbyte)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "UInt16", "Vector256", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] & right[0]) != result[0]", "(ushort)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "UInt32", "Vector256", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] & right[0]) != result[0]", "(uint)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "UInt64", "Vector256", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] & right[0]) != result[0]", "(ulong)(left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "Byte", "Vector256", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(~left[0] & right[0]) != result[0]", "(byte)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "Int16", "Vector256", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(~left[0] & right[0]) != result[0]", "(short)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "Int32", "Vector256", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(~left[0] & right[0]) != result[0]", "(int)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "Int64", "Vector256", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(~left[0] & right[0]) != result[0]", "(long)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "SByte", "Vector256", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(~left[0] & right[0]) != result[0]", "(sbyte)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "UInt16", "Vector256", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(~left[0] & right[0]) != result[0]", "(ushort)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "UInt32", "Vector256", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(~left[0] & right[0]) != result[0]", "(uint)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "UInt64", "Vector256", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(~left[0] & right[0]) != result[0]", "(ulong)(~left[i] & right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Average", "Byte", "Vector256", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)((left[0] + right[0] + 1) >> 1) != result[0]", "(byte)((left[i] + right[i] + 1) >> 1) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Average", "UInt16", "Vector256", "32", "(ushort)(random.Next(short.MinValue, short.MaxValue))","(ushort)((left[0] + right[0] + 1) >> 1) != result[0]", "(ushort)((left[i] + right[i] + 1) >> 1) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "Byte", "Vector256", "32", "(byte)(random.Next(0, byte.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((byte)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((byte)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "Int16", "Vector256", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((short)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((short)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "Int32", "Vector256", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((int)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((int)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "Int64", "Vector256", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((long)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((long)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "SByte", "Vector256", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((sbyte)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((sbyte)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "UInt16", "Vector256", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((ushort)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((ushort)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "UInt32", "Vector256", "32", "(uint)(random.Next(0, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((uint)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((uint)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "UInt64", "Vector256", "32", "(ulong)(random.Next(0, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((ulong)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((ulong)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareGreaterThan","Int16", "Vector256", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((short)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((short)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareGreaterThan","Int32", "Vector256", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((int)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((int)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareGreaterThan","Int64", "Vector256", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((long)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((long)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareGreaterThan","SByte", "Vector256", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((sbyte)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((sbyte)(-1)) : 0)"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "Byte", "Vector256", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] | right[0]) != result[0]", "(byte)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "Int16", "Vector256", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] | right[0]) != result[0]", "(short)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "Int32", "Vector256", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] | right[0]) != result[0]", "(int)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "Int64", "Vector256", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] | right[0]) != result[0]", "(long)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "SByte", "Vector256", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] | right[0]) != result[0]", "(sbyte)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "UInt16", "Vector256", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] | right[0]) != result[0]", "(ushort)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "UInt32", "Vector256", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] | right[0]) != result[0]", "(uint)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "UInt64", "Vector256", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] | right[0]) != result[0]", "(ulong)(left[i] | right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "Byte", "Vector256", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] - right[0]) != result[0]", "(byte)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "Int16", "Vector256", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] - right[0]) != result[0]", "(short)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "Int32", "Vector256", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] - right[0]) != result[0]", "(int)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "Int64", "Vector256", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] - right[0]) != result[0]", "(long)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "SByte", "Vector256", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] - right[0]) != result[0]", "(sbyte)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "UInt16", "Vector256", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] - right[0]) != result[0]", "(ushort)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "UInt32", "Vector256", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] - right[0]) != result[0]", "(uint)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "UInt64", "Vector256", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] - right[0]) != result[0]", "(ulong)(left[i] - right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "Byte", "Vector256", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] ^ right[0]) != result[0]", "(byte)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "Int16", "Vector256", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] ^ right[0]) != result[0]", "(short)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "Int32", "Vector256", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] ^ right[0]) != result[0]", "(int)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "Int64", "Vector256", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] ^ right[0]) != result[0]", "(long)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "SByte", "Vector256", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] ^ right[0]) != result[0]", "(sbyte)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "UInt16", "Vector256", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] ^ right[0]) != result[0]", "(ushort)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "UInt32", "Vector256", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] ^ right[0]) != result[0]", "(uint)(left[i] ^ right[i]) != result[i]"}),
- ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "UInt64", "Vector256", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] ^ right[0]) != result[0]", "(ulong)(left[i] ^ right[i]) != result[i]"}),
+ // TemplateName Isa, LoadIsa, Method, RetVectorType, RetBaseType, Op1VectorType, Op1BaseType, Op2VectorType, Op2BaseType, Op3VectorType, Op3BaseType, VectorSize, NextValueOp1, NextValueOp2, NextValueOp3, ValidateFirstResult, ValidateRemainingResults
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "Vector256", "Byte", "Vector256", "Byte", "Vector256", "Byte", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] + right[0]) != result[0]", "(byte)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "Vector256", "Int16", "Vector256", "Int16", "Vector256", "Int16", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] + right[0]) != result[0]", "(short)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "Vector256", "Int32", "Vector256", "Int32", "Vector256", "Int32", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] + right[0]) != result[0]", "(int)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "Vector256", "Int64", "Vector256", "Int64", "Vector256", "Int64", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] + right[0]) != result[0]", "(long)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "Vector256", "SByte", "Vector256", "SByte", "Vector256", "SByte", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] + right[0]) != result[0]", "(sbyte)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "Vector256", "UInt16", "Vector256", "UInt16", "Vector256", "UInt16", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] + right[0]) != result[0]", "(ushort)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "Vector256", "UInt32", "Vector256", "UInt32", "Vector256", "UInt32", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] + right[0]) != result[0]", "(uint)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Add", "Vector256", "UInt64", "Vector256", "UInt64", "Vector256", "UInt64", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] + right[0]) != result[0]", "(ulong)(left[i] + right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "Vector256", "Byte", "Vector256", "Byte", "Vector256", "Byte", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] & right[0]) != result[0]", "(byte)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "Vector256", "Int16", "Vector256", "Int16", "Vector256", "Int16", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] & right[0]) != result[0]", "(short)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "Vector256", "Int32", "Vector256", "Int32", "Vector256", "Int32", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] & right[0]) != result[0]", "(int)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "Vector256", "Int64", "Vector256", "Int64", "Vector256", "Int64", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] & right[0]) != result[0]", "(long)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "Vector256", "SByte", "Vector256", "SByte", "Vector256", "SByte", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] & right[0]) != result[0]", "(sbyte)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "Vector256", "UInt16", "Vector256", "UInt16", "Vector256", "UInt16", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] & right[0]) != result[0]", "(ushort)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "Vector256", "UInt32", "Vector256", "UInt32", "Vector256", "UInt32", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] & right[0]) != result[0]", "(uint)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "And", "Vector256", "UInt64", "Vector256", "UInt64", "Vector256", "UInt64", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] & right[0]) != result[0]", "(ulong)(left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "Vector256", "Byte", "Vector256", "Byte", "Vector256", "Byte", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(~left[0] & right[0]) != result[0]", "(byte)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "Vector256", "Int16", "Vector256", "Int16", "Vector256", "Int16", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(~left[0] & right[0]) != result[0]", "(short)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "Vector256", "Int32", "Vector256", "Int32", "Vector256", "Int32", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(~left[0] & right[0]) != result[0]", "(int)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "Vector256", "Int64", "Vector256", "Int64", "Vector256", "Int64", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(~left[0] & right[0]) != result[0]", "(long)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "Vector256", "SByte", "Vector256", "SByte", "Vector256", "SByte", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(~left[0] & right[0]) != result[0]", "(sbyte)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "Vector256", "UInt16", "Vector256", "UInt16", "Vector256", "UInt16", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(~left[0] & right[0]) != result[0]", "(ushort)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "Vector256", "UInt32", "Vector256", "UInt32", "Vector256", "UInt32", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "(uint)(~left[0] & right[0]) != result[0]", "(uint)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "AndNot", "Vector256", "UInt64", "Vector256", "UInt64", "Vector256", "UInt64", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(~left[0] & right[0]) != result[0]", "(ulong)(~left[i] & right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Average", "Vector256", "Byte", "Vector256", "Byte", "Vector256", "Byte", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)((left[0] + right[0] + 1) >> 1) != result[0]", "(byte)((left[i] + right[i] + 1) >> 1) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Average", "Vector256", "UInt16", "Vector256", "UInt16", "Vector256", "UInt16", "32", "(ushort)(random.Next(short.MinValue, short.MaxValue))", "(ushort)(random.Next(short.MinValue, short.MaxValue))", "(ushort)((left[0] + right[0] + 1) >> 1) != result[0]", "(ushort)((left[i] + right[i] + 1) >> 1) != result[i]"}),
+ ("SimpleTernOpTest.template", new string[] { "Avx2", "Avx", "BlendVariable", "Vector256", "Byte", "Vector256", "Byte", "Vector256", "Byte", "Vector256", "Byte", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(((i % 2) == 0) ? 128 : 1)", "((thirdOp[0] >> 7) & 1) == 1 ? secondOp[0] != result[0] : firstOp[0] != result[0]", "((thirdOp[i] >> 7) & 1) == 1 ? secondOp[i] != result[i] : firstOp[i] != result[i]"}),
+ ("SimpleTernOpTest.template", new string[] { "Avx2", "Avx", "BlendVariable", "Vector256", "SByte", "Vector256", "SByte", "Vector256", "SByte", "Vector256", "SByte", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(((i % 2) == 0) ? -128 : 1)", "((thirdOp[0] >> 7) & 1) == 1 ? secondOp[0] != result[0] : firstOp[0] != result[0]", "((thirdOp[i] >> 7) & 1) == 1 ? secondOp[i] != result[i] : firstOp[i] != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "Vector256", "Byte", "Vector256", "Byte", "Vector256", "Byte", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((byte)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((byte)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "Vector256", "Int16", "Vector256", "Int16", "Vector256", "Int16", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((short)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((short)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "Vector256", "Int32", "Vector256", "Int32", "Vector256", "Int32", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((int)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((int)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "Vector256", "Int64", "Vector256", "Int64", "Vector256", "Int64", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((long)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((long)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "Vector256", "SByte", "Vector256", "SByte", "Vector256", "SByte", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((sbyte)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((sbyte)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "Vector256", "UInt16", "Vector256", "UInt16", "Vector256", "UInt16", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((ushort)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((ushort)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "Vector256", "UInt32", "Vector256", "UInt32", "Vector256", "UInt32", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((uint)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((uint)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareEqual", "Vector256", "UInt64", "Vector256", "UInt64", "Vector256", "UInt64", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "result[0] != ((left[0] == right[0]) ? unchecked((ulong)(-1)) : 0)", "result[i] != ((left[i] == right[i]) ? unchecked((ulong)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareGreaterThan", "Vector256", "Int16", "Vector256", "Int16", "Vector256", "Int16", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((short)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((short)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareGreaterThan", "Vector256", "Int32", "Vector256", "Int32", "Vector256", "Int32", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((int)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((int)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareGreaterThan", "Vector256", "Int64", "Vector256", "Int64", "Vector256", "Int64", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((long)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((long)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "CompareGreaterThan", "Vector256", "SByte", "Vector256", "SByte", "Vector256", "SByte", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "result[0] != ((left[0] > right[0]) ? unchecked((sbyte)(-1)) : 0)", "result[i] != ((left[i] > right[i]) ? unchecked((sbyte)(-1)) : 0)"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "Vector256", "Byte", "Vector256", "Byte", "Vector256", "Byte", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] | right[0]) != result[0]", "(byte)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "Vector256", "Int16", "Vector256", "Int16", "Vector256", "Int16", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] | right[0]) != result[0]", "(short)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "Vector256", "Int32", "Vector256", "Int32", "Vector256", "Int32", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] | right[0]) != result[0]", "(int)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "Vector256", "Int64", "Vector256", "Int64", "Vector256", "Int64", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] | right[0]) != result[0]", "(long)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "Vector256", "SByte", "Vector256", "SByte", "Vector256", "SByte", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] | right[0]) != result[0]", "(sbyte)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "Vector256", "UInt16", "Vector256", "UInt16", "Vector256", "UInt16", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] | right[0]) != result[0]", "(ushort)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "Vector256", "UInt32", "Vector256", "UInt32", "Vector256", "UInt32", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] | right[0]) != result[0]", "(uint)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Or", "Vector256", "UInt64", "Vector256", "UInt64", "Vector256", "UInt64", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] | right[0]) != result[0]", "(ulong)(left[i] | right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "Vector256", "Byte", "Vector256", "Byte", "Vector256", "Byte", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] - right[0]) != result[0]", "(byte)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "Vector256", "Int16", "Vector256", "Int16", "Vector256", "Int16", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] - right[0]) != result[0]", "(short)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "Vector256", "Int32", "Vector256", "Int32", "Vector256", "Int32", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] - right[0]) != result[0]", "(int)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "Vector256", "Int64", "Vector256", "Int64", "Vector256", "Int64", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] - right[0]) != result[0]", "(long)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "Vector256", "SByte", "Vector256", "SByte", "Vector256", "SByte", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] - right[0]) != result[0]", "(sbyte)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "Vector256", "UInt16", "Vector256", "UInt16", "Vector256", "UInt16", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] - right[0]) != result[0]", "(ushort)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "Vector256", "UInt32", "Vector256", "UInt32", "Vector256", "UInt32", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] - right[0]) != result[0]", "(uint)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Subtract", "Vector256", "UInt64", "Vector256", "UInt64", "Vector256", "UInt64", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] - right[0]) != result[0]", "(ulong)(left[i] - right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "Vector256", "Byte", "Vector256", "Byte", "Vector256", "Byte", "32", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(random.Next(0, byte.MaxValue))", "(byte)(left[0] ^ right[0]) != result[0]", "(byte)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "Vector256", "Int16", "Vector256", "Int16", "Vector256", "Int16", "32", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(random.Next(short.MinValue, short.MaxValue))", "(short)(left[0] ^ right[0]) != result[0]", "(short)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "Vector256", "Int32", "Vector256", "Int32", "Vector256", "Int32", "32", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(random.Next(int.MinValue, int.MaxValue))", "(int)(left[0] ^ right[0]) != result[0]", "(int)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "Vector256", "Int64", "Vector256", "Int64", "Vector256", "Int64", "32", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(random.Next(int.MinValue, int.MaxValue))", "(long)(left[0] ^ right[0]) != result[0]", "(long)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "Vector256", "SByte", "Vector256", "SByte", "Vector256", "SByte", "32", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue))", "(sbyte)(left[0] ^ right[0]) != result[0]", "(sbyte)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "Vector256", "UInt16", "Vector256", "UInt16", "Vector256", "UInt16", "32", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(random.Next(0, ushort.MaxValue))", "(ushort)(left[0] ^ right[0]) != result[0]", "(ushort)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "Vector256", "UInt32", "Vector256", "UInt32", "Vector256", "UInt32", "32", "(uint)(random.Next(0, int.MaxValue))", "(uint)(random.Next(0, int.MaxValue))", "(uint)(left[0] ^ right[0]) != result[0]", "(uint)(left[i] ^ right[i]) != result[i]"}),
+ ("SimpleBinOpTest.template", new string[] { "Avx2", "Avx", "Xor", "Vector256", "UInt64", "Vector256", "UInt64", "Vector256", "UInt64", "32", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(random.Next(0, int.MaxValue))", "(ulong)(left[0] ^ right[0]) != result[0]", "(ulong)(left[i] ^ right[i]) != result[i]"}),
};
private static void ProcessInputs(string isa, (string templateFileName, string[] templateData)[] inputs)
@@ -313,10 +315,10 @@ namespace JIT.HardwareIntrinsics.X86
private static void ProcessInput(StreamWriter testListFile, (string templateFileName, string[] templateData) input)
{
- var testName = $"{input.templateData[2]}.{input.templateData[3]}";
+ var testName = $"{input.templateData[2]}.{input.templateData[4]}";
// Ex: ["Add.Single"] = AddSingle
- testListFile.WriteLine($@" [""{testName}""] = {input.templateData[2]}{input.templateData[3]},");
+ testListFile.WriteLine($@" [""{testName}""] = {input.templateData[2]}{input.templateData[4]},");
var testFileName = Path.Combine("..", input.templateData[0], $"{testName}.cs");
var template = File.ReadAllText(input.templateFileName);
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleBinOpTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleBinOpTest.template
index feff6f688e..74fd5e336e 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleBinOpTest.template
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleBinOpTest.template
@@ -19,29 +19,35 @@ namespace JIT.HardwareIntrinsics.X86
{{
public static partial class Program
{{
- private static void {2}{3}()
+ private static void {2}{4}()
{{
- var test = new SimpleBinaryOpTest__{2}{3}();
+ var test = new SimpleBinaryOpTest__{2}{4}();
if (test.IsSupported)
{{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if ({1}.IsSupported)
+ {{
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }}
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if ({1}.IsSupported)
+ {{
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }}
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if ({1}.IsSupported)
+ {{
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }}
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -74,43 +83,49 @@ namespace JIT.HardwareIntrinsics.X86
}}
}}
- public sealed unsafe class SimpleBinaryOpTest__{2}{3}
+ public sealed unsafe class SimpleBinaryOpTest__{2}{4}
{{
- private const int VectorSize = {5};
- private const int ElementCount = VectorSize / sizeof({3});
+ private const int VectorSize = {9};
+
+ private const int Op1ElementCount = VectorSize / sizeof({6});
+ private const int Op2ElementCount = VectorSize / sizeof({8});
+ private const int RetElementCount = VectorSize / sizeof({4});
- private static {3}[] _data1 = new {3}[ElementCount];
- private static {3}[] _data2 = new {3}[ElementCount];
+ private static {6}[] _data1 = new {6}[Op1ElementCount];
+ private static {8}[] _data2 = new {8}[Op2ElementCount];
- private static {4}<{3}> _clsVar1;
- private static {4}<{3}> _clsVar2;
+ private static {5}<{6}> _clsVar1;
+ private static {7}<{8}> _clsVar2;
- private {4}<{3}> _fld1;
- private {4}<{3}> _fld2;
+ private {5}<{6}> _fld1;
+ private {7}<{8}> _fld2;
- private SimpleBinaryOpTest__DataTable<{3}> _dataTable;
+ private SimpleBinaryOpTest__DataTable<{4}, {6}, {8}> _dataTable;
- static SimpleBinaryOpTest__{2}{3}()
+ static SimpleBinaryOpTest__{2}{4}()
{{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) {{ _data1[i] = {6}; _data2[i] = {6}; }}
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _clsVar1), ref Unsafe.As<{3}, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _clsVar2), ref Unsafe.As<{3}, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) {{ _data1[i] = {10}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{5}<{6}>, byte>(ref _clsVar1), ref Unsafe.As<{6}, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) {{ _data2[i] = {11}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{7}<{8}>, byte>(ref _clsVar2), ref Unsafe.As<{8}, byte>(ref _data2[0]), VectorSize);
}}
- public SimpleBinaryOpTest__{2}{3}()
+ public SimpleBinaryOpTest__{2}{4}()
{{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) {{ _data1[i] = {6}; _data2[i] = {6}; }}
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _fld1), ref Unsafe.As<{3}, byte>(ref _data1[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _fld2), ref Unsafe.As<{3}, byte>(ref _data2[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) {{ _data1[i] = {10}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{5}<{6}>, byte>(ref _fld1), ref Unsafe.As<{6}, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) {{ _data2[i] = {11}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{7}<{8}>, byte>(ref _fld2), ref Unsafe.As<{8}, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) {{ _data1[i] = {6}; _data2[i] = {6}; }}
- _dataTable = new SimpleBinaryOpTest__DataTable<{3}>(_data1, _data2, new {3}[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) {{ _data1[i] = {10}; }}
+ for (var i = 0; i < Op2ElementCount; i++) {{ _data2[i] = {11}; }}
+ _dataTable = new SimpleBinaryOpTest__DataTable<{4}, {6}, {8}>(_data1, _data2, new {4}[RetElementCount], VectorSize);
}}
public bool IsSupported => {0}.IsSupported;
@@ -120,8 +135,8 @@ namespace JIT.HardwareIntrinsics.X86
public void RunBasicScenario_UnsafeRead()
{{
var result = {0}.{2}(
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray1Ptr),
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray2Ptr)
+ Unsafe.Read<{5}<{6}>>(_dataTable.inArray1Ptr),
+ Unsafe.Read<{7}<{8}>>(_dataTable.inArray2Ptr)
);
Unsafe.Write(_dataTable.outArrayPtr, result);
@@ -131,8 +146,8 @@ namespace JIT.HardwareIntrinsics.X86
public void RunBasicScenario_Load()
{{
var result = {0}.{2}(
- {1}.Load{4}(({3}*)(_dataTable.inArray1Ptr)),
- {1}.Load{4}(({3}*)(_dataTable.inArray2Ptr))
+ {1}.Load{5}(({6}*)(_dataTable.inArray1Ptr)),
+ {1}.Load{7}(({8}*)(_dataTable.inArray2Ptr))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
@@ -142,8 +157,8 @@ namespace JIT.HardwareIntrinsics.X86
public void RunBasicScenario_LoadAligned()
{{
var result = {0}.{2}(
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray1Ptr)),
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray2Ptr))
+ {1}.LoadAligned{5}(({6}*)(_dataTable.inArray1Ptr)),
+ {1}.LoadAligned{7}(({8}*)(_dataTable.inArray2Ptr))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
@@ -152,37 +167,37 @@ namespace JIT.HardwareIntrinsics.X86
public void RunReflectionScenario_UnsafeRead()
{{
- var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({4}<{3}>), typeof({4}<{3}>) }})
+ var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>) }})
.Invoke(null, new object[] {{
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray1Ptr),
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray2Ptr)
+ Unsafe.Read<{5}<{6}>>(_dataTable.inArray1Ptr),
+ Unsafe.Read<{7}<{8}>>(_dataTable.inArray2Ptr)
}});
- Unsafe.Write(_dataTable.outArrayPtr, ({4}<{3}>)(result));
+ Unsafe.Write(_dataTable.outArrayPtr, ({3}<{4}>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
}}
public void RunReflectionScenario_Load()
{{
- var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({4}<{3}>), typeof({4}<{3}>) }})
+ var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>) }})
.Invoke(null, new object[] {{
- {1}.Load{4}(({3}*)(_dataTable.inArray1Ptr)),
- {1}.Load{4}(({3}*)(_dataTable.inArray2Ptr))
+ {1}.Load{5}(({6}*)(_dataTable.inArray1Ptr)),
+ {1}.Load{7}(({8}*)(_dataTable.inArray2Ptr))
}});
- Unsafe.Write(_dataTable.outArrayPtr, ({4}<{3}>)(result));
+ Unsafe.Write(_dataTable.outArrayPtr, ({3}<{4}>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
}}
public void RunReflectionScenario_LoadAligned()
{{
- var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({4}<{3}>), typeof({4}<{3}>) }})
+ var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>) }})
.Invoke(null, new object[] {{
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray1Ptr)),
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray2Ptr))
+ {1}.LoadAligned{5}(({6}*)(_dataTable.inArray1Ptr)),
+ {1}.LoadAligned{7}(({8}*)(_dataTable.inArray2Ptr))
}});
- Unsafe.Write(_dataTable.outArrayPtr, ({4}<{3}>)(result));
+ Unsafe.Write(_dataTable.outArrayPtr, ({3}<{4}>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.outArrayPtr);
}}
@@ -199,8 +214,8 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclVarScenario_UnsafeRead()
{{
- var left = Unsafe.Read<{4}<{3}>>(_dataTable.inArray1Ptr);
- var right = Unsafe.Read<{4}<{3}>>(_dataTable.inArray2Ptr);
+ var left = Unsafe.Read<{5}<{6}>>(_dataTable.inArray1Ptr);
+ var right = Unsafe.Read<{7}<{8}>>(_dataTable.inArray2Ptr);
var result = {0}.{2}(left, right);
Unsafe.Write(_dataTable.outArrayPtr, result);
@@ -209,8 +224,8 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclVarScenario_Load()
{{
- var left = {1}.Load{4}(({3}*)(_dataTable.inArray1Ptr));
- var right = {1}.Load{4}(({3}*)(_dataTable.inArray2Ptr));
+ var left = {1}.Load{5}(({6}*)(_dataTable.inArray1Ptr));
+ var right = {1}.Load{7}(({8}*)(_dataTable.inArray2Ptr));
var result = {0}.{2}(left, right);
Unsafe.Write(_dataTable.outArrayPtr, result);
@@ -219,8 +234,8 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclVarScenario_LoadAligned()
{{
- var left = {1}.LoadAligned{4}(({3}*)(_dataTable.inArray1Ptr));
- var right = {1}.LoadAligned{4}(({3}*)(_dataTable.inArray2Ptr));
+ var left = {1}.LoadAligned{5}(({6}*)(_dataTable.inArray1Ptr));
+ var right = {1}.LoadAligned{7}(({8}*)(_dataTable.inArray2Ptr));
var result = {0}.{2}(left, right);
Unsafe.Write(_dataTable.outArrayPtr, result);
@@ -229,7 +244,7 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclFldScenario()
{{
- var test = new SimpleBinaryOpTest__{2}{3}();
+ var test = new SimpleBinaryOpTest__{2}{4}();
var result = {0}.{2}(test._fld1, test._fld2);
Unsafe.Write(_dataTable.outArrayPtr, result);
@@ -258,43 +273,43 @@ namespace JIT.HardwareIntrinsics.X86
}}
}}
- private void ValidateResult({4}<{3}> left, {4}<{3}> right, void* result, [CallerMemberName] string method = "")
+ private void ValidateResult({5}<{6}> left, {7}<{8}> right, void* result, [CallerMemberName] string method = "")
{{
- {3}[] inArray1 = new {3}[ElementCount];
- {3}[] inArray2 = new {3}[ElementCount];
- {3}[] outArray = new {3}[ElementCount];
+ {6}[] inArray1 = new {6}[Op1ElementCount];
+ {8}[] inArray2 = new {8}[Op2ElementCount];
+ {4}[] outArray = new {4}[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
ValidateResult(inArray1, inArray2, outArray, method);
}}
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{{
- {3}[] inArray1 = new {3}[ElementCount];
- {3}[] inArray2 = new {3}[ElementCount];
- {3}[] outArray = new {3}[ElementCount];
+ {6}[] inArray1 = new {6}[Op1ElementCount];
+ {8}[] inArray2 = new {8}[Op2ElementCount];
+ {4}[] outArray = new {4}[RetElementCount];
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{6}, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{8}, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
ValidateResult(inArray1, inArray2, outArray, method);
}}
- private void ValidateResult({3}[] left, {3}[] right, {3}[] result, [CallerMemberName] string method = "")
+ private void ValidateResult({6}[] left, {8}[] right, {4}[] result, [CallerMemberName] string method = "")
{{
- if ({7})
+ if ({12})
{{
Succeeded = false;
}}
else
{{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{{
- if ({8})
+ if ({13})
{{
Succeeded = false;
break;
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{{
- Console.WriteLine($"{{nameof({0})}}.{{nameof({0}.{2})}}<{3}>: {{method}} failed:");
+ Console.WriteLine($"{{nameof({0})}}.{{nameof({0}.{2})}}<{4}>({5}<{6}>, {7}<{8}>): {{method}} failed:");
Console.WriteLine($" left: ({{string.Join(", ", left)}})");
Console.WriteLine($" right: ({{string.Join(", ", right)}})");
Console.WriteLine($" result: ({{string.Join(", ", result)}})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleBinOpTest_DataTable.cs b/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleBinOpTest_DataTable.cs
index f056a8fc7b..a1fc26e86c 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleBinOpTest_DataTable.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleBinOpTest_DataTable.cs
@@ -10,7 +10,10 @@ using System.Runtime.Intrinsics.X86;
namespace JIT.HardwareIntrinsics.X86
{
- public unsafe struct SimpleBinaryOpTest__DataTable<T> : IDisposable where T : struct
+ public unsafe struct SimpleBinaryOpTest__DataTable<TResult, TOp1, TOp2> : IDisposable
+ where TResult : struct
+ where TOp1 : struct
+ where TOp2 : struct
{
private byte[] inArray1;
private byte[] inArray2;
@@ -22,7 +25,7 @@ namespace JIT.HardwareIntrinsics.X86
private byte simdSize;
- public SimpleBinaryOpTest__DataTable(T[] inArray1, T[] inArray2, T[] outArray, int simdSize)
+ public SimpleBinaryOpTest__DataTable(TOp1[] inArray1, TOp2[] inArray2, TResult[] outArray, int simdSize)
{
this.inArray1 = new byte[simdSize * 2];
this.inArray2 = new byte[simdSize * 2];
@@ -34,8 +37,8 @@ namespace JIT.HardwareIntrinsics.X86
this.simdSize = unchecked((byte)(simdSize));
- Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<T, byte>(ref inArray1[0]), this.simdSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<T, byte>(ref inArray2[0]), this.simdSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<TOp1, byte>(ref inArray1[0]), this.simdSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<TOp2, byte>(ref inArray2[0]), this.simdSize);
}
public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), simdSize);
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleTernOpTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleTernOpTest.template
index 215d83eba4..3a0cbf1d55 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleTernOpTest.template
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleTernOpTest.template
@@ -19,29 +19,35 @@ namespace JIT.HardwareIntrinsics.X86
{{
public static partial class Program
{{
- private static void {2}{3}()
+ private static void {2}{4}()
{{
- var test = new SimpleTernaryOpTest__{2}{3}();
+ var test = new SimpleTernaryOpTest__{2}{4}();
if (test.IsSupported)
{{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if ({1}.IsSupported)
+ {{
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }}
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if ({1}.IsSupported)
+ {{
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }}
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if ({1}.IsSupported)
+ {{
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }}
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -74,48 +83,58 @@ namespace JIT.HardwareIntrinsics.X86
}}
}}
- public sealed unsafe class SimpleTernaryOpTest__{2}{3}
+ public sealed unsafe class SimpleTernaryOpTest__{2}{4}
{{
- private const int VectorSize = {5};
- private const int ElementCount = VectorSize / sizeof({3});
+ private const int VectorSize = {11};
- private static {3}[] _data1 = new {3}[ElementCount];
- private static {3}[] _data2 = new {3}[ElementCount];
- private static {3}[] _data3 = new {3}[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof({6});
+ private const int Op2ElementCount = VectorSize / sizeof({8});
+ private const int Op3ElementCount = VectorSize / sizeof({10});
+ private const int RetElementCount = VectorSize / sizeof({4});
- private static {4}<{3}> _clsVar1;
- private static {4}<{3}> _clsVar2;
- private static {4}<{3}> _clsVar3;
+ private static {6}[] _data1 = new {6}[Op1ElementCount];
+ private static {8}[] _data2 = new {8}[Op2ElementCount];
+ private static {10}[] _data3 = new {10}[Op3ElementCount];
- private {4}<{3}> _fld1;
- private {4}<{3}> _fld2;
- private {4}<{3}> _fld3;
+ private static {5}<{6}> _clsVar1;
+ private static {7}<{8}> _clsVar2;
+ private static {9}<{10}> _clsVar3;
- private SimpleTernaryOpTest__DataTable<{3}> _dataTable;
+ private {5}<{6}> _fld1;
+ private {7}<{8}> _fld2;
+ private {9}<{10}> _fld3;
- static SimpleTernaryOpTest__{2}{3}()
+ private SimpleTernaryOpTest__DataTable<{4}, {6}, {8}, {10}> _dataTable;
+
+ static SimpleTernaryOpTest__{2}{4}()
{{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) {{ _data1[i] = {6}; _data2[i] = {6}; _data3[i] = {7}; }}
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _clsVar1), ref Unsafe.As<{3}, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _clsVar2), ref Unsafe.As<{3}, byte>(ref _data1[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _clsVar3), ref Unsafe.As<{3}, byte>(ref _data3[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) {{ _data1[i] = {12}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{5}<{6}>, byte>(ref _clsVar1), ref Unsafe.As<{6}, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) {{ _data2[i] = {13}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{7}<{8}>, byte>(ref _clsVar2), ref Unsafe.As<{8}, byte>(ref _data2[0]), VectorSize);
+ for (var i = 0; i < Op3ElementCount; i++) {{ _data3[i] = {14}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{9}<{10}>, byte>(ref _clsVar3), ref Unsafe.As<{10}, byte>(ref _data3[0]), VectorSize);
}}
- public SimpleTernaryOpTest__{2}{3}()
+ public SimpleTernaryOpTest__{2}{4}()
{{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) {{ _data1[i] = {6}; _data2[i] = {6}; _data3[i] = {7}; }}
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _fld1), ref Unsafe.As<{3}, byte>(ref _data1[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _fld2), ref Unsafe.As<{3}, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _fld3), ref Unsafe.As<{3}, byte>(ref _data3[0]), VectorSize);
-
- for (var i = 0; i < ElementCount; i++) {{ _data1[i] = {6}; _data2[i] = {6}; _data3[i] = {7}; }}
- _dataTable = new SimpleTernaryOpTest__DataTable<{3}>(_data1, _data2, _data3, new {3}[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) {{ _data1[i] = {12}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{5}<{6}>, byte>(ref _fld1), ref Unsafe.As<{6}, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) {{ _data2[i] = {13}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{7}<{8}>, byte>(ref _fld2), ref Unsafe.As<{8}, byte>(ref _data2[0]), VectorSize);
+ for (var i = 0; i < Op3ElementCount; i++) {{ _data3[i] = {14}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{9}<{10}>, byte>(ref _fld3), ref Unsafe.As<{10}, byte>(ref _data3[0]), VectorSize);
+
+ for (var i = 0; i < Op1ElementCount; i++) {{ _data1[i] = {12}; }}
+ for (var i = 0; i < Op2ElementCount; i++) {{ _data2[i] = {13}; }}
+ for (var i = 0; i < Op3ElementCount; i++) {{ _data3[i] = {14}; }}
+ _dataTable = new SimpleTernaryOpTest__DataTable<{4}, {6}, {8}, {10}>(_data1, _data2, _data3, new {4}[RetElementCount], VectorSize);
}}
public bool IsSupported => {0}.IsSupported;
@@ -125,9 +144,9 @@ namespace JIT.HardwareIntrinsics.X86
public void RunBasicScenario_UnsafeRead()
{{
var result = {0}.{2}(
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray1Ptr),
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray2Ptr),
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray3Ptr)
+ Unsafe.Read<{5}<{6}>>(_dataTable.inArray1Ptr),
+ Unsafe.Read<{7}<{8}>>(_dataTable.inArray2Ptr),
+ Unsafe.Read<{9}<{10}>>(_dataTable.inArray3Ptr)
);
Unsafe.Write(_dataTable.outArrayPtr, result);
@@ -137,9 +156,9 @@ namespace JIT.HardwareIntrinsics.X86
public void RunBasicScenario_Load()
{{
var result = {0}.{2}(
- {1}.Load{4}(({3}*)(_dataTable.inArray1Ptr)),
- {1}.Load{4}(({3}*)(_dataTable.inArray2Ptr)),
- {1}.Load{4}(({3}*)(_dataTable.inArray3Ptr))
+ {1}.Load{5}(({6}*)(_dataTable.inArray1Ptr)),
+ {1}.Load{7}(({8}*)(_dataTable.inArray2Ptr)),
+ {1}.Load{9}(({10}*)(_dataTable.inArray3Ptr))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
@@ -149,9 +168,9 @@ namespace JIT.HardwareIntrinsics.X86
public void RunBasicScenario_LoadAligned()
{{
var result = {0}.{2}(
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray1Ptr)),
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray2Ptr)),
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray3Ptr))
+ {1}.LoadAligned{5}(({6}*)(_dataTable.inArray1Ptr)),
+ {1}.LoadAligned{7}(({8}*)(_dataTable.inArray2Ptr)),
+ {1}.LoadAligned{9}(({10}*)(_dataTable.inArray3Ptr))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
@@ -160,40 +179,40 @@ namespace JIT.HardwareIntrinsics.X86
public void RunReflectionScenario_UnsafeRead()
{{
- var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({4}<{3}>), typeof({4}<{3}>), typeof({4}<{3}>) }})
+ var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>), typeof({9}<{10}>) }})
.Invoke(null, new object[] {{
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray1Ptr),
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray2Ptr),
- Unsafe.Read<{4}<{3}>>(_dataTable.inArray3Ptr)
+ Unsafe.Read<{5}<{6}>>(_dataTable.inArray1Ptr),
+ Unsafe.Read<{7}<{8}>>(_dataTable.inArray2Ptr),
+ Unsafe.Read<{9}<{10}>>(_dataTable.inArray3Ptr)
}});
- Unsafe.Write(_dataTable.outArrayPtr, ({4}<{3}>)(result));
+ Unsafe.Write(_dataTable.outArrayPtr, ({3}<{4}>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr);
}}
public void RunReflectionScenario_Load()
{{
- var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({4}<{3}>), typeof({4}<{3}>), typeof({4}<{3}>) }})
+ var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>), typeof({9}<{10}>) }})
.Invoke(null, new object[] {{
- {1}.Load{4}(({3}*)(_dataTable.inArray1Ptr)),
- {1}.Load{4}(({3}*)(_dataTable.inArray2Ptr)),
- {1}.Load{4}(({3}*)(_dataTable.inArray3Ptr))
+ {1}.Load{5}(({6}*)(_dataTable.inArray1Ptr)),
+ {1}.Load{7}(({8}*)(_dataTable.inArray2Ptr)),
+ {1}.Load{9}(({10}*)(_dataTable.inArray3Ptr))
}});
- Unsafe.Write(_dataTable.outArrayPtr, ({4}<{3}>)(result));
+ Unsafe.Write(_dataTable.outArrayPtr, ({3}<{4}>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr);
}}
public void RunReflectionScenario_LoadAligned()
{{
- var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({4}<{3}>), typeof({4}<{3}>), typeof({4}<{3}>) }})
+ var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>), typeof({7}<{8}>), typeof({9}<{10}>) }})
.Invoke(null, new object[] {{
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray1Ptr)),
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray2Ptr)),
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArray3Ptr))
+ {1}.LoadAligned{5}(({6}*)(_dataTable.inArray1Ptr)),
+ {1}.LoadAligned{7}(({8}*)(_dataTable.inArray2Ptr)),
+ {1}.LoadAligned{9}(({10}*)(_dataTable.inArray3Ptr))
}});
- Unsafe.Write(_dataTable.outArrayPtr, ({4}<{3}>)(result));
+ Unsafe.Write(_dataTable.outArrayPtr, ({3}<{4}>)(result));
ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr);
}}
@@ -211,9 +230,9 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclVarScenario_UnsafeRead()
{{
- var firstOp = Unsafe.Read<{4}<{3}>>(_dataTable.inArray1Ptr);
- var secondOp = Unsafe.Read<{4}<{3}>>(_dataTable.inArray2Ptr);
- var thirdOp = Unsafe.Read<{4}<{3}>>(_dataTable.inArray3Ptr);
+ var firstOp = Unsafe.Read<{5}<{6}>>(_dataTable.inArray1Ptr);
+ var secondOp = Unsafe.Read<{7}<{8}>>(_dataTable.inArray2Ptr);
+ var thirdOp = Unsafe.Read<{9}<{10}>>(_dataTable.inArray3Ptr);
var result = {0}.{2}(firstOp, secondOp, thirdOp);
Unsafe.Write(_dataTable.outArrayPtr, result);
@@ -222,9 +241,9 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclVarScenario_Load()
{{
- var firstOp = {1}.Load{4}(({3}*)(_dataTable.inArray1Ptr));
- var secondOp = {1}.Load{4}(({3}*)(_dataTable.inArray2Ptr));
- var thirdOp = {1}.Load{4}(({3}*)(_dataTable.inArray3Ptr));
+ var firstOp = {1}.Load{5}(({6}*)(_dataTable.inArray1Ptr));
+ var secondOp = {1}.Load{7}(({8}*)(_dataTable.inArray2Ptr));
+ var thirdOp = {1}.Load{9}(({10}*)(_dataTable.inArray3Ptr));
var result = {0}.{2}(firstOp, secondOp, thirdOp);
Unsafe.Write(_dataTable.outArrayPtr, result);
@@ -233,9 +252,9 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclVarScenario_LoadAligned()
{{
- var firstOp = {1}.LoadAligned{4}(({3}*)(_dataTable.inArray1Ptr));
- var secondOp = {1}.LoadAligned{4}(({3}*)(_dataTable.inArray2Ptr));
- var thirdOp = {1}.LoadAligned{4}(({3}*)(_dataTable.inArray3Ptr));
+ var firstOp = {1}.LoadAligned{5}(({6}*)(_dataTable.inArray1Ptr));
+ var secondOp = {1}.LoadAligned{7}(({8}*)(_dataTable.inArray2Ptr));
+ var thirdOp = {1}.LoadAligned{9}(({10}*)(_dataTable.inArray3Ptr));
var result = {0}.{2}(firstOp, secondOp, thirdOp);
Unsafe.Write(_dataTable.outArrayPtr, result);
@@ -244,7 +263,7 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclFldScenario()
{{
- var test = new SimpleTernaryOpTest__{2}{3}();
+ var test = new SimpleTernaryOpTest__{2}{4}();
var result = {0}.{2}(test._fld1, test._fld2, test._fld3);
Unsafe.Write(_dataTable.outArrayPtr, result);
@@ -273,47 +292,47 @@ namespace JIT.HardwareIntrinsics.X86
}}
}}
- private void ValidateResult({4}<{3}> firstOp, {4}<{3}> secondOp, {4}<{3}> thirdOp, void* result, [CallerMemberName] string method = "")
+ private void ValidateResult({5}<{6}> firstOp, {7}<{8}> secondOp, {9}<{10}> thirdOp, void* result, [CallerMemberName] string method = "")
{{
- {3}[] inArray1 = new {3}[ElementCount];
- {3}[] inArray2 = new {3}[ElementCount];
- {3}[] inArray3 = new {3}[ElementCount];
- {3}[] outArray = new {3}[ElementCount];
+ {6}[] inArray1 = new {6}[Op1ElementCount];
+ {8}[] inArray2 = new {8}[Op2ElementCount];
+ {10}[] inArray3 = new {10}[Op3ElementCount];
+ {4}[] outArray = new {4}[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), firstOp);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), secondOp);
Unsafe.Write(Unsafe.AsPointer(ref inArray3[0]), thirdOp);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
ValidateResult(inArray1, inArray2, inArray3, outArray, method);
}}
private void ValidateResult(void* firstOp, void* secondOp, void* thirdOp, void* result, [CallerMemberName] string method = "")
{{
- {3}[] inArray1 = new {3}[ElementCount];
- {3}[] inArray2 = new {3}[ElementCount];
- {3}[] inArray3 = new {3}[ElementCount];
- {3}[] outArray = new {3}[ElementCount];
+ {6}[] inArray1 = new {6}[Op1ElementCount];
+ {8}[] inArray2 = new {8}[Op2ElementCount];
+ {10}[] inArray3 = new {10}[Op3ElementCount];
+ {4}[] outArray = new {4}[RetElementCount];
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(secondOp), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref inArray3[0]), ref Unsafe.AsRef<byte>(thirdOp), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{6}, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{8}, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(secondOp), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{10}, byte>(ref inArray3[0]), ref Unsafe.AsRef<byte>(thirdOp), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
ValidateResult(inArray1, inArray2, inArray3, outArray, method);
}}
- private void ValidateResult({3}[] firstOp, {3}[] secondOp, {3}[] thirdOp, {3}[] result, [CallerMemberName] string method = "")
+ private void ValidateResult({6}[] firstOp, {8}[] secondOp, {10}[] thirdOp, {4}[] result, [CallerMemberName] string method = "")
{{
- if ({8})
+ if ({15})
{{
Succeeded = false;
}}
else
{{
- for (var i = 1; i < firstOp.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{{
- if ({9})
+ if ({16})
{{
Succeeded = false;
break;
@@ -323,11 +342,11 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{{
- Console.WriteLine($"{{nameof({0})}}.{{nameof({0}.{2})}}<{3}>: {{method}} failed:");
- Console.WriteLine($" firstOp: ({{string.Join(", ", firstOp)}})");
- Console.WriteLine($" secondOp: ({{string.Join(", ", secondOp)}})");
+ Console.WriteLine($"{{nameof({0})}}.{{nameof({0}.{2})}}<{4}>({5}<{6}>, {7}<{8}>, {9}<{10}>): {{method}} failed:");
+ Console.WriteLine($" firstOp: ({{string.Join(", ", firstOp)}})");
+ Console.WriteLine($" secondOp: ({{string.Join(", ", secondOp)}})");
Console.WriteLine($" thirdOp: ({{string.Join(", ", thirdOp)}})");
- Console.WriteLine($" result: ({{string.Join(", ", result)}})");
+ Console.WriteLine($" result: ({{string.Join(", ", result)}})");
Console.WriteLine();
}}
}}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleTernOpTest_DataTable.cs b/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleTernOpTest_DataTable.cs
index ab52f6ca61..ab445ff5bd 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleTernOpTest_DataTable.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleTernOpTest_DataTable.cs
@@ -10,7 +10,11 @@ using System.Runtime.Intrinsics.X86;
namespace JIT.HardwareIntrinsics.X86
{
- public unsafe struct SimpleTernaryOpTest__DataTable<T> : IDisposable where T : struct
+ public unsafe struct SimpleTernaryOpTest__DataTable<TResult, TOp1, TOp2, TOp3> : IDisposable
+ where TResult : struct
+ where TOp1 : struct
+ where TOp2 : struct
+ where TOp3 : struct
{
private byte[] inArray1;
private byte[] inArray2;
@@ -24,7 +28,7 @@ namespace JIT.HardwareIntrinsics.X86
private byte simdSize;
- public SimpleTernaryOpTest__DataTable(T[] inArray1, T[] inArray2, T[] inArray3, T[] outArray, int simdSize)
+ public SimpleTernaryOpTest__DataTable(TOp1[] inArray1, TOp2[] inArray2, TOp3[] inArray3, TResult[] outArray, int simdSize)
{
this.inArray1 = new byte[simdSize * 2];
this.inArray2 = new byte[simdSize * 2];
@@ -38,9 +42,9 @@ namespace JIT.HardwareIntrinsics.X86
this.simdSize = unchecked((byte)(simdSize));
- Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<T, byte>(ref inArray1[0]), this.simdSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<T, byte>(ref inArray2[0]), this.simdSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray3Ptr), ref Unsafe.As<T, byte>(ref inArray3[0]), this.simdSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray1Ptr), ref Unsafe.As<TOp1, byte>(ref inArray1[0]), this.simdSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray2Ptr), ref Unsafe.As<TOp2, byte>(ref inArray2[0]), this.simdSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArray3Ptr), ref Unsafe.As<TOp3, byte>(ref inArray3[0]), this.simdSize);
}
public void* inArray1Ptr => Align((byte*)(inHandle1.AddrOfPinnedObject().ToPointer()), simdSize);
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleUnOpTest.template b/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleUnOpTest.template
index c74c5a50c8..b166292ca5 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleUnOpTest.template
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleUnOpTest.template
@@ -19,29 +19,35 @@ namespace JIT.HardwareIntrinsics.X86
{{
public static partial class Program
{{
- private static void {2}{3}()
+ private static void {2}{4}()
{{
- var test = new SimpleUnaryOpTest__{2}{3}();
+ var test = new SimpleUnaryOpTest__{2}{4}();
if (test.IsSupported)
{{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if ({1}.IsSupported)
+ {{
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }}
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if ({1}.IsSupported)
+ {{
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }}
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if ({1}.IsSupported)
+ {{
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }}
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -74,38 +83,40 @@ namespace JIT.HardwareIntrinsics.X86
}}
}}
- public sealed unsafe class SimpleUnaryOpTest__{2}{3}
+ public sealed unsafe class SimpleUnaryOpTest__{2}{4}
{{
- private const int VectorSize = {5};
- private const int ElementCount = VectorSize / sizeof({3});
+ private const int VectorSize = {7};
+
+ private const int Op1ElementCount = VectorSize / sizeof({6});
+ private const int RetElementCount = VectorSize / sizeof({4});
- private static {3}[] _data = new {3}[ElementCount];
+ private static {6}[] _data = new {6}[Op1ElementCount];
- private static {4}<{3}> _clsVar;
+ private static {5}<{6}> _clsVar;
- private {4}<{3}> _fld;
+ private {5}<{6}> _fld;
- private SimpleUnaryOpTest__DataTable<{3}> _dataTable;
+ private SimpleUnaryOpTest__DataTable<{4}, {6}> _dataTable;
- static SimpleUnaryOpTest__{2}{3}()
+ static SimpleUnaryOpTest__{2}{4}()
{{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) {{ _data[i] = {6}; }}
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _clsVar), ref Unsafe.As<{3}, byte>(ref _data[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) {{ _data[i] = {8}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{5}<{6}>, byte>(ref _clsVar), ref Unsafe.As<{6}, byte>(ref _data[0]), VectorSize);
}}
- public SimpleUnaryOpTest__{2}{3}()
+ public SimpleUnaryOpTest__{2}{4}()
{{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) {{ _data[i] = {6}; }}
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}<{3}>, byte>(ref _fld), ref Unsafe.As<{3}, byte>(ref _data[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) {{ _data[i] = {8}; }}
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{5}<{6}>, byte>(ref _fld), ref Unsafe.As<{6}, byte>(ref _data[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) {{ _data[i] = {6}; }}
- _dataTable = new SimpleUnaryOpTest__DataTable<{3}>(_data, new {3}[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) {{ _data[i] = {8}; }}
+ _dataTable = new SimpleUnaryOpTest__DataTable<{4}, {6}>(_data, new {4}[RetElementCount], VectorSize);
}}
public bool IsSupported => {0}.IsSupported;
@@ -115,7 +126,7 @@ namespace JIT.HardwareIntrinsics.X86
public void RunBasicScenario_UnsafeRead()
{{
var result = {0}.{2}(
- Unsafe.Read<{4}<{3}>>(_dataTable.inArrayPtr)
+ Unsafe.Read<{5}<{6}>>(_dataTable.inArrayPtr)
);
Unsafe.Write(_dataTable.outArrayPtr, result);
@@ -125,7 +136,7 @@ namespace JIT.HardwareIntrinsics.X86
public void RunBasicScenario_Load()
{{
var result = {0}.{2}(
- {1}.Load{4}(({3}*)(_dataTable.inArrayPtr))
+ {1}.Load{5}(({6}*)(_dataTable.inArrayPtr))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
@@ -135,7 +146,7 @@ namespace JIT.HardwareIntrinsics.X86
public void RunBasicScenario_LoadAligned()
{{
var result = {0}.{2}(
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArrayPtr))
+ {1}.LoadAligned{5}(({6}*)(_dataTable.inArrayPtr))
);
Unsafe.Write(_dataTable.outArrayPtr, result);
@@ -144,34 +155,34 @@ namespace JIT.HardwareIntrinsics.X86
public void RunReflectionScenario_UnsafeRead()
{{
- var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({4}<{3}>) }})
+ var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>) }})
.Invoke(null, new object[] {{
- Unsafe.Read<{4}<{3}>>(_dataTable.inArrayPtr)
+ Unsafe.Read<{5}<{6}>>(_dataTable.inArrayPtr)
}});
- Unsafe.Write(_dataTable.outArrayPtr, ({4}<{3}>)(result));
+ Unsafe.Write(_dataTable.outArrayPtr, ({3}<{4}>)(result));
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}}
public void RunReflectionScenario_Load()
{{
- var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({4}<{3}>) }})
+ var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>) }})
.Invoke(null, new object[] {{
- {1}.Load{4}(({3}*)(_dataTable.inArrayPtr))
+ {1}.Load{5}(({6}*)(_dataTable.inArrayPtr))
}});
- Unsafe.Write(_dataTable.outArrayPtr, ({4}<{3}>)(result));
+ Unsafe.Write(_dataTable.outArrayPtr, ({3}<{4}>)(result));
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}}
public void RunReflectionScenario_LoadAligned()
{{
- var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({4}<{3}>) }})
+ var result = typeof({0}).GetMethod(nameof({0}.{2}), new Type[] {{ typeof({5}<{6}>) }})
.Invoke(null, new object[] {{
- {1}.LoadAligned{4}(({3}*)(_dataTable.inArrayPtr))
+ {1}.LoadAligned{5}(({6}*)(_dataTable.inArrayPtr))
}});
- Unsafe.Write(_dataTable.outArrayPtr, ({4}<{3}>)(result));
+ Unsafe.Write(_dataTable.outArrayPtr, ({3}<{4}>)(result));
ValidateResult(_dataTable.inArrayPtr, _dataTable.outArrayPtr);
}}
@@ -187,7 +198,7 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclVarScenario_UnsafeRead()
{{
- var firstOp = Unsafe.Read<{4}<{3}>>(_dataTable.inArrayPtr);
+ var firstOp = Unsafe.Read<{5}<{6}>>(_dataTable.inArrayPtr);
var result = {0}.{2}(firstOp);
Unsafe.Write(_dataTable.outArrayPtr, result);
@@ -196,7 +207,7 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclVarScenario_Load()
{{
- var firstOp = {1}.Load{4}(({3}*)(_dataTable.inArrayPtr));
+ var firstOp = {1}.Load{5}(({6}*)(_dataTable.inArrayPtr));
var result = {0}.{2}(firstOp);
Unsafe.Write(_dataTable.outArrayPtr, result);
@@ -205,7 +216,7 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclVarScenario_LoadAligned()
{{
- var firstOp = {1}.LoadAligned{4}(({3}*)(_dataTable.inArrayPtr));
+ var firstOp = {1}.LoadAligned{5}(({6}*)(_dataTable.inArrayPtr));
var result = {0}.{2}(firstOp);
Unsafe.Write(_dataTable.outArrayPtr, result);
@@ -214,7 +225,7 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclFldScenario()
{{
- var test = new SimpleUnaryOpTest__{2}{3}();
+ var test = new SimpleUnaryOpTest__{2}{4}();
var result = {0}.{2}(test._fld);
Unsafe.Write(_dataTable.outArrayPtr, result);
@@ -243,39 +254,39 @@ namespace JIT.HardwareIntrinsics.X86
}}
}}
- private void ValidateResult({4}<{3}> firstOp, void* result, [CallerMemberName] string method = "")
+ private void ValidateResult({5}<{6}> firstOp, void* result, [CallerMemberName] string method = "")
{{
- {3}[] inArray = new {3}[ElementCount];
- {3}[] outArray = new {3}[ElementCount];
+ {6}[] inArray = new {6}[Op1ElementCount];
+ {4}[] outArray = new {4}[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray[0]), firstOp);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
ValidateResult(inArray, outArray, method);
}}
private void ValidateResult(void* firstOp, void* result, [CallerMemberName] string method = "")
{{
- {3}[] inArray = new {3}[ElementCount];
- {3}[] outArray = new {3}[ElementCount];
+ {6}[] inArray = new {6}[Op1ElementCount];
+ {4}[] outArray = new {4}[RetElementCount];
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<{3}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{6}, byte>(ref inArray[0]), ref Unsafe.AsRef<byte>(firstOp), VectorSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<{4}, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), VectorSize);
ValidateResult(inArray, outArray, method);
}}
- private void ValidateResult({3}[] firstOp, {3}[] result, [CallerMemberName] string method = "")
+ private void ValidateResult({6}[] firstOp, {4}[] result, [CallerMemberName] string method = "")
{{
- if ({7})
+ if ({9})
{{
Succeeded = false;
}}
else
{{
- for (var i = 1; i < firstOp.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{{
- if ({8})
+ if ({10})
{{
Succeeded = false;
break;
@@ -285,9 +296,9 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{{
- Console.WriteLine($"{{nameof({0})}}.{{nameof({0}.{2})}}<{3}>: {{method}} failed:");
- Console.WriteLine($" firstOp: ({{string.Join(", ", firstOp)}})");
- Console.WriteLine($" result: ({{string.Join(", ", result)}})");
+ Console.WriteLine($"{{nameof({0})}}.{{nameof({0}.{2})}}<{4}>({5}<{6}>): {{method}} failed:");
+ Console.WriteLine($" firstOp: ({{string.Join(", ", firstOp)}})");
+ Console.WriteLine($" result: ({{string.Join(", ", result)}})");
Console.WriteLine();
}}
}}
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleUnOpTest_DataTable.cs b/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleUnOpTest_DataTable.cs
index 62d432b787..c4c9ddf830 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleUnOpTest_DataTable.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Shared/SimpleUnOpTest_DataTable.cs
@@ -10,7 +10,9 @@ using System.Runtime.Intrinsics.X86;
namespace JIT.HardwareIntrinsics.X86
{
- public unsafe struct SimpleUnaryOpTest__DataTable<T> : IDisposable where T : struct
+ public unsafe struct SimpleUnaryOpTest__DataTable<TResult, TOp1> : IDisposable
+ where TResult : struct
+ where TOp1 : struct
{
private byte[] inArray;
private byte[] outArray;
@@ -20,7 +22,7 @@ namespace JIT.HardwareIntrinsics.X86
private byte simdSize;
- public SimpleUnaryOpTest__DataTable(T[] inArray, T[] outArray, int simdSize)
+ public SimpleUnaryOpTest__DataTable(TOp1[] inArray, TResult[] outArray, int simdSize)
{
this.inArray = new byte[simdSize * 2];
this.outArray = new byte[simdSize * 2];
@@ -30,7 +32,7 @@ namespace JIT.HardwareIntrinsics.X86
this.simdSize = unchecked((byte)(simdSize));
- Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArrayPtr), ref Unsafe.As<T, byte>(ref inArray[0]), this.simdSize);
+ Unsafe.CopyBlockUnaligned(ref Unsafe.AsRef<byte>(inArrayPtr), ref Unsafe.As<TOp1, byte>(ref inArray[0]), this.simdSize);
}
public void* inArrayPtr => Align((byte*)(inHandle.AddrOfPinnedObject().ToPointer()), simdSize);
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Add.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Add.Single.cs
index c894d11fb1..534445a08a 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Add.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Add.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AddSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__AddSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i] + right[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Add)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Add)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/AddScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/AddScalar.Single.cs
index 3e594225d6..1f82193694 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/AddScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/AddScalar.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AddScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__AddScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddScalarSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.AddScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.AddScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/And.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/And.Single.cs
index 984a441810..7601cdd34a 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/And.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/And.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__AndSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.And)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.And)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/AndNot.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/AndNot.Single.cs
index a5c8aba655..44a00de99a 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/AndNot.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/AndNot.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndNotSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__AndNotSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((~BitConverter.SingleToInt32Bits(left[0]) & BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.AndNot)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.AndNot)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqual.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqual.Single.cs
index 96da10ce4e..5ebe139b4e 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqual.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqual.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareEqualSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareEqualSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(result[i]) != ((left[i] == right[i]) ? -1 : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareEqual)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareEqual)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualOrderedScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualOrderedScalar.Boolean.cs
index cf99b9694a..51f4ce2dbd 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualOrderedScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualOrderedScalar.Boolean.cs
@@ -19,29 +19,35 @@ namespace JIT.HardwareIntrinsics.X86
{
public static partial class Program
{
- private static void CompareEqualOrderedScalarSingle()
+ private static void CompareEqualOrderedScalarBoolean()
{
- var test = new BooleanComparisonOpTest__CompareEqualOrderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareEqualOrderedScalarBoolean();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -74,13 +83,15 @@ namespace JIT.HardwareIntrinsics.X86
}
}
- public sealed unsafe class BooleanComparisonOpTest__CompareEqualOrderedScalarSingle
+ public sealed unsafe class BooleanComparisonOpTest__CompareEqualOrderedScalarBoolean
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,29 +99,32 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private BooleanComparisonOpTest__DataTable<Single> _dataTable;
+ private BooleanComparisonOpTest__DataTable<Single, Single> _dataTable;
- static BooleanComparisonOpTest__CompareEqualOrderedScalarSingle()
+ static BooleanComparisonOpTest__CompareEqualOrderedScalarBoolean()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
- public BooleanComparisonOpTest__CompareEqualOrderedScalarSingle()
+ public BooleanComparisonOpTest__CompareEqualOrderedScalarBoolean()
{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new BooleanComparisonOpTest__DataTable<Single>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new BooleanComparisonOpTest__DataTable<Single, Single>(_data1, _data2, VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -219,7 +233,7 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclFldScenario()
{
- var test = new BooleanComparisonOpTest__CompareEqualOrderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareEqualOrderedScalarBoolean();
var result = Sse.CompareEqualOrderedScalar(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
@@ -248,8 +262,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -259,8 +273,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -274,7 +288,7 @@ namespace JIT.HardwareIntrinsics.X86
{
Succeeded = false;
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareEqualOrderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareEqualOrderedScalar)}<Boolean>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualScalar.Single.cs
index b6ecfb7c9a..e4adeb9e31 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualScalar.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareEqualScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareEqualScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualScalarSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareEqualScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareEqualScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualUnorderedScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualUnorderedScalar.Boolean.cs
index 6145e8869c..135be02253 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualUnorderedScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareEqualUnorderedScalar.Boolean.cs
@@ -19,29 +19,35 @@ namespace JIT.HardwareIntrinsics.X86
{
public static partial class Program
{
- private static void CompareEqualUnorderedScalarSingle()
+ private static void CompareEqualUnorderedScalarBoolean()
{
- var test = new BooleanComparisonOpTest__CompareEqualUnorderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareEqualUnorderedScalarBoolean();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -74,13 +83,15 @@ namespace JIT.HardwareIntrinsics.X86
}
}
- public sealed unsafe class BooleanComparisonOpTest__CompareEqualUnorderedScalarSingle
+ public sealed unsafe class BooleanComparisonOpTest__CompareEqualUnorderedScalarBoolean
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,29 +99,32 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private BooleanComparisonOpTest__DataTable<Single> _dataTable;
+ private BooleanComparisonOpTest__DataTable<Single, Single> _dataTable;
- static BooleanComparisonOpTest__CompareEqualUnorderedScalarSingle()
+ static BooleanComparisonOpTest__CompareEqualUnorderedScalarBoolean()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
- public BooleanComparisonOpTest__CompareEqualUnorderedScalarSingle()
+ public BooleanComparisonOpTest__CompareEqualUnorderedScalarBoolean()
{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new BooleanComparisonOpTest__DataTable<Single>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new BooleanComparisonOpTest__DataTable<Single, Single>(_data1, _data2, VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -219,7 +233,7 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclFldScenario()
{
- var test = new BooleanComparisonOpTest__CompareEqualUnorderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareEqualUnorderedScalarBoolean();
var result = Sse.CompareEqualUnorderedScalar(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
@@ -248,8 +262,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -259,8 +273,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -274,7 +288,7 @@ namespace JIT.HardwareIntrinsics.X86
{
Succeeded = false;
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareEqualUnorderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareEqualUnorderedScalar)}<Boolean>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThan.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThan.Single.cs
index d351fd4f8e..7fbceb2101 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThan.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThan.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareGreaterThanSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(result[i]) != ((left[i] > right[i]) ? -1 : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThan)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThan)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqual.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqual.Single.cs
index 777796ff89..bcfd2ea8c3 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqual.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqual.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanOrEqualSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanOrEqualSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareGreaterThanOrEqualSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(result[i]) != ((left[i] >= right[i]) ? -1 : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanOrEqual)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanOrEqual)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualOrderedScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualOrderedScalar.Boolean.cs
index bf5c87d79d..08c508bb9a 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualOrderedScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualOrderedScalar.Boolean.cs
@@ -19,29 +19,35 @@ namespace JIT.HardwareIntrinsics.X86
{
public static partial class Program
{
- private static void CompareGreaterThanOrEqualOrderedScalarSingle()
+ private static void CompareGreaterThanOrEqualOrderedScalarBoolean()
{
- var test = new BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarBoolean();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -74,13 +83,15 @@ namespace JIT.HardwareIntrinsics.X86
}
}
- public sealed unsafe class BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarSingle
+ public sealed unsafe class BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarBoolean
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,29 +99,32 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private BooleanComparisonOpTest__DataTable<Single> _dataTable;
+ private BooleanComparisonOpTest__DataTable<Single, Single> _dataTable;
- static BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarSingle()
+ static BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarBoolean()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
- public BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarSingle()
+ public BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarBoolean()
{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new BooleanComparisonOpTest__DataTable<Single>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new BooleanComparisonOpTest__DataTable<Single, Single>(_data1, _data2, VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -219,7 +233,7 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclFldScenario()
{
- var test = new BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareGreaterThanOrEqualOrderedScalarBoolean();
var result = Sse.CompareGreaterThanOrEqualOrderedScalar(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
@@ -248,8 +262,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -259,8 +273,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -274,7 +288,7 @@ namespace JIT.HardwareIntrinsics.X86
{
Succeeded = false;
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanOrEqualOrderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanOrEqualOrderedScalar)}<Boolean>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualScalar.Single.cs
index f6179e3065..a1282c17c5 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualScalar.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanOrEqualScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanOrEqualScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareGreaterThanOrEqualScalarSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanOrEqualScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanOrEqualScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualUnorderedScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualUnorderedScalar.Boolean.cs
index 536688be34..6cd9870696 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualUnorderedScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrEqualUnorderedScalar.Boolean.cs
@@ -19,29 +19,35 @@ namespace JIT.HardwareIntrinsics.X86
{
public static partial class Program
{
- private static void CompareGreaterThanOrEqualUnorderedScalarSingle()
+ private static void CompareGreaterThanOrEqualUnorderedScalarBoolean()
{
- var test = new BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarBoolean();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -74,13 +83,15 @@ namespace JIT.HardwareIntrinsics.X86
}
}
- public sealed unsafe class BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarSingle
+ public sealed unsafe class BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarBoolean
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,29 +99,32 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private BooleanComparisonOpTest__DataTable<Single> _dataTable;
+ private BooleanComparisonOpTest__DataTable<Single, Single> _dataTable;
- static BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarSingle()
+ static BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarBoolean()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
- public BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarSingle()
+ public BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarBoolean()
{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new BooleanComparisonOpTest__DataTable<Single>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new BooleanComparisonOpTest__DataTable<Single, Single>(_data1, _data2, VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -219,7 +233,7 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclFldScenario()
{
- var test = new BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareGreaterThanOrEqualUnorderedScalarBoolean();
var result = Sse.CompareGreaterThanOrEqualUnorderedScalar(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
@@ -248,8 +262,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -259,8 +273,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -274,7 +288,7 @@ namespace JIT.HardwareIntrinsics.X86
{
Succeeded = false;
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanOrEqualUnorderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanOrEqualUnorderedScalar)}<Boolean>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrderedScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrderedScalar.Boolean.cs
index 1dec832ed1..772e1c50ca 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrderedScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanOrderedScalar.Boolean.cs
@@ -19,29 +19,35 @@ namespace JIT.HardwareIntrinsics.X86
{
public static partial class Program
{
- private static void CompareGreaterThanOrderedScalarSingle()
+ private static void CompareGreaterThanOrderedScalarBoolean()
{
- var test = new BooleanComparisonOpTest__CompareGreaterThanOrderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareGreaterThanOrderedScalarBoolean();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -74,13 +83,15 @@ namespace JIT.HardwareIntrinsics.X86
}
}
- public sealed unsafe class BooleanComparisonOpTest__CompareGreaterThanOrderedScalarSingle
+ public sealed unsafe class BooleanComparisonOpTest__CompareGreaterThanOrderedScalarBoolean
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,29 +99,32 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private BooleanComparisonOpTest__DataTable<Single> _dataTable;
+ private BooleanComparisonOpTest__DataTable<Single, Single> _dataTable;
- static BooleanComparisonOpTest__CompareGreaterThanOrderedScalarSingle()
+ static BooleanComparisonOpTest__CompareGreaterThanOrderedScalarBoolean()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
- public BooleanComparisonOpTest__CompareGreaterThanOrderedScalarSingle()
+ public BooleanComparisonOpTest__CompareGreaterThanOrderedScalarBoolean()
{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new BooleanComparisonOpTest__DataTable<Single>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new BooleanComparisonOpTest__DataTable<Single, Single>(_data1, _data2, VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -219,7 +233,7 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclFldScenario()
{
- var test = new BooleanComparisonOpTest__CompareGreaterThanOrderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareGreaterThanOrderedScalarBoolean();
var result = Sse.CompareGreaterThanOrderedScalar(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
@@ -248,8 +262,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -259,8 +273,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -274,7 +288,7 @@ namespace JIT.HardwareIntrinsics.X86
{
Succeeded = false;
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanOrderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanOrderedScalar)}<Boolean>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanScalar.Single.cs
index 38d4e2a80d..356c99e469 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanScalar.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareGreaterThanScalarSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanUnorderedScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanUnorderedScalar.Boolean.cs
index ffa170253f..02162413d8 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanUnorderedScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareGreaterThanUnorderedScalar.Boolean.cs
@@ -19,29 +19,35 @@ namespace JIT.HardwareIntrinsics.X86
{
public static partial class Program
{
- private static void CompareGreaterThanUnorderedScalarSingle()
+ private static void CompareGreaterThanUnorderedScalarBoolean()
{
- var test = new BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarBoolean();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -74,13 +83,15 @@ namespace JIT.HardwareIntrinsics.X86
}
}
- public sealed unsafe class BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarSingle
+ public sealed unsafe class BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarBoolean
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,29 +99,32 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private BooleanComparisonOpTest__DataTable<Single> _dataTable;
+ private BooleanComparisonOpTest__DataTable<Single, Single> _dataTable;
- static BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarSingle()
+ static BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarBoolean()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
- public BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarSingle()
+ public BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarBoolean()
{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new BooleanComparisonOpTest__DataTable<Single>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new BooleanComparisonOpTest__DataTable<Single, Single>(_data1, _data2, VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -219,7 +233,7 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclFldScenario()
{
- var test = new BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareGreaterThanUnorderedScalarBoolean();
var result = Sse.CompareGreaterThanUnorderedScalar(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
@@ -248,8 +262,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -259,8 +273,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -274,7 +288,7 @@ namespace JIT.HardwareIntrinsics.X86
{
Succeeded = false;
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanUnorderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareGreaterThanUnorderedScalar)}<Boolean>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThan.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThan.Single.cs
index d5ee27689c..85c177104c 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThan.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThan.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareLessThanSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareLessThanSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareLessThanSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(result[i]) != ((left[i] < right[i]) ? -1 : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThan)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThan)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqual.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqual.Single.cs
index a38d9c5217..c991d755a3 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqual.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqual.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareLessThanOrEqualSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareLessThanOrEqualSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareLessThanOrEqualSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(result[i]) != ((left[i] <= right[i]) ? -1 : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanOrEqual)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanOrEqual)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualOrderedScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualOrderedScalar.Boolean.cs
index 99a6fcf9bc..347564ee9e 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualOrderedScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualOrderedScalar.Boolean.cs
@@ -19,29 +19,35 @@ namespace JIT.HardwareIntrinsics.X86
{
public static partial class Program
{
- private static void CompareLessThanOrEqualOrderedScalarSingle()
+ private static void CompareLessThanOrEqualOrderedScalarBoolean()
{
- var test = new BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarBoolean();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -74,13 +83,15 @@ namespace JIT.HardwareIntrinsics.X86
}
}
- public sealed unsafe class BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarSingle
+ public sealed unsafe class BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarBoolean
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,29 +99,32 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private BooleanComparisonOpTest__DataTable<Single> _dataTable;
+ private BooleanComparisonOpTest__DataTable<Single, Single> _dataTable;
- static BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarSingle()
+ static BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarBoolean()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
- public BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarSingle()
+ public BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarBoolean()
{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new BooleanComparisonOpTest__DataTable<Single>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new BooleanComparisonOpTest__DataTable<Single, Single>(_data1, _data2, VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -219,7 +233,7 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclFldScenario()
{
- var test = new BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareLessThanOrEqualOrderedScalarBoolean();
var result = Sse.CompareLessThanOrEqualOrderedScalar(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
@@ -248,8 +262,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -259,8 +273,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -274,7 +288,7 @@ namespace JIT.HardwareIntrinsics.X86
{
Succeeded = false;
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanOrEqualOrderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanOrEqualOrderedScalar)}<Boolean>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualScalar.Single.cs
index 7fd6641997..9ec5684236 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualScalar.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareLessThanOrEqualScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareLessThanOrEqualScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareLessThanOrEqualScalarSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanOrEqualScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanOrEqualScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualUnorderedScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualUnorderedScalar.Boolean.cs
index 9ee8023738..28da15f675 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualUnorderedScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrEqualUnorderedScalar.Boolean.cs
@@ -19,29 +19,35 @@ namespace JIT.HardwareIntrinsics.X86
{
public static partial class Program
{
- private static void CompareLessThanOrEqualUnorderedScalarSingle()
+ private static void CompareLessThanOrEqualUnorderedScalarBoolean()
{
- var test = new BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarBoolean();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -74,13 +83,15 @@ namespace JIT.HardwareIntrinsics.X86
}
}
- public sealed unsafe class BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarSingle
+ public sealed unsafe class BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarBoolean
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,29 +99,32 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private BooleanComparisonOpTest__DataTable<Single> _dataTable;
+ private BooleanComparisonOpTest__DataTable<Single, Single> _dataTable;
- static BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarSingle()
+ static BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarBoolean()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
- public BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarSingle()
+ public BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarBoolean()
{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new BooleanComparisonOpTest__DataTable<Single>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new BooleanComparisonOpTest__DataTable<Single, Single>(_data1, _data2, VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -219,7 +233,7 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclFldScenario()
{
- var test = new BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareLessThanOrEqualUnorderedScalarBoolean();
var result = Sse.CompareLessThanOrEqualUnorderedScalar(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
@@ -248,8 +262,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -259,8 +273,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -274,7 +288,7 @@ namespace JIT.HardwareIntrinsics.X86
{
Succeeded = false;
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanOrEqualUnorderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanOrEqualUnorderedScalar)}<Boolean>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrderedScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrderedScalar.Boolean.cs
index 98a4a78845..4c63ee8174 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrderedScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanOrderedScalar.Boolean.cs
@@ -19,29 +19,35 @@ namespace JIT.HardwareIntrinsics.X86
{
public static partial class Program
{
- private static void CompareLessThanOrderedScalarSingle()
+ private static void CompareLessThanOrderedScalarBoolean()
{
- var test = new BooleanComparisonOpTest__CompareLessThanOrderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareLessThanOrderedScalarBoolean();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -74,13 +83,15 @@ namespace JIT.HardwareIntrinsics.X86
}
}
- public sealed unsafe class BooleanComparisonOpTest__CompareLessThanOrderedScalarSingle
+ public sealed unsafe class BooleanComparisonOpTest__CompareLessThanOrderedScalarBoolean
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,29 +99,32 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private BooleanComparisonOpTest__DataTable<Single> _dataTable;
+ private BooleanComparisonOpTest__DataTable<Single, Single> _dataTable;
- static BooleanComparisonOpTest__CompareLessThanOrderedScalarSingle()
+ static BooleanComparisonOpTest__CompareLessThanOrderedScalarBoolean()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
- public BooleanComparisonOpTest__CompareLessThanOrderedScalarSingle()
+ public BooleanComparisonOpTest__CompareLessThanOrderedScalarBoolean()
{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new BooleanComparisonOpTest__DataTable<Single>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new BooleanComparisonOpTest__DataTable<Single, Single>(_data1, _data2, VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -219,7 +233,7 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclFldScenario()
{
- var test = new BooleanComparisonOpTest__CompareLessThanOrderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareLessThanOrderedScalarBoolean();
var result = Sse.CompareLessThanOrderedScalar(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
@@ -248,8 +262,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -259,8 +273,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -274,7 +288,7 @@ namespace JIT.HardwareIntrinsics.X86
{
Succeeded = false;
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanOrderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanOrderedScalar)}<Boolean>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanScalar.Single.cs
index 448d1d6ba2..d945eb7dce 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanScalar.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareLessThanScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareLessThanScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareLessThanScalarSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanUnorderedScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanUnorderedScalar.Boolean.cs
index 896d1d7fab..1ae76a70e5 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanUnorderedScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareLessThanUnorderedScalar.Boolean.cs
@@ -19,29 +19,35 @@ namespace JIT.HardwareIntrinsics.X86
{
public static partial class Program
{
- private static void CompareLessThanUnorderedScalarSingle()
+ private static void CompareLessThanUnorderedScalarBoolean()
{
- var test = new BooleanComparisonOpTest__CompareLessThanUnorderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareLessThanUnorderedScalarBoolean();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -74,13 +83,15 @@ namespace JIT.HardwareIntrinsics.X86
}
}
- public sealed unsafe class BooleanComparisonOpTest__CompareLessThanUnorderedScalarSingle
+ public sealed unsafe class BooleanComparisonOpTest__CompareLessThanUnorderedScalarBoolean
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,29 +99,32 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private BooleanComparisonOpTest__DataTable<Single> _dataTable;
+ private BooleanComparisonOpTest__DataTable<Single, Single> _dataTable;
- static BooleanComparisonOpTest__CompareLessThanUnorderedScalarSingle()
+ static BooleanComparisonOpTest__CompareLessThanUnorderedScalarBoolean()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
- public BooleanComparisonOpTest__CompareLessThanUnorderedScalarSingle()
+ public BooleanComparisonOpTest__CompareLessThanUnorderedScalarBoolean()
{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new BooleanComparisonOpTest__DataTable<Single>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new BooleanComparisonOpTest__DataTable<Single, Single>(_data1, _data2, VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -219,7 +233,7 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclFldScenario()
{
- var test = new BooleanComparisonOpTest__CompareLessThanUnorderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareLessThanUnorderedScalarBoolean();
var result = Sse.CompareLessThanUnorderedScalar(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
@@ -248,8 +262,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -259,8 +273,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -274,7 +288,7 @@ namespace JIT.HardwareIntrinsics.X86
{
Succeeded = false;
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanUnorderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareLessThanUnorderedScalar)}<Boolean>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqual.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqual.Single.cs
index f2e83025d7..2bd0474828 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqual.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqual.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareNotEqualSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareNotEqualSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotEqualSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(result[i]) != ((left[i] != right[i]) ? -1 : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotEqual)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotEqual)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualOrderedScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualOrderedScalar.Boolean.cs
index 75de4bfd44..9513f0db14 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualOrderedScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualOrderedScalar.Boolean.cs
@@ -19,29 +19,35 @@ namespace JIT.HardwareIntrinsics.X86
{
public static partial class Program
{
- private static void CompareNotEqualOrderedScalarSingle()
+ private static void CompareNotEqualOrderedScalarBoolean()
{
- var test = new BooleanComparisonOpTest__CompareNotEqualOrderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareNotEqualOrderedScalarBoolean();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -74,13 +83,15 @@ namespace JIT.HardwareIntrinsics.X86
}
}
- public sealed unsafe class BooleanComparisonOpTest__CompareNotEqualOrderedScalarSingle
+ public sealed unsafe class BooleanComparisonOpTest__CompareNotEqualOrderedScalarBoolean
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,29 +99,32 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private BooleanComparisonOpTest__DataTable<Single> _dataTable;
+ private BooleanComparisonOpTest__DataTable<Single, Single> _dataTable;
- static BooleanComparisonOpTest__CompareNotEqualOrderedScalarSingle()
+ static BooleanComparisonOpTest__CompareNotEqualOrderedScalarBoolean()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
- public BooleanComparisonOpTest__CompareNotEqualOrderedScalarSingle()
+ public BooleanComparisonOpTest__CompareNotEqualOrderedScalarBoolean()
{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new BooleanComparisonOpTest__DataTable<Single>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new BooleanComparisonOpTest__DataTable<Single, Single>(_data1, _data2, VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -219,7 +233,7 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclFldScenario()
{
- var test = new BooleanComparisonOpTest__CompareNotEqualOrderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareNotEqualOrderedScalarBoolean();
var result = Sse.CompareNotEqualOrderedScalar(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
@@ -248,8 +262,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -259,8 +273,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -274,7 +288,7 @@ namespace JIT.HardwareIntrinsics.X86
{
Succeeded = false;
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotEqualOrderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotEqualOrderedScalar)}<Boolean>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualScalar.Single.cs
index 78b4d4b87b..f9c9c58e87 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualScalar.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareNotEqualScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareNotEqualScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotEqualScalarSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotEqualScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotEqualScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualUnorderedScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualUnorderedScalar.Boolean.cs
index fc6cca61b3..f1c4a524da 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualUnorderedScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotEqualUnorderedScalar.Boolean.cs
@@ -19,29 +19,35 @@ namespace JIT.HardwareIntrinsics.X86
{
public static partial class Program
{
- private static void CompareNotEqualUnorderedScalarSingle()
+ private static void CompareNotEqualUnorderedScalarBoolean()
{
- var test = new BooleanComparisonOpTest__CompareNotEqualUnorderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareNotEqualUnorderedScalarBoolean();
if (test.IsSupported)
{
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -74,13 +83,15 @@ namespace JIT.HardwareIntrinsics.X86
}
}
- public sealed unsafe class BooleanComparisonOpTest__CompareNotEqualUnorderedScalarSingle
+ public sealed unsafe class BooleanComparisonOpTest__CompareNotEqualUnorderedScalarBoolean
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,29 +99,32 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private BooleanComparisonOpTest__DataTable<Single> _dataTable;
+ private BooleanComparisonOpTest__DataTable<Single, Single> _dataTable;
- static BooleanComparisonOpTest__CompareNotEqualUnorderedScalarSingle()
+ static BooleanComparisonOpTest__CompareNotEqualUnorderedScalarBoolean()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
- public BooleanComparisonOpTest__CompareNotEqualUnorderedScalarSingle()
+ public BooleanComparisonOpTest__CompareNotEqualUnorderedScalarBoolean()
{
Succeeded = true;
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new BooleanComparisonOpTest__DataTable<Single>(_data1, _data2, VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new BooleanComparisonOpTest__DataTable<Single, Single>(_data1, _data2, VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -219,7 +233,7 @@ namespace JIT.HardwareIntrinsics.X86
public void RunLclFldScenario()
{
- var test = new BooleanComparisonOpTest__CompareNotEqualUnorderedScalarSingle();
+ var test = new BooleanComparisonOpTest__CompareNotEqualUnorderedScalarBoolean();
var result = Sse.CompareNotEqualUnorderedScalar(test._fld1, test._fld2);
ValidateResult(test._fld1, test._fld2, result);
@@ -248,8 +262,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -259,8 +273,8 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, bool result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -274,7 +288,7 @@ namespace JIT.HardwareIntrinsics.X86
{
Succeeded = false;
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotEqualUnorderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotEqualUnorderedScalar)}<Boolean>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThan.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThan.Single.cs
index c2c3797d71..0f89ef1d82 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThan.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThan.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareNotGreaterThanSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareNotGreaterThanSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotGreaterThanSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] > right[i]) ? -1 : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotGreaterThan)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotGreaterThan)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqual.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqual.Single.cs
index c23755d607..d3241ce214 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqual.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqual.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareNotGreaterThanOrEqualSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareNotGreaterThanOrEqualSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotGreaterThanOrEqualSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] >= right[i]) ? -1 : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotGreaterThanOrEqual)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotGreaterThanOrEqual)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqualScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqualScalar.Single.cs
index dca83ff945..1979c767bd 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqualScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanOrEqualScalar.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareNotGreaterThanOrEqualScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareNotGreaterThanOrEqualScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotGreaterThanOrEqualScalarSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotGreaterThanOrEqualScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotGreaterThanOrEqualScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanScalar.Single.cs
index 61b365e0b6..898c705e7b 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotGreaterThanScalar.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareNotGreaterThanScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareNotGreaterThanScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotGreaterThanScalarSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotGreaterThanScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotGreaterThanScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThan.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThan.Single.cs
index 20d6b01901..c9fb66920b 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThan.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThan.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareNotLessThanSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareNotLessThanSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotLessThanSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] < right[i]) ? -1 : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotLessThan)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotLessThan)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqual.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqual.Single.cs
index 939bfa9b51..396b0856a0 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqual.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqual.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareNotLessThanOrEqualSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareNotLessThanOrEqualSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotLessThanOrEqualSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(result[i]) != (!(left[i] <= right[i]) ? -1 : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotLessThanOrEqual)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotLessThanOrEqual)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqualScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqualScalar.Single.cs
index f8edf87bb7..c252cd2c6d 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqualScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanOrEqualScalar.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareNotLessThanOrEqualScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareNotLessThanOrEqualScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotLessThanOrEqualScalarSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotLessThanOrEqualScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotLessThanOrEqualScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanScalar.Single.cs
index 02fc9885cf..ab2c08232b 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareNotLessThanScalar.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareNotLessThanScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareNotLessThanScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotLessThanScalarSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotLessThanScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareNotLessThanScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrdered.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrdered.Single.cs
index cf7b897746..c315cde29b 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrdered.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrdered.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareOrderedSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareOrderedSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareOrderedSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(result[i]) != ((!float.IsNaN(left[i]) && !float.IsNaN(right[i])) ? -1 : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareOrdered)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareOrdered)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrderedScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrderedScalar.Single.cs
index 8e64be1bf5..4fad34423e 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrderedScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareOrderedScalar.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareOrderedScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareOrderedScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareOrderedScalarSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareOrderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareOrderedScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnordered.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnordered.Single.cs
index 70c0a8c80c..2fb8baa856 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnordered.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnordered.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareUnorderedSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareUnorderedSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareUnorderedSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(result[i]) != ((float.IsNaN(left[i]) || float.IsNaN(right[i])) ? -1 : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareUnordered)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareUnordered)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnorderedScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnorderedScalar.Single.cs
index 7466b711c1..e932e69922 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnorderedScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/CompareUnorderedScalar.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareUnorderedScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__CompareUnorderedScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareUnorderedScalarSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareUnorderedScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.CompareUnorderedScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Divide.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Divide.Single.cs
index ca5d35cc63..f76217fa6c 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Divide.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Divide.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__DivideSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__DivideSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__DivideSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i] / right[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Divide)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Divide)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/DivideScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/DivideScalar.Single.cs
index 001b209d78..f49ea039fa 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/DivideScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/DivideScalar.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__DivideScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__DivideScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__DivideScalarSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.DivideScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.DivideScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Max.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Max.Single.cs
index d8b3641653..c6a4c6c769 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Max.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Max.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__MaxSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__MaxSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MaxSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(Math.Max(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Max)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Max)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/MaxScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/MaxScalar.Single.cs
index 40198d0e63..75e2ff255e 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/MaxScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/MaxScalar.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__MaxScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__MaxScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MaxScalarSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.MaxScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.MaxScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Min.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Min.Single.cs
index 75413737b0..dd89a5b076 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Min.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Min.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__MinSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__MinSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MinSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(Math.Min(left[i], right[i])) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Min)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Min)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/MinScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/MinScalar.Single.cs
index 9efe272ab5..0634f8b3a1 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/MinScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/MinScalar.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__MinScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__MinScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MinScalarSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.MinScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.MinScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Multiply.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Multiply.Single.cs
index ba603f8ddd..99a71d038d 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Multiply.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Multiply.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__MultiplySingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__MultiplySingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MultiplySingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i] * right[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Multiply)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Multiply)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/MultiplyScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/MultiplyScalar.Single.cs
index cc353e45a0..1f5ad0c7a8 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/MultiplyScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/MultiplyScalar.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__MultiplyScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__MultiplyScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MultiplyScalarSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.MultiplyScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.MultiplyScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Or.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Or.Single.cs
index 93b8539fdf..a092544a21 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Or.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Or.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__OrSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__OrSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((BitConverter.SingleToInt32Bits(left[0]) | BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Or)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Or)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Program.Sse.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Program.Sse.cs
index 0358610402..ce98a40c60 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Program.Sse.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Program.Sse.cs
@@ -18,28 +18,28 @@ namespace JIT.HardwareIntrinsics.X86
["AndNot.Single"] = AndNotSingle,
["CompareEqual.Single"] = CompareEqualSingle,
["CompareEqualScalar.Single"] = CompareEqualScalarSingle,
- ["CompareEqualOrderedScalar.Single"] = CompareEqualOrderedScalarSingle,
- ["CompareEqualUnorderedScalar.Single"] = CompareEqualUnorderedScalarSingle,
+ ["CompareEqualOrderedScalar.Boolean"] = CompareEqualOrderedScalarBoolean,
+ ["CompareEqualUnorderedScalar.Boolean"] = CompareEqualUnorderedScalarBoolean,
["CompareGreaterThan.Single"] = CompareGreaterThanSingle,
["CompareGreaterThanScalar.Single"] = CompareGreaterThanScalarSingle,
- ["CompareGreaterThanOrderedScalar.Single"] = CompareGreaterThanOrderedScalarSingle,
- ["CompareGreaterThanUnorderedScalar.Single"] = CompareGreaterThanUnorderedScalarSingle,
+ ["CompareGreaterThanOrderedScalar.Boolean"] = CompareGreaterThanOrderedScalarBoolean,
+ ["CompareGreaterThanUnorderedScalar.Boolean"] = CompareGreaterThanUnorderedScalarBoolean,
["CompareGreaterThanOrEqual.Single"] = CompareGreaterThanOrEqualSingle,
["CompareGreaterThanOrEqualScalar.Single"] = CompareGreaterThanOrEqualScalarSingle,
- ["CompareGreaterThanOrEqualOrderedScalar.Single"] = CompareGreaterThanOrEqualOrderedScalarSingle,
- ["CompareGreaterThanOrEqualUnorderedScalar.Single"] = CompareGreaterThanOrEqualUnorderedScalarSingle,
+ ["CompareGreaterThanOrEqualOrderedScalar.Boolean"] = CompareGreaterThanOrEqualOrderedScalarBoolean,
+ ["CompareGreaterThanOrEqualUnorderedScalar.Boolean"] = CompareGreaterThanOrEqualUnorderedScalarBoolean,
["CompareLessThan.Single"] = CompareLessThanSingle,
["CompareLessThanScalar.Single"] = CompareLessThanScalarSingle,
- ["CompareLessThanOrderedScalar.Single"] = CompareLessThanOrderedScalarSingle,
- ["CompareLessThanUnorderedScalar.Single"] = CompareLessThanUnorderedScalarSingle,
+ ["CompareLessThanOrderedScalar.Boolean"] = CompareLessThanOrderedScalarBoolean,
+ ["CompareLessThanUnorderedScalar.Boolean"] = CompareLessThanUnorderedScalarBoolean,
["CompareLessThanOrEqual.Single"] = CompareLessThanOrEqualSingle,
["CompareLessThanOrEqualScalar.Single"] = CompareLessThanOrEqualScalarSingle,
- ["CompareLessThanOrEqualOrderedScalar.Single"] = CompareLessThanOrEqualOrderedScalarSingle,
- ["CompareLessThanOrEqualUnorderedScalar.Single"] = CompareLessThanOrEqualUnorderedScalarSingle,
+ ["CompareLessThanOrEqualOrderedScalar.Boolean"] = CompareLessThanOrEqualOrderedScalarBoolean,
+ ["CompareLessThanOrEqualUnorderedScalar.Boolean"] = CompareLessThanOrEqualUnorderedScalarBoolean,
["CompareNotEqual.Single"] = CompareNotEqualSingle,
["CompareNotEqualScalar.Single"] = CompareNotEqualScalarSingle,
- ["CompareNotEqualOrderedScalar.Single"] = CompareNotEqualOrderedScalarSingle,
- ["CompareNotEqualUnorderedScalar.Single"] = CompareNotEqualUnorderedScalarSingle,
+ ["CompareNotEqualOrderedScalar.Boolean"] = CompareNotEqualOrderedScalarBoolean,
+ ["CompareNotEqualUnorderedScalar.Boolean"] = CompareNotEqualUnorderedScalarBoolean,
["CompareNotGreaterThan.Single"] = CompareNotGreaterThanSingle,
["CompareNotGreaterThanScalar.Single"] = CompareNotGreaterThanScalarSingle,
["CompareNotGreaterThanOrEqual.Single"] = CompareNotGreaterThanOrEqualSingle,
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Sse_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Sse_r.csproj
index ee3966d9b2..c8a0b0a799 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Sse_r.csproj
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Sse_r.csproj
@@ -33,28 +33,28 @@
<Compile Include="AndNot.Single.cs" />
<Compile Include="CompareEqual.Single.cs" />
<Compile Include="CompareEqualScalar.Single.cs" />
- <Compile Include="CompareEqualOrderedScalar.Single.cs" />
- <Compile Include="CompareEqualUnorderedScalar.Single.cs" />
+ <Compile Include="CompareEqualOrderedScalar.Boolean.cs" />
+ <Compile Include="CompareEqualUnorderedScalar.Boolean.cs" />
<Compile Include="CompareGreaterThan.Single.cs" />
<Compile Include="CompareGreaterThanScalar.Single.cs" />
- <Compile Include="CompareGreaterThanOrderedScalar.Single.cs" />
- <Compile Include="CompareGreaterThanUnorderedScalar.Single.cs" />
+ <Compile Include="CompareGreaterThanOrderedScalar.Boolean.cs" />
+ <Compile Include="CompareGreaterThanUnorderedScalar.Boolean.cs" />
<Compile Include="CompareGreaterThanOrEqual.Single.cs" />
<Compile Include="CompareGreaterThanOrEqualScalar.Single.cs" />
- <Compile Include="CompareGreaterThanOrEqualOrderedScalar.Single.cs" />
- <Compile Include="CompareGreaterThanOrEqualUnorderedScalar.Single.cs" />
+ <Compile Include="CompareGreaterThanOrEqualOrderedScalar.Boolean.cs" />
+ <Compile Include="CompareGreaterThanOrEqualUnorderedScalar.Boolean.cs" />
<Compile Include="CompareLessThan.Single.cs" />
<Compile Include="CompareLessThanScalar.Single.cs" />
- <Compile Include="CompareLessThanOrderedScalar.Single.cs" />
- <Compile Include="CompareLessThanUnorderedScalar.Single.cs" />
+ <Compile Include="CompareLessThanOrderedScalar.Boolean.cs" />
+ <Compile Include="CompareLessThanUnorderedScalar.Boolean.cs" />
<Compile Include="CompareLessThanOrEqual.Single.cs" />
<Compile Include="CompareLessThanOrEqualScalar.Single.cs" />
- <Compile Include="CompareLessThanOrEqualOrderedScalar.Single.cs" />
- <Compile Include="CompareLessThanOrEqualUnorderedScalar.Single.cs" />
+ <Compile Include="CompareLessThanOrEqualOrderedScalar.Boolean.cs" />
+ <Compile Include="CompareLessThanOrEqualUnorderedScalar.Boolean.cs" />
<Compile Include="CompareNotEqual.Single.cs" />
<Compile Include="CompareNotEqualScalar.Single.cs" />
- <Compile Include="CompareNotEqualOrderedScalar.Single.cs" />
- <Compile Include="CompareNotEqualUnorderedScalar.Single.cs" />
+ <Compile Include="CompareNotEqualOrderedScalar.Boolean.cs" />
+ <Compile Include="CompareNotEqualUnorderedScalar.Boolean.cs" />
<Compile Include="CompareNotGreaterThan.Single.cs" />
<Compile Include="CompareNotGreaterThanScalar.Single.cs" />
<Compile Include="CompareNotGreaterThanOrEqual.Single.cs" />
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Sse_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Sse_ro.csproj
index 946557677a..e76a6d8dbe 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Sse_ro.csproj
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Sse_ro.csproj
@@ -33,28 +33,28 @@
<Compile Include="AndNot.Single.cs" />
<Compile Include="CompareEqual.Single.cs" />
<Compile Include="CompareEqualScalar.Single.cs" />
- <Compile Include="CompareEqualOrderedScalar.Single.cs" />
- <Compile Include="CompareEqualUnorderedScalar.Single.cs" />
+ <Compile Include="CompareEqualOrderedScalar.Boolean.cs" />
+ <Compile Include="CompareEqualUnorderedScalar.Boolean.cs" />
<Compile Include="CompareGreaterThan.Single.cs" />
<Compile Include="CompareGreaterThanScalar.Single.cs" />
- <Compile Include="CompareGreaterThanOrderedScalar.Single.cs" />
- <Compile Include="CompareGreaterThanUnorderedScalar.Single.cs" />
+ <Compile Include="CompareGreaterThanOrderedScalar.Boolean.cs" />
+ <Compile Include="CompareGreaterThanUnorderedScalar.Boolean.cs" />
<Compile Include="CompareGreaterThanOrEqual.Single.cs" />
<Compile Include="CompareGreaterThanOrEqualScalar.Single.cs" />
- <Compile Include="CompareGreaterThanOrEqualOrderedScalar.Single.cs" />
- <Compile Include="CompareGreaterThanOrEqualUnorderedScalar.Single.cs" />
+ <Compile Include="CompareGreaterThanOrEqualOrderedScalar.Boolean.cs" />
+ <Compile Include="CompareGreaterThanOrEqualUnorderedScalar.Boolean.cs" />
<Compile Include="CompareLessThan.Single.cs" />
<Compile Include="CompareLessThanScalar.Single.cs" />
- <Compile Include="CompareLessThanOrderedScalar.Single.cs" />
- <Compile Include="CompareLessThanUnorderedScalar.Single.cs" />
+ <Compile Include="CompareLessThanOrderedScalar.Boolean.cs" />
+ <Compile Include="CompareLessThanUnorderedScalar.Boolean.cs" />
<Compile Include="CompareLessThanOrEqual.Single.cs" />
<Compile Include="CompareLessThanOrEqualScalar.Single.cs" />
- <Compile Include="CompareLessThanOrEqualOrderedScalar.Single.cs" />
- <Compile Include="CompareLessThanOrEqualUnorderedScalar.Single.cs" />
+ <Compile Include="CompareLessThanOrEqualOrderedScalar.Boolean.cs" />
+ <Compile Include="CompareLessThanOrEqualUnorderedScalar.Boolean.cs" />
<Compile Include="CompareNotEqual.Single.cs" />
<Compile Include="CompareNotEqualScalar.Single.cs" />
- <Compile Include="CompareNotEqualOrderedScalar.Single.cs" />
- <Compile Include="CompareNotEqualUnorderedScalar.Single.cs" />
+ <Compile Include="CompareNotEqualOrderedScalar.Boolean.cs" />
+ <Compile Include="CompareNotEqualUnorderedScalar.Boolean.cs" />
<Compile Include="CompareNotGreaterThan.Single.cs" />
<Compile Include="CompareNotGreaterThanScalar.Single.cs" />
<Compile Include="CompareNotGreaterThanOrEqual.Single.cs" />
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Subtract.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Subtract.Single.cs
index 7a2bda1e6a..57c4b5615b 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Subtract.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Subtract.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__SubtractSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__SubtractSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i] - right[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Subtract)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Subtract)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/SubtractScalar.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/SubtractScalar.Single.cs
index e6a475e7a0..4a48af3624 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/SubtractScalar.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/SubtractScalar.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__SubtractScalarSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__SubtractScalarSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractScalarSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.SingleToInt32Bits(left[i]) != BitConverter.SingleToInt32Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.SubtractScalar)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.SubtractScalar)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Xor.Single.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Xor.Single.cs
index 6af8bc33c2..8f9eedc376 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse/Xor.Single.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse/Xor.Single.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__XorSingle
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Single);
- private static Single[] _data1 = new Single[ElementCount];
- private static Single[] _data2 = new Single[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Single);
+ private const int Op2ElementCount = VectorSize / sizeof(Single);
+ private const int RetElementCount = VectorSize / sizeof(Single);
+
+ private static Single[] _data1 = new Single[Op1ElementCount];
+ private static Single[] _data2 = new Single[Op2ElementCount];
private static Vector128<Single> _clsVar1;
private static Vector128<Single> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Single> _fld1;
private Vector128<Single> _fld2;
- private SimpleBinaryOpTest__DataTable<Single> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Single, Single, Single> _dataTable;
static SimpleBinaryOpTest__XorSingle()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _clsVar2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorSingle()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld1), ref Unsafe.As<Single, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Single>, byte>(ref _fld2), ref Unsafe.As<Single, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); _data2[i] = (float)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Single>(_data1, _data2, new Single[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (float)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (float)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Single, Single, Single>(_data1, _data2, new Single[RetElementCount], VectorSize);
}
public bool IsSupported => Sse.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Single> left, Vector128<Single> right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Single[] inArray1 = new Single[ElementCount];
- Single[] inArray2 = new Single[ElementCount];
- Single[] outArray = new Single[ElementCount];
+ Single[] inArray1 = new Single[Op1ElementCount];
+ Single[] inArray2 = new Single[Op2ElementCount];
+ Single[] outArray = new Single[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Single, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((BitConverter.SingleToInt32Bits(left[0]) ^ BitConverter.SingleToInt32Bits(right[0])) != BitConverter.SingleToInt32Bits(result[0]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Xor)}<Single>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse)}.{nameof(Sse.Xor)}<Single>(Vector128<Single>, Vector128<Single>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Byte.cs
index fec58076dd..ceb40a96ab 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Byte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Byte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AddByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector128<Byte> _clsVar1;
private static Vector128<Byte> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Byte> _fld1;
private Vector128<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__AddByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], 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 SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Byte> left, Vector128<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)(left[i] + right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<Byte>(Vector128<Byte>, Vector128<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Double.cs
index a6a2d771ee..10e9c81b4a 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AddDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__AddDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(left[i] + right[i]) != BitConverter.DoubleToInt64Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int16.cs
index a4e17a627f..25ac20670f 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AddInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector128<Int16> _clsVar1;
private static Vector128<Int16> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int16> _fld1;
private Vector128<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__AddInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int16> left, Vector128<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((short)(left[i] + right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<Int16>(Vector128<Int16>, Vector128<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int32.cs
index 2b6916f82b..4938b62b02 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AddInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector128<Int32> _clsVar1;
private static Vector128<Int32> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int32> _fld1;
private Vector128<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__AddInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int32> left, Vector128<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((int)(left[i] + right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<Int32>(Vector128<Int32>, Vector128<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int64.cs
index 09812f4270..1074967e0a 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.Int64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AddInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = VectorSize / sizeof(Int64);
+
+ private static Int64[] _data1 = new Int64[Op1ElementCount];
+ private static Int64[] _data2 = new Int64[Op2ElementCount];
private static Vector128<Int64> _clsVar1;
private static Vector128<Int64> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int64> _fld1;
private Vector128<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__AddInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int64> left, Vector128<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((long)(left[i] + right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<Int64>(Vector128<Int64>, Vector128<Int64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.SByte.cs
index 6db15f6a8f..f62dbd853f 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.SByte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.SByte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AddSByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector128<SByte> _clsVar1;
private static Vector128<SByte> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<SByte> _fld1;
private Vector128<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__AddSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddSByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], 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 SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<SByte> left, Vector128<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((sbyte)(left[i] + right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<SByte>(Vector128<SByte>, Vector128<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt16.cs
index b26b1dc64d..9bb80adc1f 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AddUInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = VectorSize / sizeof(UInt16);
+
+ private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+ private static UInt16[] _data2 = new UInt16[Op2ElementCount];
private static Vector128<UInt16> _clsVar1;
private static Vector128<UInt16> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<UInt16> _fld1;
private Vector128<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__AddUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddUInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<UInt16> left, Vector128<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)(left[i] + right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<UInt16>(Vector128<UInt16>, Vector128<UInt16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt32.cs
index 753093a392..d00d51322b 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AddUInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = VectorSize / sizeof(UInt32);
+
+ private static UInt32[] _data1 = new UInt32[Op1ElementCount];
+ private static UInt32[] _data2 = new UInt32[Op2ElementCount];
private static Vector128<UInt32> _clsVar1;
private static Vector128<UInt32> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<UInt32> _fld1;
private Vector128<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__AddUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddUInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<UInt32> left, Vector128<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((uint)(left[i] + right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<UInt32>(Vector128<UInt32>, Vector128<UInt32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt64.cs
index 23ee721995..b73a3a8f85 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Add.UInt64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AddUInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = VectorSize / sizeof(UInt64);
+
+ private static UInt64[] _data1 = new UInt64[Op1ElementCount];
+ private static UInt64[] _data2 = new UInt64[Op2ElementCount];
private static Vector128<UInt64> _clsVar1;
private static Vector128<UInt64> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<UInt64> _fld1;
private Vector128<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__AddUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AddUInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<UInt64> left, Vector128<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ulong)(left[i] + right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Add)}<UInt64>(Vector128<UInt64>, Vector128<UInt64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Byte.cs
index 9841e66e57..f3924f31a9 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Byte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Byte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector128<Byte> _clsVar1;
private static Vector128<Byte> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Byte> _fld1;
private Vector128<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__AndByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], 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 SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Byte> left, Vector128<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)(left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<Byte>(Vector128<Byte>, Vector128<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Double.cs
index 2f6f0d79c6..71c4854eb1 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__AndDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((BitConverter.DoubleToInt64Bits(left[i]) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int16.cs
index d5c18eeaf5..092c73a107 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector128<Int16> _clsVar1;
private static Vector128<Int16> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int16> _fld1;
private Vector128<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__AndInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int16> left, Vector128<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((short)(left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<Int16>(Vector128<Int16>, Vector128<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int32.cs
index f440ef540c..1a93262033 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector128<Int32> _clsVar1;
private static Vector128<Int32> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int32> _fld1;
private Vector128<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__AndInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int32> left, Vector128<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((int)(left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<Int32>(Vector128<Int32>, Vector128<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int64.cs
index f6c22b36de..fa7d363a18 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.Int64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = VectorSize / sizeof(Int64);
+
+ private static Int64[] _data1 = new Int64[Op1ElementCount];
+ private static Int64[] _data2 = new Int64[Op2ElementCount];
private static Vector128<Int64> _clsVar1;
private static Vector128<Int64> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int64> _fld1;
private Vector128<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__AndInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int64> left, Vector128<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((long)(left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<Int64>(Vector128<Int64>, Vector128<Int64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.SByte.cs
index 6bef767cfb..4afd964e85 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.SByte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.SByte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndSByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector128<SByte> _clsVar1;
private static Vector128<SByte> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<SByte> _fld1;
private Vector128<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__AndSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndSByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], 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 SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<SByte> left, Vector128<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((sbyte)(left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<SByte>(Vector128<SByte>, Vector128<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt16.cs
index 550dd341f7..0418698763 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndUInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = VectorSize / sizeof(UInt16);
+
+ private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+ private static UInt16[] _data2 = new UInt16[Op2ElementCount];
private static Vector128<UInt16> _clsVar1;
private static Vector128<UInt16> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<UInt16> _fld1;
private Vector128<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__AndUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndUInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<UInt16> left, Vector128<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)(left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<UInt16>(Vector128<UInt16>, Vector128<UInt16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt32.cs
index aa2329e740..b7eb74ffc1 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndUInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = VectorSize / sizeof(UInt32);
+
+ private static UInt32[] _data1 = new UInt32[Op1ElementCount];
+ private static UInt32[] _data2 = new UInt32[Op2ElementCount];
private static Vector128<UInt32> _clsVar1;
private static Vector128<UInt32> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<UInt32> _fld1;
private Vector128<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__AndUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndUInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<UInt32> left, Vector128<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((uint)(left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<UInt32>(Vector128<UInt32>, Vector128<UInt32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt64.cs
index dbfbbf68fc..1003aa9c13 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/And.UInt64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndUInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = VectorSize / sizeof(UInt64);
+
+ private static UInt64[] _data1 = new UInt64[Op1ElementCount];
+ private static UInt64[] _data2 = new UInt64[Op2ElementCount];
private static Vector128<UInt64> _clsVar1;
private static Vector128<UInt64> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<UInt64> _fld1;
private Vector128<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__AndUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndUInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<UInt64> left, Vector128<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ulong)(left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.And)}<UInt64>(Vector128<UInt64>, Vector128<UInt64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Byte.cs
index ae9c583b95..832a36452b 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Byte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Byte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndNotByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector128<Byte> _clsVar1;
private static Vector128<Byte> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Byte> _fld1;
private Vector128<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__AndNotByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], 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 SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Byte> left, Vector128<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)(~left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<Byte>(Vector128<Byte>, Vector128<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Double.cs
index 9a072eebce..f469ea8aa3 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndNotDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__AndNotDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((~BitConverter.DoubleToInt64Bits(left[i]) & BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int16.cs
index 695826926f..cd6edc32ab 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndNotInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector128<Int16> _clsVar1;
private static Vector128<Int16> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int16> _fld1;
private Vector128<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__AndNotInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int16> left, Vector128<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((short)(~left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<Int16>(Vector128<Int16>, Vector128<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int32.cs
index e381266bee..a609d2d118 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndNotInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector128<Int32> _clsVar1;
private static Vector128<Int32> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int32> _fld1;
private Vector128<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__AndNotInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int32> left, Vector128<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((int)(~left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<Int32>(Vector128<Int32>, Vector128<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int64.cs
index 652825cb3a..e0a58e3270 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.Int64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndNotInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = VectorSize / sizeof(Int64);
+
+ private static Int64[] _data1 = new Int64[Op1ElementCount];
+ private static Int64[] _data2 = new Int64[Op2ElementCount];
private static Vector128<Int64> _clsVar1;
private static Vector128<Int64> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int64> _fld1;
private Vector128<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__AndNotInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int64> left, Vector128<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((long)(~left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<Int64>(Vector128<Int64>, Vector128<Int64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.SByte.cs
index 0082496555..051a6a5d73 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.SByte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.SByte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndNotSByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector128<SByte> _clsVar1;
private static Vector128<SByte> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<SByte> _fld1;
private Vector128<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__AndNotSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotSByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], 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 SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<SByte> left, Vector128<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((sbyte)(~left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<SByte>(Vector128<SByte>, Vector128<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt16.cs
index ab2ed5f277..244b58a497 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndNotUInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = VectorSize / sizeof(UInt16);
+
+ private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+ private static UInt16[] _data2 = new UInt16[Op2ElementCount];
private static Vector128<UInt16> _clsVar1;
private static Vector128<UInt16> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<UInt16> _fld1;
private Vector128<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__AndNotUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotUInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<UInt16> left, Vector128<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)(~left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<UInt16>(Vector128<UInt16>, Vector128<UInt16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt32.cs
index 6f87e8757e..1b60c18221 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndNotUInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = VectorSize / sizeof(UInt32);
+
+ private static UInt32[] _data1 = new UInt32[Op1ElementCount];
+ private static UInt32[] _data2 = new UInt32[Op2ElementCount];
private static Vector128<UInt32> _clsVar1;
private static Vector128<UInt32> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<UInt32> _fld1;
private Vector128<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__AndNotUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotUInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<UInt32> left, Vector128<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((uint)(~left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<UInt32>(Vector128<UInt32>, Vector128<UInt32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt64.cs
index 64d975b4f5..6fcdc0b82d 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/AndNot.UInt64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__AndNotUInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = VectorSize / sizeof(UInt64);
+
+ private static UInt64[] _data1 = new UInt64[Op1ElementCount];
+ private static UInt64[] _data2 = new UInt64[Op2ElementCount];
private static Vector128<UInt64> _clsVar1;
private static Vector128<UInt64> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<UInt64> _fld1;
private Vector128<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__AndNotUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__AndNotUInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<UInt64> left, Vector128<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ulong)(~left[i] & right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.AndNot)}<UInt64>(Vector128<UInt64>, Vector128<UInt64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Byte.cs
index a97e76c268..b9c107ad9a 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Byte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Byte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareEqualByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector128<Byte> _clsVar1;
private static Vector128<Byte> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Byte> _fld1;
private Vector128<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__CompareEqualByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], 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 SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Byte> left, Vector128<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((byte)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<Byte>(Vector128<Byte>, Vector128<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Double.cs
index 8f2305cc5b..31d308d106 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareEqualDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__CompareEqualDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] == right[i]) ? -1 : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Int16.cs
index 567cecb4f7..ec8247280e 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Int16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Int16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareEqualInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector128<Int16> _clsVar1;
private static Vector128<Int16> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int16> _fld1;
private Vector128<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__CompareEqualInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int16> left, Vector128<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((short)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<Int16>(Vector128<Int16>, Vector128<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Int32.cs
index 7844d3f4e8..438d87310e 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Int32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.Int32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareEqualInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector128<Int32> _clsVar1;
private static Vector128<Int32> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int32> _fld1;
private Vector128<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__CompareEqualInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int32> left, Vector128<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((int)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<Int32>(Vector128<Int32>, Vector128<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.SByte.cs
index 55199d8902..9327cc116d 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.SByte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.SByte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareEqualSByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector128<SByte> _clsVar1;
private static Vector128<SByte> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<SByte> _fld1;
private Vector128<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__CompareEqualSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualSByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], 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 SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<SByte> left, Vector128<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((sbyte)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<SByte>(Vector128<SByte>, Vector128<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.UInt16.cs
index a61d1dc218..1d1d92dc6a 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.UInt16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.UInt16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareEqualUInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = VectorSize / sizeof(UInt16);
+
+ private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+ private static UInt16[] _data2 = new UInt16[Op2ElementCount];
private static Vector128<UInt16> _clsVar1;
private static Vector128<UInt16> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<UInt16> _fld1;
private Vector128<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__CompareEqualUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualUInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<UInt16> left, Vector128<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((ushort)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<UInt16>(Vector128<UInt16>, Vector128<UInt16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.UInt32.cs
index e9c2db3767..65a4372fa1 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.UInt32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareEqual.UInt32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareEqualUInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = VectorSize / sizeof(UInt32);
+
+ private static UInt32[] _data1 = new UInt32[Op1ElementCount];
+ private static UInt32[] _data2 = new UInt32[Op2ElementCount];
private static Vector128<UInt32> _clsVar1;
private static Vector128<UInt32> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<UInt32> _fld1;
private Vector128<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__CompareEqualUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualUInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<UInt32> left, Vector128<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((uint)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareEqual)}<UInt32>(Vector128<UInt32>, Vector128<UInt32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Double.cs
index bdc6052cf4..d05ea8a3b7 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareGreaterThanDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] > right[i]) ? -1 : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareGreaterThan)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareGreaterThan)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Int16.cs
index 4f5f5e6292..21f15db676 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Int16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Int16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector128<Int16> _clsVar1;
private static Vector128<Int16> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int16> _fld1;
private Vector128<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareGreaterThanInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int16> left, Vector128<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] > right[i]) ? unchecked((short)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareGreaterThan)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareGreaterThan)}<Int16>(Vector128<Int16>, Vector128<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Int32.cs
index e6c2541e4b..a5211eb3ed 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Int32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.Int32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector128<Int32> _clsVar1;
private static Vector128<Int32> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int32> _fld1;
private Vector128<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareGreaterThanInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int32> left, Vector128<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] > right[i]) ? unchecked((int)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareGreaterThan)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareGreaterThan)}<Int32>(Vector128<Int32>, Vector128<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.SByte.cs
index 56f523f98b..181d9d4146 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.SByte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThan.SByte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanSByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector128<SByte> _clsVar1;
private static Vector128<SByte> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<SByte> _fld1;
private Vector128<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareGreaterThanSByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], 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 SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<SByte> left, Vector128<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] > right[i]) ? unchecked((sbyte)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareGreaterThan)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareGreaterThan)}<SByte>(Vector128<SByte>, Vector128<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThanOrEqual.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThanOrEqual.Double.cs
index 2af59f78d0..f366b4591d 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThanOrEqual.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareGreaterThanOrEqual.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanOrEqualDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanOrEqualDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareGreaterThanOrEqualDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] >= right[i]) ? -1 : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareGreaterThanOrEqual)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareGreaterThanOrEqual)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Double.cs
index 937d4d8576..54a880f4e7 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareLessThanDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__CompareLessThanDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareLessThanDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] < right[i]) ? -1 : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareLessThan)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareLessThan)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Int16.cs
index 77bf3a4347..a0e162d694 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Int16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Int16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareLessThanInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector128<Int16> _clsVar1;
private static Vector128<Int16> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int16> _fld1;
private Vector128<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__CompareLessThanInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareLessThanInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int16> left, Vector128<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] < right[i]) ? unchecked((short)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareLessThan)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareLessThan)}<Int16>(Vector128<Int16>, Vector128<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Int32.cs
index 29042f122f..fbaa85b7c7 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Int32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.Int32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareLessThanInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector128<Int32> _clsVar1;
private static Vector128<Int32> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int32> _fld1;
private Vector128<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__CompareLessThanInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareLessThanInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int32> left, Vector128<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] < right[i]) ? unchecked((int)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareLessThan)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareLessThan)}<Int32>(Vector128<Int32>, Vector128<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.SByte.cs
index 17eb6f00b6..c11bb11933 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.SByte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThan.SByte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareLessThanSByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector128<SByte> _clsVar1;
private static Vector128<SByte> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<SByte> _fld1;
private Vector128<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__CompareLessThanSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareLessThanSByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], 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 SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<SByte> left, Vector128<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] < right[i]) ? unchecked((sbyte)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareLessThan)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareLessThan)}<SByte>(Vector128<SByte>, Vector128<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThanOrEqual.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThanOrEqual.Double.cs
index e8a2beb65f..2fcaf8ec0c 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThanOrEqual.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareLessThanOrEqual.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareLessThanOrEqualDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__CompareLessThanOrEqualDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareLessThanOrEqualDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] <= right[i]) ? -1 : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareLessThanOrEqual)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareLessThanOrEqual)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotEqual.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotEqual.Double.cs
index 8f34fcc250..bdbc2d2cb7 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotEqual.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotEqual.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareNotEqualDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__CompareNotEqualDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotEqualDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(result[i]) != ((left[i] != right[i]) ? -1 : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareNotEqual)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareNotEqual)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThan.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThan.Double.cs
index 1aca451839..c4bf1a7530 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThan.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThan.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareNotGreaterThanDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__CompareNotGreaterThanDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotGreaterThanDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] > right[i]) ? -1 : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareNotGreaterThan)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareNotGreaterThan)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThanOrEqual.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThanOrEqual.Double.cs
index 9b34b59a4e..135c267291 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThanOrEqual.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotGreaterThanOrEqual.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareNotGreaterThanOrEqualDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__CompareNotGreaterThanOrEqualDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotGreaterThanOrEqualDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] >= right[i]) ? -1 : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareNotGreaterThanOrEqual)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareNotGreaterThanOrEqual)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThan.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThan.Double.cs
index d2a124fa83..7e09d7299d 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThan.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThan.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareNotLessThanDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__CompareNotLessThanDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotLessThanDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] < right[i]) ? -1 : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareNotLessThan)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareNotLessThan)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThanOrEqual.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThanOrEqual.Double.cs
index d889a84d01..aba54b1d74 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThanOrEqual.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareNotLessThanOrEqual.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareNotLessThanOrEqualDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__CompareNotLessThanOrEqualDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareNotLessThanOrEqualDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(result[i]) != (!(left[i] <= right[i]) ? -1 : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareNotLessThanOrEqual)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareNotLessThanOrEqual)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareOrdered.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareOrdered.Double.cs
index a26d95d09d..c0fcd14646 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareOrdered.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareOrdered.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareOrderedDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__CompareOrderedDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareOrderedDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(result[i]) != ((!double.IsNaN(left[i]) && !double.IsNaN(right[i])) ? -1 : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareOrdered)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareOrdered)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareUnordered.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareUnordered.Double.cs
index a213bb723c..26f6215127 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareUnordered.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/CompareUnordered.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareUnorderedDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__CompareUnorderedDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareUnorderedDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(result[i]) != ((double.IsNaN(left[i]) || double.IsNaN(right[i])) ? -1 : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareUnordered)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.CompareUnordered)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Divide.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Divide.Double.cs
index 34315c1f5b..5be2f34960 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Divide.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Divide.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__DivideDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__DivideDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__DivideDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(left[i] / right[i]) != BitConverter.DoubleToInt64Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Divide)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Divide)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Byte.cs
index d03267468f..cad2cafc16 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Byte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Byte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__MaxByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector128<Byte> _clsVar1;
private static Vector128<Byte> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Byte> _fld1;
private Vector128<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__MaxByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MaxByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], 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 SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Byte> left, Vector128<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (Math.Max(left[i], right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Max)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Max)}<Byte>(Vector128<Byte>, Vector128<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Double.cs
index 49df538161..b282c730d0 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__MaxDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__MaxDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MaxDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(Math.Max(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Max)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Max)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Int16.cs
index 20b2d6fe26..4d022ed9b2 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Int16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Max.Int16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__MaxInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector128<Int16> _clsVar1;
private static Vector128<Int16> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int16> _fld1;
private Vector128<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__MaxInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MaxInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int16> left, Vector128<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (Math.Max(left[i], right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Max)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Max)}<Int16>(Vector128<Int16>, Vector128<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Byte.cs
index 73a6b915e8..872f85c62e 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Byte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Byte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__MinByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector128<Byte> _clsVar1;
private static Vector128<Byte> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Byte> _fld1;
private Vector128<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__MinByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MinValue)); _data2[i] = (byte)(random.Next(0, byte.MinValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MinValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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.MinValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MinByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MinValue)); _data2[i] = (byte)(random.Next(0, byte.MinValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MinValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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.MinValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MinValue)); _data2[i] = (byte)(random.Next(0, byte.MinValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MinValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (byte)(random.Next(0, byte.MinValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Byte> left, Vector128<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (Math.Min(left[i], right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Min)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Min)}<Byte>(Vector128<Byte>, Vector128<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Double.cs
index 4d8e914ff0..49eda34e59 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__MinDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__MinDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MinDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(Math.Min(left[i], right[i])) != BitConverter.DoubleToInt64Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Min)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Min)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Int16.cs
index 9019540d3d..b3e86cc8ba 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Int16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Min.Int16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__MinInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector128<Int16> _clsVar1;
private static Vector128<Int16> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int16> _fld1;
private Vector128<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__MinInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MinValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MinValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MinValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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.MinValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MinInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MinValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MinValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MinValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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.MinValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MinValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MinValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MinValue)); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (short)(random.Next(short.MinValue, short.MinValue)); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int16> left, Vector128<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (Math.Min(left[i], right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Min)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Min)}<Int16>(Vector128<Int16>, Vector128<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Multiply.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Multiply.Double.cs
index 09fa36e52d..01495135d5 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Multiply.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Multiply.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__MultiplyDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__MultiplyDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__MultiplyDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(left[i] * right[i]) != BitConverter.DoubleToInt64Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Multiply)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Multiply)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Byte.cs
index 6481107fab..ff638cf3f7 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Byte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Byte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__OrByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector128<Byte> _clsVar1;
private static Vector128<Byte> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Byte> _fld1;
private Vector128<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__OrByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], 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 SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Byte> left, Vector128<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)(left[i] | right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<Byte>(Vector128<Byte>, Vector128<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Double.cs
index bfa8d33473..72f6c5651e 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__OrDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__OrDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((BitConverter.DoubleToInt64Bits(left[i]) | BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int16.cs
index 2d3fe08199..898a63a377 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__OrInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector128<Int16> _clsVar1;
private static Vector128<Int16> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int16> _fld1;
private Vector128<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__OrInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int16> left, Vector128<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((short)(left[i] | right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<Int16>(Vector128<Int16>, Vector128<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int32.cs
index fbe5b1ced9..674e8e6bdc 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__OrInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector128<Int32> _clsVar1;
private static Vector128<Int32> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int32> _fld1;
private Vector128<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__OrInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int32> left, Vector128<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((int)(left[i] | right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<Int32>(Vector128<Int32>, Vector128<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int64.cs
index 861aed23c9..3e15eac690 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.Int64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__OrInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = VectorSize / sizeof(Int64);
+
+ private static Int64[] _data1 = new Int64[Op1ElementCount];
+ private static Int64[] _data2 = new Int64[Op2ElementCount];
private static Vector128<Int64> _clsVar1;
private static Vector128<Int64> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int64> _fld1;
private Vector128<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__OrInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int64> left, Vector128<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((long)(left[i] | right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<Int64>(Vector128<Int64>, Vector128<Int64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.SByte.cs
index 56a3cfb4aa..cffcbb6579 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.SByte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.SByte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__OrSByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector128<SByte> _clsVar1;
private static Vector128<SByte> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<SByte> _fld1;
private Vector128<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__OrSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrSByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], 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 SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<SByte> left, Vector128<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((sbyte)(left[i] | right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<SByte>(Vector128<SByte>, Vector128<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt16.cs
index ea151578a3..643ab5b8d3 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__OrUInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = VectorSize / sizeof(UInt16);
+
+ private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+ private static UInt16[] _data2 = new UInt16[Op2ElementCount];
private static Vector128<UInt16> _clsVar1;
private static Vector128<UInt16> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<UInt16> _fld1;
private Vector128<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__OrUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrUInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<UInt16> left, Vector128<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)(left[i] | right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<UInt16>(Vector128<UInt16>, Vector128<UInt16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt32.cs
index b03776135c..a981df138b 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__OrUInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = VectorSize / sizeof(UInt32);
+
+ private static UInt32[] _data1 = new UInt32[Op1ElementCount];
+ private static UInt32[] _data2 = new UInt32[Op2ElementCount];
private static Vector128<UInt32> _clsVar1;
private static Vector128<UInt32> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<UInt32> _fld1;
private Vector128<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__OrUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrUInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<UInt32> left, Vector128<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((uint)(left[i] | right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<UInt32>(Vector128<UInt32>, Vector128<UInt32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt64.cs
index 40e22b43d7..eb8c2d67aa 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Or.UInt64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__OrUInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = VectorSize / sizeof(UInt64);
+
+ private static UInt64[] _data1 = new UInt64[Op1ElementCount];
+ private static UInt64[] _data2 = new UInt64[Op2ElementCount];
private static Vector128<UInt64> _clsVar1;
private static Vector128<UInt64> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<UInt64> _fld1;
private Vector128<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__OrUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__OrUInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<UInt64> left, Vector128<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ulong)(left[i] | right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Or)}<UInt64>(Vector128<UInt64>, Vector128<UInt64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Byte.cs
index dcd9ed39fe..205e1f7bb8 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Byte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Byte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__SubtractByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector128<Byte> _clsVar1;
private static Vector128<Byte> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Byte> _fld1;
private Vector128<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__SubtractByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], 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 SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Byte> left, Vector128<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)(left[i] - right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<Byte>(Vector128<Byte>, Vector128<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Double.cs
index 0e8c22da1d..0ebd0f14da 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__SubtractDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__SubtractDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (BitConverter.DoubleToInt64Bits(left[i] - right[i]) != BitConverter.DoubleToInt64Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int16.cs
index 737fd780f0..500297f9cd 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__SubtractInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector128<Int16> _clsVar1;
private static Vector128<Int16> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int16> _fld1;
private Vector128<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__SubtractInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int16> left, Vector128<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((short)(left[i] - right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<Int16>(Vector128<Int16>, Vector128<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int32.cs
index eb31b7ece7..061f315941 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__SubtractInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector128<Int32> _clsVar1;
private static Vector128<Int32> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int32> _fld1;
private Vector128<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__SubtractInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int32> left, Vector128<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((int)(left[i] - right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<Int32>(Vector128<Int32>, Vector128<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int64.cs
index f67c4f8604..f83b1a2ce3 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.Int64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__SubtractInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = VectorSize / sizeof(Int64);
+
+ private static Int64[] _data1 = new Int64[Op1ElementCount];
+ private static Int64[] _data2 = new Int64[Op2ElementCount];
private static Vector128<Int64> _clsVar1;
private static Vector128<Int64> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int64> _fld1;
private Vector128<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__SubtractInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int64> left, Vector128<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((long)(left[i] - right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<Int64>(Vector128<Int64>, Vector128<Int64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.SByte.cs
index c3fe70cbd6..4eb10c2b35 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.SByte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.SByte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__SubtractSByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector128<SByte> _clsVar1;
private static Vector128<SByte> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<SByte> _fld1;
private Vector128<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__SubtractSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractSByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], 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 SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<SByte> left, Vector128<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((sbyte)(left[i] - right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<SByte>(Vector128<SByte>, Vector128<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt16.cs
index 3ac3c7ff46..0ac431e7fb 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__SubtractUInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = VectorSize / sizeof(UInt16);
+
+ private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+ private static UInt16[] _data2 = new UInt16[Op2ElementCount];
private static Vector128<UInt16> _clsVar1;
private static Vector128<UInt16> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<UInt16> _fld1;
private Vector128<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__SubtractUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractUInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<UInt16> left, Vector128<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)(left[i] - right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<UInt16>(Vector128<UInt16>, Vector128<UInt16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt32.cs
index dd4ead9740..1647d0b1fa 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__SubtractUInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = VectorSize / sizeof(UInt32);
+
+ private static UInt32[] _data1 = new UInt32[Op1ElementCount];
+ private static UInt32[] _data2 = new UInt32[Op2ElementCount];
private static Vector128<UInt32> _clsVar1;
private static Vector128<UInt32> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<UInt32> _fld1;
private Vector128<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__SubtractUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractUInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<UInt32> left, Vector128<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((uint)(left[i] - right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<UInt32>(Vector128<UInt32>, Vector128<UInt32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt64.cs
index 992fe56faa..0f1d080da9 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Subtract.UInt64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__SubtractUInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = VectorSize / sizeof(UInt64);
+
+ private static UInt64[] _data1 = new UInt64[Op1ElementCount];
+ private static UInt64[] _data2 = new UInt64[Op2ElementCount];
private static Vector128<UInt64> _clsVar1;
private static Vector128<UInt64> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<UInt64> _fld1;
private Vector128<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__SubtractUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__SubtractUInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<UInt64> left, Vector128<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ulong)(left[i] - right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Subtract)}<UInt64>(Vector128<UInt64>, Vector128<UInt64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Byte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Byte.cs
index 6d8ad708ba..f7a7f469b0 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Byte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Byte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__XorByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Byte);
- private static Byte[] _data1 = new Byte[ElementCount];
- private static Byte[] _data2 = new Byte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Byte);
+ private const int Op2ElementCount = VectorSize / sizeof(Byte);
+ private const int RetElementCount = VectorSize / sizeof(Byte);
+
+ private static Byte[] _data1 = new Byte[Op1ElementCount];
+ private static Byte[] _data2 = new Byte[Op2ElementCount];
private static Vector128<Byte> _clsVar1;
private static Vector128<Byte> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Byte> _fld1;
private Vector128<Byte> _fld2;
- private SimpleBinaryOpTest__DataTable<Byte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Byte, Byte, Byte> _dataTable;
static SimpleBinaryOpTest__XorByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar1), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Byte>, byte>(ref _clsVar2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Byte>, byte>(ref _fld2), ref Unsafe.As<Byte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (byte)(random.Next(0, byte.MaxValue)); _data2[i] = (byte)(random.Next(0, byte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Byte>(_data1, _data2, new Byte[ElementCount], 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 SimpleBinaryOpTest__DataTable<Byte, Byte, Byte>(_data1, _data2, new Byte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Byte> left, Vector128<Byte> right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Byte[] inArray1 = new Byte[ElementCount];
- Byte[] inArray2 = new Byte[ElementCount];
- Byte[] outArray = new Byte[ElementCount];
+ Byte[] inArray1 = new Byte[Op1ElementCount];
+ Byte[] inArray2 = new Byte[Op2ElementCount];
+ Byte[] outArray = new Byte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((byte)(left[i] ^ right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<Byte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<Byte>(Vector128<Byte>, Vector128<Byte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Double.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Double.cs
index 3bbf24a14f..479399f36c 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Double.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Double.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__XorDouble
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Double);
- private static Double[] _data1 = new Double[ElementCount];
- private static Double[] _data2 = new Double[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Double);
+ private const int Op2ElementCount = VectorSize / sizeof(Double);
+ private const int RetElementCount = VectorSize / sizeof(Double);
+
+ private static Double[] _data1 = new Double[Op1ElementCount];
+ private static Double[] _data2 = new Double[Op2ElementCount];
private static Vector128<Double> _clsVar1;
private static Vector128<Double> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Double> _fld1;
private Vector128<Double> _fld2;
- private SimpleBinaryOpTest__DataTable<Double> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Double, Double, Double> _dataTable;
static SimpleBinaryOpTest__XorDouble()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorDouble()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); _data2[i] = (double)(random.NextDouble()); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Double>(_data1, _data2, new Double[ElementCount], VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (double)(random.NextDouble()); }
+ for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = (double)(random.NextDouble()); }
+ _dataTable = new SimpleBinaryOpTest__DataTable<Double, Double, Double>(_data1, _data2, new Double[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Double> left, Vector128<Double> right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Double[] inArray1 = new Double[ElementCount];
- Double[] inArray2 = new Double[ElementCount];
- Double[] outArray = new Double[ElementCount];
+ Double[] inArray1 = new Double[Op1ElementCount];
+ Double[] inArray2 = new Double[Op2ElementCount];
+ Double[] outArray = new Double[RetElementCount];
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(left), VectorSize);
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(right), VectorSize);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((BitConverter.DoubleToInt64Bits(left[i]) ^ BitConverter.DoubleToInt64Bits(right[i])) != BitConverter.DoubleToInt64Bits(result[i]))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<Double>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<Double>(Vector128<Double>, Vector128<Double>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int16.cs
index c14ac4d434..c6756e80f9 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__XorInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int16);
- private static Int16[] _data1 = new Int16[ElementCount];
- private static Int16[] _data2 = new Int16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int16);
+ private const int Op2ElementCount = VectorSize / sizeof(Int16);
+ private const int RetElementCount = VectorSize / sizeof(Int16);
+
+ private static Int16[] _data1 = new Int16[Op1ElementCount];
+ private static Int16[] _data2 = new Int16[Op2ElementCount];
private static Vector128<Int16> _clsVar1;
private static Vector128<Int16> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int16> _fld1;
private Vector128<Int16> _fld2;
- private SimpleBinaryOpTest__DataTable<Int16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int16, Int16, Int16> _dataTable;
static SimpleBinaryOpTest__XorInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar1), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int16>, byte>(ref _clsVar2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int16>, byte>(ref _fld2), ref Unsafe.As<Int16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (short)(random.Next(short.MinValue, short.MaxValue)); _data2[i] = (short)(random.Next(short.MinValue, short.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int16>(_data1, _data2, new Int16[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int16, Int16, Int16>(_data1, _data2, new Int16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int16> left, Vector128<Int16> right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int16[] inArray1 = new Int16[ElementCount];
- Int16[] inArray2 = new Int16[ElementCount];
- Int16[] outArray = new Int16[ElementCount];
+ Int16[] inArray1 = new Int16[Op1ElementCount];
+ Int16[] inArray2 = new Int16[Op2ElementCount];
+ Int16[] outArray = new Int16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((short)(left[i] ^ right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<Int16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<Int16>(Vector128<Int16>, Vector128<Int16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int32.cs
index 2a7970763b..dd20fb5351 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__XorInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int32);
- private static Int32[] _data1 = new Int32[ElementCount];
- private static Int32[] _data2 = new Int32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int32);
+ private const int Op2ElementCount = VectorSize / sizeof(Int32);
+ private const int RetElementCount = VectorSize / sizeof(Int32);
+
+ private static Int32[] _data1 = new Int32[Op1ElementCount];
+ private static Int32[] _data2 = new Int32[Op2ElementCount];
private static Vector128<Int32> _clsVar1;
private static Vector128<Int32> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int32> _fld1;
private Vector128<Int32> _fld2;
- private SimpleBinaryOpTest__DataTable<Int32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int32, Int32, Int32> _dataTable;
static SimpleBinaryOpTest__XorInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar1), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int32>, byte>(ref _clsVar2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int32>, byte>(ref _fld2), ref Unsafe.As<Int32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (int)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (int)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int32>(_data1, _data2, new Int32[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int32, Int32, Int32>(_data1, _data2, new Int32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int32> left, Vector128<Int32> right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int32[] inArray1 = new Int32[ElementCount];
- Int32[] inArray2 = new Int32[ElementCount];
- Int32[] outArray = new Int32[ElementCount];
+ Int32[] inArray1 = new Int32[Op1ElementCount];
+ Int32[] inArray2 = new Int32[Op2ElementCount];
+ Int32[] outArray = new Int32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((int)(left[i] ^ right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<Int32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<Int32>(Vector128<Int32>, Vector128<Int32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int64.cs
index be2e77e03f..a7515744c6 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.Int64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__XorInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = VectorSize / sizeof(Int64);
+
+ private static Int64[] _data1 = new Int64[Op1ElementCount];
+ private static Int64[] _data2 = new Int64[Op2ElementCount];
private static Vector128<Int64> _clsVar1;
private static Vector128<Int64> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int64> _fld1;
private Vector128<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__XorInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int64> left, Vector128<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((long)(left[i] ^ right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<Int64>(Vector128<Int64>, Vector128<Int64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.SByte.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.SByte.cs
index 77d25337a2..d9be054c46 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.SByte.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.SByte.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__XorSByte
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(SByte);
- private static SByte[] _data1 = new SByte[ElementCount];
- private static SByte[] _data2 = new SByte[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(SByte);
+ private const int Op2ElementCount = VectorSize / sizeof(SByte);
+ private const int RetElementCount = VectorSize / sizeof(SByte);
+
+ private static SByte[] _data1 = new SByte[Op1ElementCount];
+ private static SByte[] _data2 = new SByte[Op2ElementCount];
private static Vector128<SByte> _clsVar1;
private static Vector128<SByte> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<SByte> _fld1;
private Vector128<SByte> _fld2;
- private SimpleBinaryOpTest__DataTable<SByte> _dataTable;
+ private SimpleBinaryOpTest__DataTable<SByte, SByte, SByte> _dataTable;
static SimpleBinaryOpTest__XorSByte()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar1), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<SByte>, byte>(ref _clsVar2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorSByte()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<SByte>, byte>(ref _fld2), ref Unsafe.As<SByte, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); _data2[i] = (sbyte)(random.Next(sbyte.MinValue, sbyte.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<SByte>(_data1, _data2, new SByte[ElementCount], 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 SimpleBinaryOpTest__DataTable<SByte, SByte, SByte>(_data1, _data2, new SByte[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<SByte> left, Vector128<SByte> right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- SByte[] inArray1 = new SByte[ElementCount];
- SByte[] inArray2 = new SByte[ElementCount];
- SByte[] outArray = new SByte[ElementCount];
+ SByte[] inArray1 = new SByte[Op1ElementCount];
+ SByte[] inArray2 = new SByte[Op2ElementCount];
+ SByte[] outArray = new SByte[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((sbyte)(left[i] ^ right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<SByte>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<SByte>(Vector128<SByte>, Vector128<SByte>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt16.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt16.cs
index 89aad87dba..687351b893 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt16.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt16.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__XorUInt16
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt16);
- private static UInt16[] _data1 = new UInt16[ElementCount];
- private static UInt16[] _data2 = new UInt16[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt16);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt16);
+ private const int RetElementCount = VectorSize / sizeof(UInt16);
+
+ private static UInt16[] _data1 = new UInt16[Op1ElementCount];
+ private static UInt16[] _data2 = new UInt16[Op2ElementCount];
private static Vector128<UInt16> _clsVar1;
private static Vector128<UInt16> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<UInt16> _fld1;
private Vector128<UInt16> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt16> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16> _dataTable;
static SimpleBinaryOpTest__XorUInt16()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar1), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt16>, byte>(ref _clsVar2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorUInt16()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt16>, byte>(ref _fld2), ref Unsafe.As<UInt16, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ushort)(random.Next(0, ushort.MaxValue)); _data2[i] = (ushort)(random.Next(0, ushort.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt16>(_data1, _data2, new UInt16[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt16, UInt16, UInt16>(_data1, _data2, new UInt16[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<UInt16> left, Vector128<UInt16> right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt16[] inArray1 = new UInt16[ElementCount];
- UInt16[] inArray2 = new UInt16[ElementCount];
- UInt16[] outArray = new UInt16[ElementCount];
+ UInt16[] inArray1 = new UInt16[Op1ElementCount];
+ UInt16[] inArray2 = new UInt16[Op2ElementCount];
+ UInt16[] outArray = new UInt16[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ushort)(left[i] ^ right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<UInt16>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<UInt16>(Vector128<UInt16>, Vector128<UInt16>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt32.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt32.cs
index 479b11151d..ddf6feca11 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt32.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt32.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__XorUInt32
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt32);
- private static UInt32[] _data1 = new UInt32[ElementCount];
- private static UInt32[] _data2 = new UInt32[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt32);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt32);
+ private const int RetElementCount = VectorSize / sizeof(UInt32);
+
+ private static UInt32[] _data1 = new UInt32[Op1ElementCount];
+ private static UInt32[] _data2 = new UInt32[Op2ElementCount];
private static Vector128<UInt32> _clsVar1;
private static Vector128<UInt32> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<UInt32> _fld1;
private Vector128<UInt32> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt32> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32> _dataTable;
static SimpleBinaryOpTest__XorUInt32()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar1), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt32>, byte>(ref _clsVar2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorUInt32()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt32>, byte>(ref _fld2), ref Unsafe.As<UInt32, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (uint)(random.Next(0, int.MaxValue)); _data2[i] = (uint)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt32>(_data1, _data2, new UInt32[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt32, UInt32, UInt32>(_data1, _data2, new UInt32[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<UInt32> left, Vector128<UInt32> right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt32[] inArray1 = new UInt32[ElementCount];
- UInt32[] inArray2 = new UInt32[ElementCount];
- UInt32[] outArray = new UInt32[ElementCount];
+ UInt32[] inArray1 = new UInt32[Op1ElementCount];
+ UInt32[] inArray2 = new UInt32[Op2ElementCount];
+ UInt32[] outArray = new UInt32[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((uint)(left[i] ^ right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<UInt32>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<UInt32>(Vector128<UInt32>, Vector128<UInt32>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt64.cs
index 2a448a4c48..720c11f03a 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse2/Xor.UInt64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__XorUInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = VectorSize / sizeof(UInt64);
+
+ private static UInt64[] _data1 = new UInt64[Op1ElementCount];
+ private static UInt64[] _data2 = new UInt64[Op2ElementCount];
private static Vector128<UInt64> _clsVar1;
private static Vector128<UInt64> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<UInt64> _fld1;
private Vector128<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__XorUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__XorUInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse2.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<UInt64> left, Vector128<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if ((ulong)(left[i] ^ right[i]) != result[i])
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse2)}.{nameof(Sse2.Xor)}<UInt64>(Vector128<UInt64>, Vector128<UInt64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/CompareEqual.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/CompareEqual.Int64.cs
index 3759d72de6..7da279a1a2 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/CompareEqual.Int64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/CompareEqual.Int64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareEqualInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = VectorSize / sizeof(Int64);
+
+ private static Int64[] _data1 = new Int64[Op1ElementCount];
+ private static Int64[] _data2 = new Int64[Op2ElementCount];
private static Vector128<Int64> _clsVar1;
private static Vector128<Int64> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int64> _fld1;
private Vector128<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__CompareEqualInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse41.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int64> left, Vector128<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((long)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.CompareEqual)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.CompareEqual)}<Int64>(Vector128<Int64>, Vector128<Int64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/CompareEqual.UInt64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/CompareEqual.UInt64.cs
index 146847f861..970b5dc5d0 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse41/CompareEqual.UInt64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse41/CompareEqual.UInt64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareEqualUInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(UInt64);
- private static UInt64[] _data1 = new UInt64[ElementCount];
- private static UInt64[] _data2 = new UInt64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(UInt64);
+ private const int Op2ElementCount = VectorSize / sizeof(UInt64);
+ private const int RetElementCount = VectorSize / sizeof(UInt64);
+
+ private static UInt64[] _data1 = new UInt64[Op1ElementCount];
+ private static UInt64[] _data2 = new UInt64[Op2ElementCount];
private static Vector128<UInt64> _clsVar1;
private static Vector128<UInt64> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<UInt64> _fld1;
private Vector128<UInt64> _fld2;
- private SimpleBinaryOpTest__DataTable<UInt64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64> _dataTable;
static SimpleBinaryOpTest__CompareEqualUInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar1), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt64>, byte>(ref _clsVar2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareEqualUInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<UInt64>, byte>(ref _fld2), ref Unsafe.As<UInt64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (ulong)(random.Next(0, int.MaxValue)); _data2[i] = (ulong)(random.Next(0, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<UInt64>(_data1, _data2, new UInt64[ElementCount], 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 SimpleBinaryOpTest__DataTable<UInt64, UInt64, UInt64>(_data1, _data2, new UInt64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse41.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<UInt64> left, Vector128<UInt64> right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- UInt64[] inArray1 = new UInt64[ElementCount];
- UInt64[] inArray2 = new UInt64[ElementCount];
- UInt64[] outArray = new UInt64[ElementCount];
+ UInt64[] inArray1 = new UInt64[Op1ElementCount];
+ UInt64[] inArray2 = new UInt64[Op2ElementCount];
+ UInt64[] outArray = new UInt64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] == right[i]) ? unchecked((ulong)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.CompareEqual)}<UInt64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse41)}.{nameof(Sse41.CompareEqual)}<UInt64>(Vector128<UInt64>, Vector128<UInt64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Sse42/CompareGreaterThan.Int64.cs b/tests/src/JIT/HardwareIntrinsics/X86/Sse42/CompareGreaterThan.Int64.cs
index e8bf19a979..763f931361 100644
--- a/tests/src/JIT/HardwareIntrinsics/X86/Sse42/CompareGreaterThan.Int64.cs
+++ b/tests/src/JIT/HardwareIntrinsics/X86/Sse42/CompareGreaterThan.Int64.cs
@@ -28,20 +28,26 @@ namespace JIT.HardwareIntrinsics.X86
// Validates basic functionality works, using Unsafe.Read
test.RunBasicScenario_UnsafeRead();
- // Validates basic functionality works, using Load
- test.RunBasicScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates basic functionality works, using Load
+ test.RunBasicScenario_Load();
- // Validates basic functionality works, using LoadAligned
- test.RunBasicScenario_LoadAligned();
+ // Validates basic functionality works, using LoadAligned
+ test.RunBasicScenario_LoadAligned();
+ }
// Validates calling via reflection works, using Unsafe.Read
test.RunReflectionScenario_UnsafeRead();
- // Validates calling via reflection works, using Load
- test.RunReflectionScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates calling via reflection works, using Load
+ test.RunReflectionScenario_Load();
- // Validates calling via reflection works, using LoadAligned
- test.RunReflectionScenario_LoadAligned();
+ // Validates calling via reflection works, using LoadAligned
+ test.RunReflectionScenario_LoadAligned();
+ }
// Validates passing a static member works
test.RunClsVarScenario();
@@ -49,11 +55,14 @@ namespace JIT.HardwareIntrinsics.X86
// Validates passing a local works, using Unsafe.Read
test.RunLclVarScenario_UnsafeRead();
- // Validates passing a local works, using Load
- test.RunLclVarScenario_Load();
+ if (Sse2.IsSupported)
+ {
+ // Validates passing a local works, using Load
+ test.RunLclVarScenario_Load();
- // Validates passing a local works, using LoadAligned
- test.RunLclVarScenario_LoadAligned();
+ // Validates passing a local works, using LoadAligned
+ test.RunLclVarScenario_LoadAligned();
+ }
// Validates passing the field of a local works
test.RunLclFldScenario();
@@ -77,10 +86,13 @@ namespace JIT.HardwareIntrinsics.X86
public sealed unsafe class SimpleBinaryOpTest__CompareGreaterThanInt64
{
private const int VectorSize = 16;
- private const int ElementCount = VectorSize / sizeof(Int64);
- private static Int64[] _data1 = new Int64[ElementCount];
- private static Int64[] _data2 = new Int64[ElementCount];
+ private const int Op1ElementCount = VectorSize / sizeof(Int64);
+ private const int Op2ElementCount = VectorSize / sizeof(Int64);
+ private const int RetElementCount = VectorSize / sizeof(Int64);
+
+ private static Int64[] _data1 = new Int64[Op1ElementCount];
+ private static Int64[] _data2 = new Int64[Op2ElementCount];
private static Vector128<Int64> _clsVar1;
private static Vector128<Int64> _clsVar2;
@@ -88,15 +100,16 @@ namespace JIT.HardwareIntrinsics.X86
private Vector128<Int64> _fld1;
private Vector128<Int64> _fld2;
- private SimpleBinaryOpTest__DataTable<Int64> _dataTable;
+ private SimpleBinaryOpTest__DataTable<Int64, Int64, Int64> _dataTable;
static SimpleBinaryOpTest__CompareGreaterThanInt64()
{
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar1), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data1[0]), VectorSize);
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int64>, byte>(ref _clsVar2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
}
public SimpleBinaryOpTest__CompareGreaterThanInt64()
@@ -105,12 +118,14 @@ namespace JIT.HardwareIntrinsics.X86
var random = new Random();
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
+ for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<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<Vector128<Int64>, byte>(ref _fld2), ref Unsafe.As<Int64, byte>(ref _data2[0]), VectorSize);
- for (var i = 0; i < ElementCount; i++) { _data1[i] = (long)(random.Next(int.MinValue, int.MaxValue)); _data2[i] = (long)(random.Next(int.MinValue, int.MaxValue)); }
- _dataTable = new SimpleBinaryOpTest__DataTable<Int64>(_data1, _data2, new Int64[ElementCount], 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 SimpleBinaryOpTest__DataTable<Int64, Int64, Int64>(_data1, _data2, new Int64[RetElementCount], VectorSize);
}
public bool IsSupported => Sse42.IsSupported;
@@ -260,9 +275,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(Vector128<Int64> left, Vector128<Int64> right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
Unsafe.Write(Unsafe.AsPointer(ref inArray1[0]), left);
Unsafe.Write(Unsafe.AsPointer(ref inArray2[0]), right);
@@ -273,9 +288,9 @@ namespace JIT.HardwareIntrinsics.X86
private void ValidateResult(void* left, void* right, void* result, [CallerMemberName] string method = "")
{
- Int64[] inArray1 = new Int64[ElementCount];
- Int64[] inArray2 = new Int64[ElementCount];
- Int64[] outArray = new Int64[ElementCount];
+ Int64[] inArray1 = new Int64[Op1ElementCount];
+ Int64[] inArray2 = new Int64[Op2ElementCount];
+ Int64[] outArray = new Int64[RetElementCount];
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);
@@ -292,7 +307,7 @@ namespace JIT.HardwareIntrinsics.X86
}
else
{
- for (var i = 1; i < left.Length; i++)
+ for (var i = 1; i < RetElementCount; i++)
{
if (result[i] != ((left[i] > right[i]) ? unchecked((long)(-1)) : 0))
{
@@ -304,7 +319,7 @@ namespace JIT.HardwareIntrinsics.X86
if (!Succeeded)
{
- Console.WriteLine($"{nameof(Sse42)}.{nameof(Sse42.CompareGreaterThan)}<Int64>: {method} failed:");
+ Console.WriteLine($"{nameof(Sse42)}.{nameof(Sse42.CompareGreaterThan)}<Int64>(Vector128<Int64>, Vector128<Int64>): {method} failed:");
Console.WriteLine($" left: ({string.Join(", ", left)})");
Console.WriteLine($" right: ({string.Join(", ", right)})");
Console.WriteLine($" result: ({string.Join(", ", result)})");