Respect JitNoRangeChks flag in RyuJit
authorJoseph Tremoulet <jotrem@microsoft.com>
Tue, 20 Sep 2016 20:09:32 +0000 (16:09 -0400)
committerJoseph Tremoulet <jotrem@microsoft.com>
Tue, 20 Sep 2016 21:28:39 +0000 (17:28 -0400)
Honor this config flag by having assertion prop treat all bounds check
nodes as redundant when it is set.

Also change the flag's lookup options to `REGUTIL_default` to match the
rest of the jit-focused flags.

Note that support for this flag is conditional on having the preprocessor
flag `FEATURE_ENABLE_NO_RANGE_CHECKS` defined, which requires a custom
build with line 199 of inc/switches.h un-commented (or with compile flags
altered to include `-DFEATURE_ENABLE_NO_RANGE_CHECKS`) -- the purpose of
the flag is to facilitate experiments to estimate the cumulative cost of
bounds checking in various workloads.

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

src/coreclr/src/inc/clrconfigvalues.h
src/coreclr/src/jit/assertionprop.cpp
src/coreclr/src/jit/jitconfig.h
src/coreclr/src/jit/jitconfigvalues.h

index 9cf1c50..1bd0419 100644 (file)
@@ -493,7 +493,7 @@ CONFIG_DWORD_INFO_EX(INTERNAL_JitNoStructPromotion, W("JitNoStructPromotion"), 0
 CONFIG_DWORD_INFO_EX(INTERNAL_JitNoUnroll, W("JitNoUnroll"), 0, "", CLRConfig::REGUTIL_default)
 CONFIG_DWORD_INFO_EX(INTERNAL_JitNoMemoryBarriers, W("JitNoMemoryBarriers"), 0, "If 1, don't generate memory barriers", CLRConfig::REGUTIL_default)
 #ifdef FEATURE_ENABLE_NO_RANGE_CHECKS
-RETAIL_CONFIG_DWORD_INFO(PRIVATE_JitNoRangeChks, W("JitNoRngChks"), 0, "If 1, don't generate range checks")
+RETAIL_CONFIG_DWORD_INFO_EX(PRIVATE_JitNoRangeChks, W("JitNoRngChks"), 0, "If 1, don't generate range checks", CLRConfig::REGUTIL_default)
 #endif
 RETAIL_CONFIG_DWORD_INFO_DIRECT_ACCESS(EXTERNAL_JitOptimizeType, W("JitOptimizeType"), "")
 CONFIG_DWORD_INFO_EX(INTERNAL_JitOrder, W("JitOrder"), 0, "", CLRConfig::REGUTIL_default)
index fe35c3b..8a53278 100644 (file)
@@ -3700,6 +3700,21 @@ GenTreePtr Compiler::optAssertionProp_BndsChk(ASSERT_VALARG_TP assertions, const
 
     assert(tree->gtOper == GT_ARR_BOUNDS_CHECK);
 
+#ifdef FEATURE_ENABLE_NO_RANGE_CHECKS
+       if (JitConfig.JitNoRangeChks())
+       {
+#ifdef DEBUG
+               if (verbose)
+               {
+                       printf("\nFlagging check redundant due to JitNoRangeChks in BB%02u:\n", compCurBB->bbNum);
+                       gtDispTree(tree, nullptr, nullptr, true);
+               }
+#endif // DEBUG
+               tree->gtFlags |= GTF_ARR_BOUND_INBND;
+               return nullptr;
+       }
+#endif // FEATURE_ENABLE_NO_RANGE_CHECKS
+
     BitVecOps::Iter iter(apTraits, assertions);
     unsigned        index = 0;
     while (iter.NextElem(apTraits, &index))
index d5b4e30..9186e12 100644 (file)
@@ -5,6 +5,8 @@
 #ifndef _JITCONFIG_H_
 #define _JITCONFIG_H_
 
+#include "switches.h"
+
 struct CORINFO_SIG_INFO;
 class ICorJitHost;
 
index 497d677..d03a31f 100644 (file)
@@ -92,6 +92,9 @@ CONFIG_INTEGER(JitNoMemoryBarriers, W("JitNoMemoryBarriers"), 0) // If 1, don't
 CONFIG_INTEGER(JitNoRegLoc, W("JitNoRegLoc"), 0)
 CONFIG_INTEGER(JitNoStructPromotion, W("JitNoStructPromotion"), 0) // Disables struct promotion in Jit32
 CONFIG_INTEGER(JitNoUnroll, W("JitNoUnroll"), 0)
+#ifdef FEATURE_ENABLE_NO_RANGE_CHECKS
+CONFIG_INTEGER(JitNoRangeChks, W("JitNoRngChks"), 0) // If 1, don't generate range checks
+#endif
 CONFIG_INTEGER(JitOrder, W("JitOrder"), 0)
 CONFIG_INTEGER(JitPInvokeCheckEnabled, W("JITPInvokeCheckEnabled"), 0)
 CONFIG_INTEGER(JitPInvokeEnabled, W("JITPInvokeEnabled"), 1)