Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use BoundsCheckNoThrow assertion in optAssertionProp_RangeProperties #102089

Merged
merged 1 commit into from
May 11, 2024
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
12 changes: 12 additions & 0 deletions src/coreclr/jit/assertionprop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3930,6 +3930,18 @@ void Compiler::optAssertionProp_RangeProperties(ASSERT_VALARG_TP assertions,
{
AssertionDsc* curAssertion = optGetAssertion(GetAssertionIndex(index));

// if treeVN has a bound-check assertion where it's an index, then
// it means it's not negative, example:
//
// array[idx] = 42; // creates 'BoundsCheckNoThrow' assertion
// return idx % 8; // idx is known to be never negative here, hence, MOD->UMOD
//
if (curAssertion->IsBoundsCheckNoThrow() && (curAssertion->op1.bnd.vnIdx == treeVN))
{
*isKnownNonNegative = true;
continue;
}

// First, analyze possible X ==/!= CNS assertions.
if (curAssertion->IsConstantInt32Assertion() && (curAssertion->op1.vn == treeVN))
{
Expand Down
Loading