diff options
Diffstat (limited to 'tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17435/GitHub_17435.cs')
-rw-r--r-- | tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17435/GitHub_17435.cs | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17435/GitHub_17435.cs b/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17435/GitHub_17435.cs new file mode 100644 index 0000000000..bed639c202 --- /dev/null +++ b/tests/src/JIT/HardwareIntrinsics/X86/Regression/GitHub_17435/GitHub_17435.cs @@ -0,0 +1,62 @@ +using System; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Runtime.Intrinsics.X86; +using System.Runtime.Intrinsics; + +namespace GitHub_17435 +{ + class Program + { + const int Pass = 100; + const int Fail = 0; + + static unsafe int Main(string[] args) + { + + if (Sse2.IsSupported) + { + (uint a, uint b) = Program.Repro(); + if ((a !=3) || (b != 6)) + { + Console.WriteLine($"FAILED {a}, {b}"); + return Fail; + } + else + { + Console.WriteLine("Passed"); + return Pass; + } + } + else + { + Console.WriteLine("SSE2 not supported"); + return Pass; + } + } + + [MethodImpl(MethodImplOptions.NoInlining)] + public unsafe static (uint, uint) Repro() + { + uint* a = stackalloc uint[4]; + a[0] = 1; + a[1] = 1; + a[2] = 1; + a[3] = 1; + + // Here we force populate the registers + var b = a[0]; + var h = a[3]; + var c = a[1]; + + // We operate the values in xmm0 + Vector128<uint> v = Sse2.LoadVector128(a); + v = Sse2.Add(v, v); + // We send to the memory the modified values + Sse2.Store(a, v); + + // We return both sums (from registers and from memory) + return (b + h + c, a[0]+a[1]+a[3]); + } + } +} |