// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System; using System.Runtime.CompilerServices; using System.Numerics; public class GitHub_23885 { [MethodImpl(MethodImplOptions.NoInlining)] static void dummy(Vector v1, Vector v2, Vector v3, Vector v4, Vector v5, Vector v6, Vector v7, Vector v8) { } [MethodImpl(MethodImplOptions.NoInlining)] static void CreateVectors() { Vector vA = new Vector((ulong)0xa); Vector vB = new Vector((ulong)0xb); Vector vC = new Vector((ulong)0xc); Vector vD = new Vector((ulong)0xd); Vector vE = new Vector((ulong)0xe); Vector vF = new Vector((ulong)0xf); Vector vG = new Vector((ulong)0x8); Vector vH = new Vector((ulong)0x9); dummy(vA, vB, vC, vD, vE, vF, vG, vH); } [MethodImpl(MethodImplOptions.NoInlining)] static double GetDouble() { return 1.0; } [MethodImpl(MethodImplOptions.NoInlining)] static void ConsumeDouble(double d) { } static int Main(string[] args) { int returnVal = 100; // Define a non-SIMD floating point value so that we've got an odd number of // callee-save floating-point/vector registers remaining. double d = GetDouble(); // Declare and initialize a bunch of vectors. Vector xA = Vector.One; Vector xB = Vector.One; Vector xC = Vector.One; Vector xD = Vector.One; Vector xE = Vector.One; Vector xF = Vector.One; // Use d a few times to give it more weight than the SIMD values. ConsumeDouble((d * d) + d); d = d * GetDouble(); // Use the vectors in computation to give them some weight. xA = xB + xC + xD + xE + xF; xB = xA + xC + xD + xE + xF; xC = xA + xB + xD + xE + xF; xD = xA + xC + xC + xE + xF; xE = xA + xC + xD + xD + xF; xF = xA + xC + xD + xE + xE; ConsumeDouble((d * d) + d); d = d * GetDouble(); CreateVectors(); Console.WriteLine("{0} {1} {2} {3} {4} {5}", xA, xB, xC, xD, xE, xF); if (!xA.Equals(new Vector((ulong)5)) || !xB.Equals(new Vector((ulong)9)) || !xC.Equals(new Vector((ulong)17)) || !xD.Equals(new Vector((ulong)41)) || !xE.Equals(new Vector((ulong)105)) || !xF.Equals(new Vector((ulong)273))) { returnVal = -1; } // Now, create more vectors, so that even more will be spilled aross the next call. Vector xG = Vector.Zero; Vector xH = Vector.Zero; Vector xI = Vector.Zero; CreateVectors(); Console.WriteLine("{0} {1} {2} {3} {4} {5} {6} {7} {8}", xA, xB, xC, xD, xE, xF, xG, xH, xI); ConsumeDouble((d * d) + d); d = d * GetDouble(); if (!xA.Equals(new Vector((ulong)5)) || !xB.Equals(new Vector((ulong)9)) || !xC.Equals(new Vector((ulong)17)) || !xD.Equals(new Vector((ulong)41)) || !xE.Equals(new Vector((ulong)105)) || !xF.Equals(new Vector((ulong)273)) || !xG.Equals(Vector.Zero) || !xH.Equals(Vector.Zero) || !xI.Equals(Vector.Zero)) { returnVal = -1; } return returnVal; } }