Revert "Don't allow the hoisting of GT_CLS_VARs that were assigned a constant value...
authorJan Kotas <jkotas@microsoft.com>
Tue, 24 Sep 2019 15:19:30 +0000 (08:19 -0700)
committerJan Kotas <jkotas@microsoft.com>
Tue, 24 Sep 2019 15:19:30 +0000 (08:19 -0700)
This reverts commit dotnet/coreclr@2342c8231f1b1b3c17baaefbd0357aa4f228f5d1.

Commit migrated from https://github.com/dotnet/coreclr/commit/0d834661b9f47631f16a1ace56606a2d49a6615c

src/coreclr/src/jit/optimizer.cpp
src/coreclr/tests/src/JIT/Regression/JitBlue/GitHub_26417/GitHub_26417.cs [deleted file]
src/coreclr/tests/src/JIT/Regression/JitBlue/GitHub_26417/GitHub_26417.csproj [deleted file]

index bc04da5..e801b1f 100644 (file)
@@ -6795,21 +6795,8 @@ void Compiler::optHoistLoopBlocks(unsigned loopNum, ArrayStack<BasicBlock*>* 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 (file)
index 6871962..0000000
+++ /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 (file)
index f3e1cbd..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<Project Sdk="Microsoft.NET.Sdk">
-  <PropertyGroup>
-    <OutputType>Exe</OutputType>
-  </PropertyGroup>
-  <PropertyGroup>
-    <DebugType>None</DebugType>
-    <Optimize>True</Optimize>
-  </PropertyGroup>
-  <ItemGroup>
-    <Compile Include="$(MSBuildProjectName).cs" />
-  </ItemGroup>
-</Project>