JIT: Remove bound checks when index is Byte and array.Length >= 256 #25912
Changes from 6 commits
b8c9f62
034d97e
1f15a4b
cb0e27b
ceb75d4
b9b88cb
1d68ae6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1050,6 +1050,15 @@ bool RangeCheck::ComputeDoesOverflow(BasicBlock* block, GenTree* expr) | |
{ | ||
overflows = DoesPhiOverflow(block, expr); | ||
} | ||
else if (expr->OperGet() == GT_CAST) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It sounds like @dotnet/jit-contrib do we need an issue/task to rewrite this function to make it work for all opcodes and clarify its relationships with |
||
{ | ||
GenTreeCast* castExpr = expr->AsCast(); | ||
if (castExpr->CastToType() == TYP_UBYTE && castExpr->CastFromType() == TYP_INT) | ||
EgorBo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
overflows = false; | ||
} | ||
} | ||
|
||
GetOverflowMap()->Set(expr, overflows, OverflowMap::Overwrite); | ||
m_pSearchPath->Remove(expr); | ||
return overflows; | ||
|
@@ -1144,9 +1153,11 @@ Range RangeCheck::ComputeRange(BasicBlock* block, GenTree* expr, bool monotonic | |
JITDUMP("%s\n", range.ToString(m_pCompiler->getAllocatorDebugOnly())); | ||
} | ||
} | ||
else if (varTypeIsSmallInt(expr->TypeGet())) | ||
else if (expr->OperIs(GT_CAST) || varTypeIsSmallInt(expr->TypeGet())) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks unnatural for me to have a special case for the cast here, could you please extract the code below into Note: right now we hit this case only for
@dotnet/jit-contrib does anybody know any other nodes that could have |
||
{ | ||
switch (expr->TypeGet()) | ||
var_types exprType = expr->OperIs(GT_CAST) ? expr->AsCast()->CastToType() : expr->TypeGet(); | ||
|
||
switch (exprType) | ||
{ | ||
case TYP_UBYTE: | ||
range = Range(Limit(Limit::keConstant, 0), Limit(Limit::keConstant, 255)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is wrong