diff options
author | Jan Kotas <jkotas@microsoft.com> | 2016-03-05 19:15:10 -0800 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2016-03-05 19:15:10 -0800 |
commit | 8e069ce739232b43085e530556bf6b02832d8b5b (patch) | |
tree | 1246187282fac29596144ef2278fe02e9536ebf8 /tests/src/readytorun | |
parent | c89bf3f87b0d8df4865bd9b50ad8ef14c2655d39 (diff) | |
parent | 669bd80064f26cd0b4ded9404899e23f512a7e33 (diff) | |
download | coreclr-8e069ce739232b43085e530556bf6b02832d8b5b.tar.gz coreclr-8e069ce739232b43085e530556bf6b02832d8b5b.tar.bz2 coreclr-8e069ce739232b43085e530556bf6b02832d8b5b.zip |
Merge pull request #3470 from erozenfeld/ValueNumbersForR2RHelpers
Improvements for ReadyToRun helpers in JIT value numbering.
Diffstat (limited to 'tests/src/readytorun')
-rw-r--r-- | tests/src/readytorun/main.cs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/src/readytorun/main.cs b/tests/src/readytorun/main.cs index c68baa025d..427ca42340 100644 --- a/tests/src/readytorun/main.cs +++ b/tests/src/readytorun/main.cs @@ -249,6 +249,47 @@ class Program new MyClass().GetType().ToString(); } + [MethodImplAttribute(MethodImplOptions.NoInlining)] + static void TestStaticBaseCSE() + { + // There should be just one call to CORINFO_HELP_READYTORUN_STATIC_BASE + // in the generated code. + s++; + s++; + Assert.AreEqual(s, 2); + s = 0; + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + static void TestIsInstCSE() + { + // There should be just one call to CORINFO_HELP_READYTORUN_ISINSTANCEOF + // in the generated code. + object o1 = (s < 1) ? (object)"foo" : (object)1; + Assert.AreEqual(o1 is string, true); + Assert.AreEqual(o1 is string, true); + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + static void TestCastClassCSE() + { + // There should be just one call to CORINFO_HELP_READYTORUN_CHKCAST + // in the generated code. + object o1 = (s < 1) ? (object)"foo" : (object)1; + string str1 = (string)o1; + string str2 = (string)o1; + Assert.AreEqual(str1, str2); + } + + [MethodImplAttribute(MethodImplOptions.NoInlining)] + static void TestRangeCheckElimination() + { + // Range checks for array accesses should be eliminated by the compiler. + int[] array = new int[5]; + array[2] = 2; + Assert.AreEqual(array[2], 2); + } + #if CORECLR class MyLoadContext : AssemblyLoadContext { @@ -331,6 +372,14 @@ class Program #endif TestFieldLayoutNGenMixAndMatch(); + + TestStaticBaseCSE(); + + TestIsInstCSE(); + + TestCastClassCSE(); + + TestRangeCheckElimination(); } static int Main() @@ -353,4 +402,6 @@ class Program } static bool LLILCJitEnabled; + + static int s; } |