summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndy Ayers <andya@microsoft.com>2019-01-08 18:42:59 -0800
committerGitHub <noreply@github.com>2019-01-08 18:42:59 -0800
commiteaf9823a0ba090826ed6cb3763fdce93f16199f0 (patch)
treec7a0a91c88d7a76d85fa1b7bca74119aad4df8ec /src
parent5a0144e70f412178615e3e69f2256ffd695d2189 (diff)
parenteef4174805ccf8ae17f1f4e6170590a037122ddd (diff)
downloadcoreclr-eaf9823a0ba090826ed6cb3763fdce93f16199f0.tar.gz
coreclr-eaf9823a0ba090826ed6cb3763fdce93f16199f0.tar.bz2
coreclr-eaf9823a0ba090826ed6cb3763fdce93f16199f0.zip
Merge pull request #21857 from AndyAyersMS/RangeCheckSmallTypes
JIT: infer ranges from small int type operations
Diffstat (limited to 'src')
-rw-r--r--src/jit/rangecheck.cpp31
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.