diff options
author | Andy Ayers <andya@microsoft.com> | 2019-01-07 13:15:27 -0800 |
---|---|---|
committer | Andy Ayers <andya@microsoft.com> | 2019-01-07 13:15:27 -0800 |
commit | eef4174805ccf8ae17f1f4e6170590a037122ddd (patch) | |
tree | 057d151f77f4bfb4d49bfed62c1e544f289e0a88 | |
parent | 7d54c590315ad682ed74f9491654720d83532ae7 (diff) | |
download | coreclr-eef4174805ccf8ae17f1f4e6170590a037122ddd.tar.gz coreclr-eef4174805ccf8ae17f1f4e6170590a037122ddd.tar.bz2 coreclr-eef4174805ccf8ae17f1f4e6170590a037122ddd.zip |
JIT: infer ranges from small int type operations
Have range check use the ranges for small int types if it has no better
information.
Fixes #21481
-rw-r--r-- | src/jit/rangecheck.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/jit/rangecheck.cpp b/src/jit/rangecheck.cpp index 7f9020e778..91ffb1a036 100644 --- a/src/jit/rangecheck.cpp +++ b/src/jit/rangecheck.cpp @@ -1027,6 +1027,14 @@ bool RangeCheck::ComputeDoesOverflow(BasicBlock* block, GenTree* expr) { overflows = false; } + else if (expr->OperGet() == GT_IND) + { + overflows = false; + } + else if (expr->OperGet() == GT_COMMA) + { + overflows = ComputeDoesOverflow(block, expr->gtEffectiveVal()); + } // Check if the var def has rhs involving arithmetic that overflows. else if (expr->IsLocal()) { @@ -1135,6 +1143,29 @@ Range RangeCheck::ComputeRange(BasicBlock* block, GenTree* expr, bool monotonic JITDUMP("%s\n", range.ToString(m_pCompiler->getAllocatorDebugOnly())); } } + else if (varTypeIsSmallInt(expr->TypeGet())) + { + switch (expr->TypeGet()) + { + case TYP_UBYTE: + range = Range(Limit(Limit::keConstant, 0), Limit(Limit::keConstant, 255)); + break; + case TYP_BYTE: + range = Range(Limit(Limit::keConstant, -127), Limit(Limit::keConstant, 128)); + break; + case TYP_USHORT: + range = Range(Limit(Limit::keConstant, 0), Limit(Limit::keConstant, 65535)); + break; + case TYP_SHORT: + range = Range(Limit(Limit::keConstant, -32768), Limit(Limit::keConstant, 32767)); + break; + default: + range = Range(Limit(Limit::keUnknown)); + break; + } + + JITDUMP("%s\n", range.ToString(m_pCompiler->getAllocatorDebugOnly())); + } else { // The expression is not recognized, so the result is unknown. |