From ba3b4025a6974e5266181760003cf7552f8ae199 Mon Sep 17 00:00:00 2001 From: Carol Eidt Date: Tue, 18 Dec 2018 15:13:07 -0800 Subject: [PATCH] Transform SIMD8 to FIELD_LIST if promoted Fix #21546 --- src/jit/morph.cpp | 2 +- .../JitBlue/GitHub_21546/GitHub_21546.cs | 78 ++++++++++++++++++++++ .../JitBlue/GitHub_21546/GitHub_21546.csproj | 33 +++++++++ 3 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 tests/src/JIT/Regression/JitBlue/GitHub_21546/GitHub_21546.cs create mode 100644 tests/src/JIT/Regression/JitBlue/GitHub_21546/GitHub_21546.csproj diff --git a/src/jit/morph.cpp b/src/jit/morph.cpp index 0a6a6fc..ebe4105 100644 --- a/src/jit/morph.cpp +++ b/src/jit/morph.cpp @@ -4174,7 +4174,7 @@ GenTreeCall* Compiler::fgMorphArgs(GenTreeCall* call) #if defined(_TARGET_X86_) if (isStructArg) { - GenTree* lclNode = fgIsIndirOfAddrOfLocal(argx); + GenTree* lclNode = argx->OperIs(GT_LCL_VAR) ? argx : fgIsIndirOfAddrOfLocal(argx); if ((lclNode != nullptr) && (lvaGetPromotionType(lclNode->AsLclVarCommon()->gtLclNum) == Compiler::PROMOTION_TYPE_INDEPENDENT)) { diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_21546/GitHub_21546.cs b/tests/src/JIT/Regression/JitBlue/GitHub_21546/GitHub_21546.cs new file mode 100644 index 0000000..1d94212 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_21546/GitHub_21546.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. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; + +using Point = System.Numerics.Vector2; + +namespace GitHub_21546 +{ + public class test + { + static Point checkA; + static Point checkB; + static Point checkC; + static int returnVal; + + [MethodImpl(MethodImplOptions.NoInlining)] + static void check(Point a, Point b, Point c) + { + if (a != checkA) + { + Console.WriteLine($"A doesn't match. Should be {checkA} but is {a}"); + returnVal = -1; + } + if (b != checkB) + { + Console.WriteLine($"B doesn't match. Should be {checkB} but is {b}"); + returnVal = -1; + } + if (c != checkC) + { + Console.WriteLine($"C doesn't match. Should be {checkC} but is {c}"); + returnVal = -1; + } + } + + [MethodImpl(MethodImplOptions.NoInlining)] + static void FailureCase(List p) + { + Point p1 = p[0]; + Point p2 = p.Last(); + + check(p1, p[1], p2); + check(p1, p[1], p2); + check(p1, p[1], p2); + } + + static Point NextPoint(Random random) + { + return new Point( + (float)random.NextDouble(), + (float)random.NextDouble() + ); + } + + static int Main() + { + returnVal = 100; + Random random = new Random(13); + List p = new List(); + + checkA = NextPoint(random); + p.Add(checkA); + checkB = NextPoint(random); + p.Add(checkB); + checkC = NextPoint(random); + p.Add(checkC); + + FailureCase(p); + + return returnVal; + } + } +} diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_21546/GitHub_21546.csproj b/tests/src/JIT/Regression/JitBlue/GitHub_21546/GitHub_21546.csproj new file mode 100644 index 0000000..42f8a01 --- /dev/null +++ b/tests/src/JIT/Regression/JitBlue/GitHub_21546/GitHub_21546.csproj @@ -0,0 +1,33 @@ + + + + + Debug + AnyCPU + 2.0 + {2649FAFE-07BF-4F93-8120-BA9A69285ABB} + Exe + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ..\..\ + + + + + + None + True + + + + False + + + + + + + + + + + \ No newline at end of file -- 2.7.4