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:
+++ /dev/null
-// 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;
- }
-}
+++ /dev/null
-<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>