From da50c7c0b92f47260ad95fc6995b6d58767965e8 Mon Sep 17 00:00:00 2001 From: Fei Peng Date: Wed, 25 Apr 2018 12:14:24 -0700 Subject: [PATCH] Port more Vector tests to Vector128/256 --- .../HardwareIntrinsics/X86/General/VectorArgs.cs | 114 +++++++++ .../X86/General/VectorArgs_r.csproj | 34 +++ .../X86/General/VectorArgs_ro.csproj | 34 +++ .../HardwareIntrinsics/X86/General/VectorArray.cs | 148 ++++++++++++ .../X86/General/VectorArray_r.csproj | 35 +++ .../X86/General/VectorArray_ro.csproj | 35 +++ .../X86/General/VectorHelpers.cs | 267 +++++++++++++++++++++ .../HardwareIntrinsics/X86/General/VectorRet.cs | 3 + .../HardwareIntrinsics/X86/General/VectorUnused.cs | 78 ++++++ .../X86/General/VectorUnused_r.csproj | 35 +++ .../X86/General/VectorUnused_ro.csproj | 35 +++ 11 files changed, 818 insertions(+) create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/General/VectorArgs.cs create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/General/VectorArgs_r.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/General/VectorArgs_ro.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/General/VectorArray.cs create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/General/VectorArray_r.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/General/VectorArray_ro.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/General/VectorHelpers.cs create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/General/VectorUnused.cs create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/General/VectorUnused_r.csproj create mode 100644 tests/src/JIT/HardwareIntrinsics/X86/General/VectorUnused_ro.csproj diff --git a/tests/src/JIT/HardwareIntrinsics/X86/General/VectorArgs.cs b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorArgs.cs new file mode 100644 index 0000000..84832cf --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorArgs.cs @@ -0,0 +1,114 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// + +// This test case is ported from S.N.Vector counterpart +// https://github.com/dotnet/coreclr/blob/master/tests/src/JIT/SIMD/VectorArgs.cs + +using System; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +internal partial class IntelHardwareIntrinsicTest +{ + private const int Pass = 100; + private const int Fail = -1; + + internal class VectorArg128 + { + private Vector128 _rgb; + + public VectorArg128(float r, float g, float b) + { + float[] temp = new float[4]; + temp[0] = r; temp[1] = g; temp[2] = b; + unsafe + { + fixed (float* ptr = temp) + { + _rgb = Sse.LoadVector128(ptr); + } + } + } + + public VectorArg128(Vector128 _rgb) + { this._rgb = _rgb; } + + public VectorArg128 Change(float f) + { + Vector128 t = Sse.SetAllVector128(f); + return new VectorArg128(Sse.Add(t, _rgb)); + } + + public Vector128 RGB { get { return _rgb; } } + } + + internal class VectorArg256 + { + private Vector256 _rgb; + + public VectorArg256(float r, float g, float b) + { + float[] temp = new float[8]; + temp[0] = r; temp[1] = g; temp[2] = b; + unsafe + { + fixed (float* ptr = temp) + { + _rgb = Avx.LoadVector256(ptr); + } + } + } + + public VectorArg256(Vector256 _rgb) + { this._rgb = _rgb; } + + public VectorArg256 Change(float f) + { + Vector256 t = Avx.SetAllVector256(f); + return new VectorArg256(Avx.Add(t, _rgb)); + } + + public Vector256 RGB { get { return _rgb; } } + } + + unsafe static int Main() + { + int returnVal = Pass; + + if (Sse41.IsSupported) + { + Vector128 rgb = Sse.SetVector128(0, 1, 2, 3); + float x = 2f; + VectorArg128 c1 = new VectorArg128(rgb); + VectorArg128 c2 = c1.Change(x); + for (int i = 0; i < 4; i++) + { + if (((int)Sse41.Extract(c2.RGB, (byte)i)) != (3 - i) + x) + { + returnVal = Fail; + } + } + } + + if (Avx.IsSupported) + { + Vector256 rgb = Avx.SetVector256(0f, 1f, 2f, 3f, 4f, 5f, 6f, 7f); + float x = 2f; + VectorArg256 c1 = new VectorArg256(rgb); + VectorArg256 c2 = c1.Change(x); + float* buffer = stackalloc float[8]; + Avx.Store(buffer, c2.RGB); + for (int i = 0; i < 8; i++) + { + if (((int)buffer[i]) != (7 - i) + x) + { + returnVal = Fail; + } + } + } + + return returnVal; + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/General/VectorArgs_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorArgs_r.csproj new file mode 100644 index 0000000..3002207 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorArgs_r.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/General/VectorArgs_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorArgs_ro.csproj new file mode 100644 index 0000000..30461f1 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorArgs_ro.csproj @@ -0,0 +1,34 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + True + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/General/VectorArray.cs b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorArray.cs new file mode 100644 index 0000000..12bc7c1 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorArray.cs @@ -0,0 +1,148 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// + +// This test case is ported from S.N.Vector counterpart +// https://github.com/dotnet/coreclr/blob/master/tests/src/JIT/SIMD/VectorArray.cs + +using System; +using System.Numerics; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; +using System.Runtime.CompilerServices; + +internal partial class IntelHardwareIntrinsicTest +{ + private const int Pass = 100; + private const int Fail = -1; + + private class Vector128ArrayTest where T : struct, IComparable, IEquatable + { + private static void Move(Vector128[] pos, ref Vector128 delta) + { + for (int i = 0; i < pos.Length; ++i) + { + pos[i] = Vector128Add(pos[i], delta); + } + } + + static public unsafe int Vector128Array() + { + Vector128[] v = new Vector128[3]; + int elementSize = Unsafe.SizeOf(); + const int vectorSize = 16; + int elementCount = vectorSize / elementSize; + + for (int i = 0; i < v.Length; ++i) + v[i] = SetAllVector128(GetValueFromInt(i + 1)); + + Vector128 delta = SetAllVector128(GetValueFromInt(1)); + Move(v, ref delta); + + byte* buffer = stackalloc byte[vectorSize * v.Length]; + for (int i = 0; i < v.Length; ++i) + Unsafe.Write>(buffer + i * vectorSize, v[i]); + + for (int i = 0; i < v.Length; i++) + { + T checkValue = GetValueFromInt(i + 2); + for (int j = 0; j < elementCount; j++) + { + if (!CheckValue(Unsafe.Read(&buffer[i * vectorSize + j * elementSize]), checkValue)) return Fail; + } + } + + return Pass; + } + } + + private class Vector256ArrayTest where T : struct, IComparable, IEquatable + { + private static void Move(Vector256[] pos, ref Vector256 delta) + { + for (int i = 0; i < pos.Length; ++i) + { + pos[i] = Vector256Add(pos[i], delta); + } + } + + static public unsafe int Vector256Array() + { + Vector256[] v = new Vector256[3]; + int elementSize = Unsafe.SizeOf(); + const int vectorSize = 32; + int elementCount = vectorSize / elementSize; + + for (int i = 0; i < v.Length; ++i) + v[i] = Avx.SetAllVector256((T)Convert.ChangeType(i + 1, typeof(T))); + + Vector256 delta = Avx.SetAllVector256((T)Convert.ChangeType(1, typeof(T))); + Move(v, ref delta); + + byte* buffer = stackalloc byte[vectorSize * v.Length]; + for (int i = 0; i < v.Length; ++i) + Unsafe.Write>(buffer + i * vectorSize, v[i]); + + for (int i = 0; i < v.Length; i++) + { + T checkValue = GetValueFromInt(i + 2); + for (int j = 0; j < elementCount; j++) + { + if (!CheckValue(Unsafe.Read(&buffer[i * vectorSize + j * elementSize]), checkValue)) return Fail; + } + } + + return Pass; + } + } + + unsafe static int Main() + { + int returnVal = Pass; + try + { + if (Sse2.IsSupported) + { + if (Vector128ArrayTest.Vector128Array() != Pass) returnVal = Fail; + if (Vector128ArrayTest.Vector128Array() != Pass) returnVal = Fail; + if (Vector128ArrayTest.Vector128Array() != Pass) returnVal = Fail; + if (Vector128ArrayTest.Vector128Array() != Pass) returnVal = Fail; + if (Vector128ArrayTest.Vector128Array() != Pass) returnVal = Fail; + if (Vector128ArrayTest.Vector128Array() != Pass) returnVal = Fail; + if (Vector128ArrayTest.Vector128Array() != Pass) returnVal = Fail; + if (Vector128ArrayTest.Vector128Array() != Pass) returnVal = Fail; + if (Environment.Is64BitProcess) + { + if (Vector128ArrayTest.Vector128Array() != Pass) returnVal = Fail; + if (Vector128ArrayTest.Vector128Array() != Pass) returnVal = Fail; + } + } + + if (Avx2.IsSupported) + { + if (Vector256ArrayTest.Vector256Array() != Pass) returnVal = Fail; + if (Vector256ArrayTest.Vector256Array() != Pass) returnVal = Fail; + if (Vector256ArrayTest.Vector256Array() != Pass) returnVal = Fail; + if (Vector256ArrayTest.Vector256Array() != Pass) returnVal = Fail; + if (Vector256ArrayTest.Vector256Array() != Pass) returnVal = Fail; + if (Vector256ArrayTest.Vector256Array() != Pass) returnVal = Fail; + if (Vector256ArrayTest.Vector256Array() != Pass) returnVal = Fail; + if (Vector256ArrayTest.Vector256Array() != Pass) returnVal = Fail; + if (Environment.Is64BitProcess) + { + if (Vector256ArrayTest.Vector256Array() != Pass) returnVal = Fail; + if (Vector256ArrayTest.Vector256Array() != Pass) returnVal = Fail; + } + } + } + catch (NotSupportedException ex) + { + Console.WriteLine("NotSupportedException was raised"); + Console.WriteLine(ex.StackTrace); + return Fail; + } + + return returnVal; + } +} diff --git a/tests/src/JIT/HardwareIntrinsics/X86/General/VectorArray_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorArray_r.csproj new file mode 100644 index 0000000..d4ff2bb --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorArray_r.csproj @@ -0,0 +1,35 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/General/VectorArray_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorArray_ro.csproj new file mode 100644 index 0000000..6ebdc84 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorArray_ro.csproj @@ -0,0 +1,35 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + True + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/General/VectorHelpers.cs b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorHelpers.cs new file mode 100644 index 0000000..d06fcf9 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorHelpers.cs @@ -0,0 +1,267 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// + +using System; +using System.Numerics; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; +using System.Runtime.CompilerServices; + +internal partial class IntelHardwareIntrinsicTest +{ + public static Vector128 Vector128Add(Vector128 left, Vector128 right) where T : struct + { + if (typeof(T) == typeof(byte)) + { + return Sse.StaticCast(Sse2.Add(Sse.StaticCast(left), Sse.StaticCast(right))); + } + else if (typeof(T) == typeof(sbyte)) + { + return Sse.StaticCast(Sse2.Add(Sse.StaticCast(left), Sse.StaticCast(right))); + } + else if (typeof(T) == typeof(short)) + { + return Sse.StaticCast(Sse2.Add(Sse.StaticCast(left), Sse.StaticCast(right))); + } + else if (typeof(T) == typeof(ushort)) + { + return Sse.StaticCast(Sse2.Add(Sse.StaticCast(left), Sse.StaticCast(right))); + } + else if (typeof(T) == typeof(int)) + { + return Sse.StaticCast(Sse2.Add(Sse.StaticCast(left), Sse.StaticCast(right))); + } + else if (typeof(T) == typeof(uint)) + { + return Sse.StaticCast(Sse2.Add(Sse.StaticCast(left), Sse.StaticCast(right))); + } + else if (typeof(T) == typeof(long)) + { + return Sse.StaticCast(Sse2.Add(Sse.StaticCast(left), Sse.StaticCast(right))); + } + else if (typeof(T) == typeof(ulong)) + { + return Sse.StaticCast(Sse2.Add(Sse.StaticCast(left), Sse.StaticCast(right))); + } + else if (typeof(T) == typeof(float)) + { + return Sse.StaticCast(Sse.Add(Sse.StaticCast(left), Sse.StaticCast(right))); + } + else if (typeof(T) == typeof(double)) + { + return Sse.StaticCast(Sse2.Add(Sse.StaticCast(left), Sse.StaticCast(right))); + } + else + { + throw new NotSupportedException(); + } + } + + public static Vector256 Vector256Add(Vector256 left, Vector256 right) where T : struct + { + if (typeof(T) == typeof(byte)) + { + return Avx.StaticCast(Avx2.Add(Avx.StaticCast(left), Avx.StaticCast(right))); + } + else if (typeof(T) == typeof(sbyte)) + { + return Avx.StaticCast(Avx2.Add(Avx.StaticCast(left), Avx.StaticCast(right))); + } + else if (typeof(T) == typeof(short)) + { + return Avx.StaticCast(Avx2.Add(Avx.StaticCast(left), Avx.StaticCast(right))); + } + else if (typeof(T) == typeof(ushort)) + { + return Avx.StaticCast(Avx2.Add(Avx.StaticCast(left), Avx.StaticCast(right))); + } + else if (typeof(T) == typeof(int)) + { + return Avx.StaticCast(Avx2.Add(Avx.StaticCast(left), Avx.StaticCast(right))); + } + else if (typeof(T) == typeof(uint)) + { + return Avx.StaticCast(Avx2.Add(Avx.StaticCast(left), Avx.StaticCast(right))); + } + else if (typeof(T) == typeof(long)) + { + return Avx.StaticCast(Avx2.Add(Avx.StaticCast(left), Avx.StaticCast(right))); + } + else if (typeof(T) == typeof(ulong)) + { + return Avx.StaticCast(Avx2.Add(Avx.StaticCast(left), Avx.StaticCast(right))); + } + else if (typeof(T) == typeof(float)) + { + return Avx.StaticCast(Avx.Add(Avx.StaticCast(left), Avx.StaticCast(right))); + } + else if (typeof(T) == typeof(double)) + { + return Avx.StaticCast(Avx.Add(Avx.StaticCast(left), Avx.StaticCast(right))); + } + else + { + throw new NotSupportedException(); + } + } + + public static Vector128 SetAllVector128(T value) where T : struct + { + if (typeof(T) == typeof(byte)) + { + return Sse.StaticCast(Sse2.SetAllVector128(Convert.ToByte(value))); + } + else if (typeof(T) == typeof(sbyte)) + { + return Sse.StaticCast(Sse2.SetAllVector128(Convert.ToSByte(value))); + } + else if (typeof(T) == typeof(short)) + { + return Sse.StaticCast(Sse2.SetAllVector128(Convert.ToInt16(value))); + } + else if (typeof(T) == typeof(ushort)) + { + return Sse.StaticCast(Sse2.SetAllVector128(Convert.ToUInt16(value))); + } + else if (typeof(T) == typeof(int)) + { + return Sse.StaticCast(Sse2.SetAllVector128(Convert.ToInt32(value))); + } + else if (typeof(T) == typeof(uint)) + { + return Sse.StaticCast(Sse2.SetAllVector128(Convert.ToUInt32(value))); + } + else if (typeof(T) == typeof(long)) + { + return Sse.StaticCast(Sse2.SetAllVector128(Convert.ToInt64(value))); + } + else if (typeof(T) == typeof(ulong)) + { + return Sse.StaticCast(Sse2.SetAllVector128(Convert.ToUInt64(value))); + } + else if (typeof(T) == typeof(float)) + { + return Sse.StaticCast(Sse.SetAllVector128(Convert.ToSingle(value))); + } + else if (typeof(T) == typeof(double)) + { + return Sse.StaticCast(Sse2.SetAllVector128(Convert.ToDouble(value))); + } + else + { + throw new NotSupportedException(); + } + } + + // These two helper functions are a workaround for the bug of Sse2.SetZeroVector128 + // https://github.com/dotnet/coreclr/pull/17691 + public static Vector128 SetZeroVector128() where T : struct + { + if (typeof(T) == typeof(float)) + { + return Sse.StaticCast(Sse.SetZeroVector128()); + } + else + { + return Sse2SetZeroVector128(); + } + } + + [MethodImpl(MethodImplOptions.NoInlining)] + private static Vector128 Sse2SetZeroVector128() where T : struct + { + if (typeof(T) == typeof(double) || typeof(T) == typeof(byte) || typeof(T) == typeof(sbyte) || typeof(T) == typeof(short) || + typeof(T) == typeof(ushort) || typeof(T) == typeof(int) || typeof(T) == typeof(uint) || typeof(T) == typeof(long) || typeof(T) == typeof(ulong)) + { + return Sse2.SetZeroVector128(); + } + else + { + throw new NotSupportedException(); + } + } + + public static bool CheckValue(T value, T expectedValue) where T : struct + { + bool returnVal; + if (typeof(T) == typeof(float)) + { + returnVal = Math.Abs(((float)(object)value) - ((float)(object)expectedValue)) <= Single.Epsilon; + } + if (typeof(T) == typeof(double)) + { + returnVal = Math.Abs(((double)(object)value) - ((double)(object)expectedValue)) <= Double.Epsilon; + } + else + { + returnVal = value.Equals(expectedValue); + } + if (returnVal == false) + { + if ((typeof(T) == typeof(double)) || (typeof(T) == typeof(float))) + { + Console.WriteLine("CheckValue failed for type " + typeof(T).ToString() + ". Expected: {0} , Got: {1}", expectedValue, value); + } + else + { + Console.WriteLine("CheckValue failed for type " + typeof(T).ToString() + ". Expected: {0} (0x{0:X}), Got: {1} (0x{1:X})", expectedValue, value); + } + } + return returnVal; + } + + public static T GetValueFromInt(int value) where T : struct + { + if (typeof(T) == typeof(float)) + { + float floatValue = (float)value; + return (T)(object)floatValue; + } + if (typeof(T) == typeof(double)) + { + double doubleValue = (double)value; + return (T)(object)doubleValue; + } + if (typeof(T) == typeof(int)) + { + return (T)(object)value; + } + if (typeof(T) == typeof(uint)) + { + uint uintValue = (uint)value; + return (T)(object)uintValue; + } + if (typeof(T) == typeof(long)) + { + long longValue = (long)value; + return (T)(object)longValue; + } + if (typeof(T) == typeof(ulong)) + { + ulong longValue = (ulong)value; + return (T)(object)longValue; + } + if (typeof(T) == typeof(ushort)) + { + return (T)(object)(ushort)value; + } + if (typeof(T) == typeof(byte)) + { + return (T)(object)(byte)value; + } + if (typeof(T) == typeof(short)) + { + return (T)(object)(short)value; + } + if (typeof(T) == typeof(sbyte)) + { + return (T)(object)(sbyte)value; + } + else + { + throw new ArgumentException(); + } + } +} \ No newline at end of file diff --git a/tests/src/JIT/HardwareIntrinsics/X86/General/VectorRet.cs b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorRet.cs index 479b529..bf3d0e4 100644 --- a/tests/src/JIT/HardwareIntrinsics/X86/General/VectorRet.cs +++ b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorRet.cs @@ -3,6 +3,9 @@ // See the LICENSE file in the project root for more information. // +// This test case is ported from S.N.Vector counterpart +// https://github.com/dotnet/coreclr/blob/master/tests/src/JIT/SIMD/VectorReturn.cs + using System; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; diff --git a/tests/src/JIT/HardwareIntrinsics/X86/General/VectorUnused.cs b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorUnused.cs new file mode 100644 index 0000000..331a176 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorUnused.cs @@ -0,0 +1,78 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. +// + +// This test case is ported from S.N.Vector counterpart +// https://github.com/dotnet/coreclr/blob/master/tests/src/JIT/SIMD/VectorUnused.cs + +using System; +using System.Runtime.Intrinsics; +using System.Runtime.Intrinsics.X86; + +internal partial class IntelHardwareIntrinsicTest +{ + private const int Pass = 100; + private const int Fail = -1; + + private class Vector128UnusedTest where T : struct, IComparable, IEquatable + { + public static int VectorUnused(T t1, T t2) + { + if (Sse2.IsSupported) + { + Vector128 v1 = SetAllVector128(t1); + v1 = Vector128Add(v1, SetZeroVector128()); + } + + return Pass; + } + } + + private class Vector256UnusedTest where T : struct, IComparable, IEquatable + { + public static int VectorUnused(T t1, T t2) + { + if (Avx.IsSupported) + { + Vector256 v1 = Avx.SetAllVector256(t1); + v1 = Avx.Permute2x128(v1, Avx.SetAllVector256(t2), 1); + } + return Pass; + } + } + + private static int Main() + { + int returnVal = Pass; + + if (Vector128UnusedTest.VectorUnused(3f, 2f) != Pass) returnVal = Fail; + if (Vector128UnusedTest.VectorUnused(3, 2) != Pass) returnVal = Fail; + if (Vector128UnusedTest.VectorUnused(3, 2) != Pass) returnVal = Fail; + if (Vector128UnusedTest.VectorUnused(3, 2) != Pass) returnVal = Fail; + if (Vector128UnusedTest.VectorUnused(3, 2) != Pass) returnVal = Fail; + if (Vector128UnusedTest.VectorUnused(3, 2) != Pass) returnVal = Fail; + if (Vector128UnusedTest.VectorUnused(3, 2) != Pass) returnVal = Fail; + if (Vector128UnusedTest.VectorUnused(3, 2) != Pass) returnVal = Fail; + if (Environment.Is64BitProcess) + { + if (Vector128UnusedTest.VectorUnused(3, 2) != Pass) returnVal = Fail; + if (Vector128UnusedTest.VectorUnused(3, 2) != Pass) returnVal = Fail; + } + + if (Vector256UnusedTest.VectorUnused(3f, 2f) != Pass) returnVal = Fail; + if (Vector256UnusedTest.VectorUnused(3, 2) != Pass) returnVal = Fail; + if (Vector256UnusedTest.VectorUnused(3, 2) != Pass) returnVal = Fail; + if (Vector256UnusedTest.VectorUnused(3, 2) != Pass) returnVal = Fail; + if (Vector256UnusedTest.VectorUnused(3, 2) != Pass) returnVal = Fail; + if (Vector256UnusedTest.VectorUnused(3, 2) != Pass) returnVal = Fail; + if (Vector256UnusedTest.VectorUnused(3, 2) != Pass) returnVal = Fail; + if (Vector256UnusedTest.VectorUnused(3, 2) != Pass) returnVal = Fail; + if (Environment.Is64BitProcess) + { + if (Vector256UnusedTest.VectorUnused(3, 2) != Pass) returnVal = Fail; + if (Vector256UnusedTest.VectorUnused(3, 2) != Pass) returnVal = Fail; + } + return returnVal; + } +} \ No newline at end of file diff --git a/tests/src/JIT/HardwareIntrinsics/X86/General/VectorUnused_r.csproj b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorUnused_r.csproj new file mode 100644 index 0000000..c752906 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorUnused_r.csproj @@ -0,0 +1,35 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + + + + + + + + + + + + diff --git a/tests/src/JIT/HardwareIntrinsics/X86/General/VectorUnused_ro.csproj b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorUnused_ro.csproj new file mode 100644 index 0000000..a3de422 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/General/VectorUnused_ro.csproj @@ -0,0 +1,35 @@ + + + + + Debug + AnyCPU + 2.0 + {95DFC527-4DC1-495E-97D7-E94EE1F7140D} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + true + + + + + + + False + + + + None + True + + + + + + + + + + + -- 2.7.4