From 916e74132d7234bb828c036590090329d1083637 Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Mon, 22 Jul 2024 10:43:18 -0700 Subject: [PATCH 1/2] Resolving an antigen failure --- src/coreclr/jit/gentree.cpp | 5 ++- src/coreclr/jit/lowerxarch.cpp | 15 ++++++++ .../JitBlue/Runtime_105255/Runtime_105255.cs | 36 +++++++++++++++++++ .../Runtime_105255/Runtime_105255.csproj | 8 +++++ 4 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_105255/Runtime_105255.cs create mode 100644 src/tests/JIT/Regression/JitBlue/Runtime_105255/Runtime_105255.csproj diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index 8ba61fe3a1121c..a73fb77b6bae7d 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -30360,8 +30360,11 @@ GenTree* Compiler::gtFoldExprHWIntrinsic(GenTreeHWIntrinsic* tree) #endif // !TARGET_XARCH && !TARGET_ARM64 DEBUG_DESTROY_NODE(op, tree); - INDEBUG(vectorNode->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED); + if (fgGlobalMorph) + { + INDEBUG(vectorNode->gtDebugFlags |= GTF_DEBUG_NODE_MORPHED); + } return vectorNode; } } diff --git a/src/coreclr/jit/lowerxarch.cpp b/src/coreclr/jit/lowerxarch.cpp index 8b199a898d4419..3f441215e37123 100644 --- a/src/coreclr/jit/lowerxarch.cpp +++ b/src/coreclr/jit/lowerxarch.cpp @@ -1570,6 +1570,21 @@ GenTree* Lowering::LowerHWIntrinsic(GenTreeHWIntrinsic* node) op2->SetUnusedValue(); } + // Since we have a double negation, it's possible that gtNext + // is op1 or user. If it is op1, then it's also possible the + // subsequent gtNext is user. We need to make sure to skip both + // in such a scenario since we're removing them. + + if (nextNode == op1) + { + nextNode = nextNode->gtNext; + } + + if (nextNode == user) + { + nextNode = nextNode->gtNext; + } + BlockRange().Remove(op3); BlockRange().Remove(op1); BlockRange().Remove(user); diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_105255/Runtime_105255.cs b/src/tests/JIT/Regression/JitBlue/Runtime_105255/Runtime_105255.cs new file mode 100644 index 00000000000000..3af36e3132cebf --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_105255/Runtime_105255.cs @@ -0,0 +1,36 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Runtime.CompilerServices; +using System.Runtime.Intrinsics; +using Xunit; + +#nullable disable + +public class Runtime_105255_A +{ + private static Vector512 s_v512_uint_62 = Vector512.Zero; + + public void Method0() + { + s_v512_uint_62 = Vector512.LessThan(s_v512_uint_62, Vector512.Zero); + try + { + } + finally + { + for (int i = 0; i < 1; i++) ; + } + } + + [Fact] + public static void TestEntryPoint() => new Runtime_105255_A().Method0(); + + /* + Assert failure(PID 5828 [0x000016c4], Thread: 6044 [0x179c]): Assertion failed '((tree->gtDebugFlags & GTF_DEBUG_NODE_MORPHED) == 0) && "ERROR: Already morphed this node!"' in 'TestClass:Method0():this' during 'Morph - Global' (IL size 22846; hash 0x46e9aa75; Tier0-FullOpts) + File: D:\a\_work\1\s\src\coreclr\jit\morph.cpp:12227 + Image: C:\h\w\A715090A\p\CoreRoot\corerun.exe + + Assertion failed '((tree->gtDebugFlags & GTF_DEBUG_NODE_MORPHED) == 0) && "ERROR: Already morphed this node!"' during 'Morph - Global' + */ +} diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_105255/Runtime_105255.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_105255/Runtime_105255.csproj new file mode 100644 index 00000000000000..de6d5e08882e86 --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_105255/Runtime_105255.csproj @@ -0,0 +1,8 @@ + + + True + + + + + From 3e31d0d8fe8890208aadb523b8f098873e5df4bf Mon Sep 17 00:00:00 2001 From: Tanner Gooding Date: Mon, 22 Jul 2024 15:48:23 -0700 Subject: [PATCH 2/2] Fix method accessibility so xunit doesn't complain --- .../JIT/Regression/JitBlue/Runtime_105255/Runtime_105255.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_105255/Runtime_105255.cs b/src/tests/JIT/Regression/JitBlue/Runtime_105255/Runtime_105255.cs index 3af36e3132cebf..bee31e60b12003 100644 --- a/src/tests/JIT/Regression/JitBlue/Runtime_105255/Runtime_105255.cs +++ b/src/tests/JIT/Regression/JitBlue/Runtime_105255/Runtime_105255.cs @@ -11,7 +11,7 @@ public class Runtime_105255_A { private static Vector512 s_v512_uint_62 = Vector512.Zero; - public void Method0() + private void Method0() { s_v512_uint_62 = Vector512.LessThan(s_v512_uint_62, Vector512.Zero); try