Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions src/coreclr/jit/rangecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,8 +863,28 @@ void RangeCheck::MergeEdgeAssertions(Compiler* comp,
}
else
{
// We have a != assertion, but it doesn't tell us much about the interval. So just skip it.
continue;
assert(curAssertion->assertionKind == Compiler::OAK_NOT_EQUAL);

// We have an assertion of the form "X != constLimit".
// For example, if the assertion is "X != 100" and the current range for X is [100, X],
// we can tighten the range to [101, X].
// Similarly, if the range is [Y, 100], we can tighten it to [Y, 99].

if (pRange->LowerLimit().IsConstant() && pRange->LowerLimit().GetConstant() == cnstLimit)
{
limit = Limit(Limit::keConstant, cnstLimit);
cmpOper = GT_GT;
}
else if (pRange->UpperLimit().IsConstant() && pRange->UpperLimit().GetConstant() == cnstLimit)
{
limit = Limit(Limit::keConstant, cnstLimit);
cmpOper = GT_LT;
}
else
{
// We can't make any useful deduction from this assertion.
continue;
}
}

isConstantAssertion = true;
Expand Down
Loading