summaryrefslogtreecommitdiff
path: root/tests/src/JIT/Regression
diff options
context:
space:
mode:
authorMike Danes <onemihaid@hotmail.com>2018-01-27 22:09:52 +0200
committerMike Danes <onemihaid@hotmail.com>2018-02-12 22:32:48 +0200
commit0880a64ed1f932f65e21618661baab3ce9c60162 (patch)
tree9aa555288a24bb98ab929a36675bffc0a49baae7 /tests/src/JIT/Regression
parent1e9f9ab12d58d2cd465891be7524d3b132704d64 (diff)
downloadcoreclr-0880a64ed1f932f65e21618661baab3ce9c60162.tar.gz
coreclr-0880a64ed1f932f65e21618661baab3ce9c60162.tar.bz2
coreclr-0880a64ed1f932f65e21618661baab3ce9c60162.zip
Fix inconsistent handling of zero extending casts
For casts that are supposed to zero extend the GTF_UNSIGNED must always be set (and obeyed). Some code failed to set the flag (e.g. when importing add.ovf.un instructions having native int and int32 operands) and some other code failed to check the flag (e.g. x64 codegen, gtFoldExprConst) and instead decided to zero extend based on the cast destination type. This resulted in discrepancies between ARM64 and x64 codegen and between constant folding performed by gtFoldExprConst and VN's EvalCastForConstantArgs.
Diffstat (limited to 'tests/src/JIT/Regression')
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_13501/GitHub_13501.il97
-rw-r--r--tests/src/JIT/Regression/JitBlue/GitHub_13501/GitHub_13501.ilproj24
2 files changed, 121 insertions, 0 deletions
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_13501/GitHub_13501.il b/tests/src/JIT/Regression/JitBlue/GitHub_13501/GitHub_13501.il
new file mode 100644
index 0000000000..7d36305ed9
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_13501/GitHub_13501.il
@@ -0,0 +1,97 @@
+// 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 mscorlib { auto }
+.assembly GitHub_13501 { }
+
+.class private Program extends [mscorlib]System.Object
+{
+ .method hidebysig static int32 Main() cil managed
+ {
+ .entrypoint
+ .maxstack 8
+
+ T1: // Test that add.ovf.un(native int(0), int32(-1)) produces native int(0xFFFFFFFF),
+ // -1 is supposed to be treated as unsigned by add.ovf.un.
+ // Test_Cast_gtFoldExprConst is supposed to result in the compile time evaluation
+ // of the cast in gtFoldExprConst.
+
+ ldc.i4 0
+ conv.i
+ ldc.i4 0
+ call native int Program::Test_Cast_gtFoldExprConst(native int, bool)
+ ldc.i4 -1
+ conv.u
+ bne.un FAIL
+
+ T2: // Same test as above but using Test_Cast_EvalCastForConstantArgs. In this case
+ // -1 is the result of a more complex expression that can be evaluated at compile
+ // time by value numbering in EvalCastForConstantArgs.
+
+ ldc.i4 0
+ conv.i
+ ldc.i4 0
+ call native int Program::Test_Cast_EvalCastForConstantArgs(native int, bool)
+ ldc.i4 -1
+ conv.u
+ bne.un FAIL
+
+ T3: // Same test as above but using Test_Cast_Codegen. In this case -1 is passed
+ // as a parameter so the cast cannot be evaluated at compile time and actual
+ // cast code needs to be generated.
+
+ ldc.i4 0
+ conv.i
+ ldc.i4 -1
+ call native int Program::Test_Cast_Codegen(native int, int32)
+ ldc.i4 -1
+ conv.u
+ bne.un FAIL
+
+ PASS:
+ ldstr "PASS"
+ call void [System.Console]System.Console::WriteLine(string)
+ ldc.i4 100
+ ret
+ FAIL:
+ ldstr "FAIL"
+ call void [System.Console]System.Console::WriteLine(string)
+ ldc.i4 1
+ ret
+ }
+
+ .method static native int Test_Cast_gtFoldExprConst(native int, bool) cil managed noinlining
+ {
+ .maxstack 4
+
+ ldc.i4 -1
+ ldarg.0
+ add.ovf.un
+ ret
+ }
+
+ .method static native int Test_Cast_EvalCastForConstantArgs(native int, bool) cil managed noinlining
+ {
+ .maxstack 4
+
+ ldarg.1
+ brtrue L1
+ ldc.i4 -1
+ br L2
+ L1: ldc.i4 -1
+ L2: ldarg.0
+ add.ovf.un
+ ret
+ }
+
+ .method static native int Test_Cast_Codegen(native int, int32) cil managed noinlining
+ {
+ .maxstack 4
+
+ ldarg.1
+ ldarg.0
+ add.ovf.un
+ ret
+ }
+}
diff --git a/tests/src/JIT/Regression/JitBlue/GitHub_13501/GitHub_13501.ilproj b/tests/src/JIT/Regression/JitBlue/GitHub_13501/GitHub_13501.ilproj
new file mode 100644
index 0000000000..918ae0ab40
--- /dev/null
+++ b/tests/src/JIT/Regression/JitBlue/GitHub_13501/GitHub_13501.ilproj
@@ -0,0 +1,24 @@
+<?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>
+ <ProjectGuid>{95DFC527-4DC1-495E-97D7-E94EE1F7140D}</ProjectGuid>
+ <OutputType>Exe</OutputType>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
+ <CLRTestPriority>1</CLRTestPriority>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "></PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "></PropertyGroup>
+ <PropertyGroup>
+ <DebugType>None</DebugType>
+ <Optimize>True</Optimize>
+ </PropertyGroup>
+ <ItemGroup>
+ <Compile Include="GitHub_13501.il" />
+ </ItemGroup>
+ <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
+ <PropertyGroup Condition=" '$(MsBuildProjectDirOverride)' != '' "></PropertyGroup>
+</Project> \ No newline at end of file