From: Jan Kotas Date: Tue, 24 Sep 2019 15:19:30 +0000 (-0700) Subject: Revert "Don't allow the hoisting of GT_CLS_VARs that were assigned a constant value... X-Git-Tag: submit/tizen/20210909.063632~11030^2~535^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8e08dc3191d9c9122a3e508d79abf2b24c3bf2aa;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Revert "Don't allow the hoisting of GT_CLS_VARs that were assigned a constant value. (dotnet/coreclr#26551)" This reverts commit dotnet/coreclr@2342c8231f1b1b3c17baaefbd0357aa4f228f5d1. Commit migrated from https://github.com/dotnet/coreclr/commit/0d834661b9f47631f16a1ace56606a2d49a6615c --- diff --git a/src/coreclr/src/jit/optimizer.cpp b/src/coreclr/src/jit/optimizer.cpp index bc04da5..e801b1f 100644 --- a/src/coreclr/src/jit/optimizer.cpp +++ b/src/coreclr/src/jit/optimizer.cpp @@ -6795,21 +6795,8 @@ void Compiler::optHoistLoopBlocks(unsigned loopNum, ArrayStack* blo bool IsTreeVNInvariant(GenTree* tree) { - ValueNum vn = tree->gtVNPair.GetLiberal(); - - if (m_compiler->vnStore->IsVNConstant(vn)) - { - // It is unsafe to allow a GT_CLS_VAR that has been assigned a constant. - // The logic in optVNIsLoopInvariant would consider it to be loop-invariant, even - // if the assignment of the constant to the GT_CLS_VAR was inside the loop. - // - if (tree->OperIs(GT_CLS_VAR)) - { - return false; - } - } - - return m_compiler->optVNIsLoopInvariant(vn, m_loopNum, &m_hoistContext->m_curLoopVnInvariantCache); + return m_compiler->optVNIsLoopInvariant(tree->gtVNPair.GetLiberal(), m_loopNum, + &m_hoistContext->m_curLoopVnInvariantCache); } public: diff --git a/src/coreclr/tests/src/JIT/Regression/JitBlue/GitHub_26417/GitHub_26417.cs b/src/coreclr/tests/src/JIT/Regression/JitBlue/GitHub_26417/GitHub_26417.cs deleted file mode 100644 index 6871962..0000000 --- a/src/coreclr/tests/src/JIT/Regression/JitBlue/GitHub_26417/GitHub_26417.cs +++ /dev/null @@ -1,47 +0,0 @@ -// 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; - -class GitHub_26417 -{ - static int _a; - - [MethodImplAttribute(MethodImplOptions.NoInlining)] - static void MyWriteLine(int v) - { - Console.WriteLine(v); - if (v == 0) - { - throw new Exception(); - } - } - - [MethodImplAttribute(MethodImplOptions.NoInlining)] - static void Test() - { - _a = 1; - - while (_a == 1) - { - MyWriteLine(_a); - _a = 0; - } - } - - static int Main() - { - int result = 100; - try { - Test(); - } - catch (Exception) - { - Console.WriteLine("FAILED"); - result = -1; - } - return result; - } -} diff --git a/src/coreclr/tests/src/JIT/Regression/JitBlue/GitHub_26417/GitHub_26417.csproj b/src/coreclr/tests/src/JIT/Regression/JitBlue/GitHub_26417/GitHub_26417.csproj deleted file mode 100644 index f3e1cbd..0000000 --- a/src/coreclr/tests/src/JIT/Regression/JitBlue/GitHub_26417/GitHub_26417.csproj +++ /dev/null @@ -1,12 +0,0 @@ - - - Exe - - - None - True - - - - -