[RyuJit][x86] Set unused flag when replace an unused parent with a child. (#15157)
authorSergey Andreenko <seandree@microsoft.com>
Wed, 22 Nov 2017 07:46:50 +0000 (23:46 -0800)
committerGitHub <noreply@github.com>
Wed, 22 Nov 2017 07:46:50 +0000 (23:46 -0800)
* add the repro

* fix the issue

* Move the test to pri1

src/jit/decomposelongs.cpp
tests/src/JIT/Regression/JitBlue/DevDiv_524309/DevDiv_524309.il [new file with mode: 0644]
tests/src/JIT/Regression/JitBlue/DevDiv_524309/DevDiv_524309.ilproj [new file with mode: 0644]

index 6de7ef6..cf2a418 100644 (file)
@@ -1080,6 +1080,10 @@ GenTree* DecomposeLongs::DecomposeShift(LIR::Use& use)
         {
             GenTree* next = shift->gtNext;
             // Remove shift and don't do anything else.
+            if (shift->IsUnusedValue())
+            {
+                gtLong->SetUnusedValue();
+            }
             Range().Remove(shift);
             use.ReplaceWith(m_compiler, gtLong);
             return next;
diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_524309/DevDiv_524309.il b/tests/src/JIT/Regression/JitBlue/DevDiv_524309/DevDiv_524309.il
new file mode 100644 (file)
index 0000000..22159e2
--- /dev/null
@@ -0,0 +1,96 @@
+// 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.
+
+.assembly extern System.Runtime {auto}
+.assembly DevDiv_524309 {}
+
+// The test showed problem with x86 long decomposition of unused values,  
+// DecomposeShift did not set unused on the removed shift's children. 
+
+.class private auto ansi beforefieldinit DevDiv_524309.ILGEN_CLASS
+       extends [System.Runtime]System.Object
+{
+  .method private static bool  ILGEN_METHOD(uint64 a, int16 b) cil managed
+  {
+       .maxstack  88
+       .locals init (char, native unsigned int, float64, int16, native unsigned int, unsigned int8)
+       IL0000: ldarg.s 0x00
+       IL0002: brtrue 
+       IL000f
+       IL0007: ldarg 0x0000
+       IL000b: starg 0x0000
+       IL000f: ldarg 0x0000
+       IL0013: ldarg 0x0000
+       IL0017: conv.ovf.i8.un
+       IL0018: conv.ovf.u8
+       IL0019: ldc.i8 0x2b09aaa61c8c032b // will be converted to comma(throw, 0).
+       IL0022: conv.ovf.i1 // this cast must throw.
+       IL0023: ldarg.s 0x00
+       IL0025: conv.i4
+       IL0026: shr.un // <- the result is unused, because it is proven to throw before.
+       IL0027: shr.un
+       IL0028: nop
+       IL0029: bgt 
+       IL0040
+       IL002e: ldarg.s 0x00
+       IL0030: ldarg 0x0000
+       IL0034: xor
+       IL0035: ldloc 0x0000
+       IL0039: shl
+       IL003a: ldloc.s 0x02
+       IL003c: conv.ovf.i8.un
+       IL003d: rem.un
+       IL003e: pop
+       IL003f: nop
+       IL0040: ldarg.s 0x00
+       IL0042: conv.u4
+       IL0043: ldarg 0x0001
+       IL0047: ldloc.s 0x02
+       IL0049: ldloc 0x0002
+       IL004d: clt
+       IL004f: ldarg 0x0001
+       IL0053: clt.un
+       IL0055: shr
+       IL0056: rem.un
+       IL0057: ret
+  } // end of method ILGEN_CLASS::ILGEN_METHOD
+
+  .method private static int32 Main(string[] args) cil managed
+  {
+    .entrypoint
+    // Code size       39 (0x27)
+    .maxstack  2
+    .locals init (class [System.Runtime]System.Exception V_0,
+             int32 V_1)
+    IL_0000:  nop
+    .try
+    {
+      IL_0001:  nop
+      IL_0002:  ldc.i4.s   100
+      IL_0004:  conv.i8
+      IL_0005:  ldc.i4.s   10
+      IL_0007:  call       bool DevDiv_524309.ILGEN_CLASS::ILGEN_METHOD(uint64,
+                                                                        int16)
+      IL_000c:  pop
+      IL_000d:  nop
+      IL_000e:  leave.s    IL_0020
+
+    }  // end .try
+    catch [System.Runtime]System.Exception 
+    {
+      IL_0010:  stloc.0
+      IL_0011:  nop
+      IL_0012:  nop
+      IL_0013:  leave.s    IL_0020
+
+    }  // end handler
+    IL_0020:  ldc.i4.s   100
+    IL_0022:  stloc.1
+    IL_0023:  br.s       IL_0025
+
+    IL_0025:  ldloc.1
+    IL_0026:  ret
+  } // end of method ILGEN_CLASS::Main
+
+} // end of class DevDiv_524309.ILGEN_CLASS
diff --git a/tests/src/JIT/Regression/JitBlue/DevDiv_524309/DevDiv_524309.ilproj b/tests/src/JIT/Regression/JitBlue/DevDiv_524309/DevDiv_524309.ilproj
new file mode 100644 (file)
index 0000000..cf78edf
--- /dev/null
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <AssemblyName>$(MSBuildProjectName)</AssemblyName>
+    <SchemaVersion>2.0</SchemaVersion>
+    <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+    <OutputType>Exe</OutputType>
+    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+    <CLRTestPriority>1</CLRTestPriority>
+  </PropertyGroup>
+  <!-- Default configurations to help VS understand the configurations -->
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "></PropertyGroup>
+  <ItemGroup>
+    <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies">
+      <Visible>False</Visible>
+    </CodeAnalysisDependentAssemblyPaths>
+  </ItemGroup>
+  <PropertyGroup>
+    <DebugType>None</DebugType>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="DevDiv_524309.il" />
+  </ItemGroup>
+  <ItemGroup>
+    <Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
+  </ItemGroup>
+  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+  <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project>