-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Have ComputeRange call into GetRangeFromAssertions for non dependent/symbolic cases
#128922
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
Changes from all commits
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 |
|---|---|---|
|
|
@@ -1201,7 +1201,7 @@ void RangeCheck::MergeEdgeAssertionsWorker(Compiler* comp | |
| ValueNumStore::SmallValueNumSet* visited) | ||
| { | ||
| Range assertedRange = Range(Limit(Limit::keUnknown)); | ||
| if (BitVecOps::IsEmpty(comp->apTraits, assertions)) | ||
| if (BitVecOps::MayBeUninit(assertions) || BitVecOps::IsEmpty(comp->apTraits, assertions)) | ||
| { | ||
| return; | ||
| } | ||
|
|
@@ -2287,9 +2287,19 @@ Range RangeCheck::ComputeRange(BasicBlock* block, GenTree* expr, bool monIncreas | |
| // If VN is constant return range as constant. | ||
| else if (m_compiler->vnStore->IsVNConstant(vn)) | ||
| { | ||
| range = (m_compiler->vnStore->TypeOfVN(vn) == TYP_INT) | ||
| ? Range(Limit(Limit::keConstant, m_compiler->vnStore->ConstantValue<int>(vn))) | ||
| : Limit(Limit::keUnknown); | ||
| // We want to handle constants first since it can avoid other more expensive work | ||
|
|
||
| int cns; | ||
| if (m_compiler->vnStore->IsVNIntegralConstant(vn, &cns)) | ||
| { | ||
| range = Range(Limit(Limit::keConstant, cns)); | ||
| } | ||
| else | ||
| { | ||
| // TODO: We could return `0, keUnknown` if the constant is known positive | ||
| // but this would require more handling in other places to take advantage of. | ||
| range = Limit(Limit::keUnknown); | ||
|
Member
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. I don't think we can TBH, a never-negative long that doesn't fit into INT32 can be negative when casted to INT32?
Member
Author
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. Wouldn’t that be handled by the cast?
Member
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. I meant I don't see what we can possibly do for a LONG that doesn't fit into INT here
Member
Author
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's the same consideration as for Which is that the MSB is never set for this target format and so therefore shifts, mods, and various other operations can be optimized as the unsigned variants. If we cast from |
||
| } | ||
| } | ||
| // If local, find the definition from the def map and evaluate the range for rhs. | ||
| else if (expr->IsLocal()) | ||
|
|
@@ -2331,20 +2341,10 @@ Range RangeCheck::ComputeRange(BasicBlock* block, GenTree* expr, bool monIncreas | |
| JITDUMP("%s\n", range.ToString(m_compiler)); | ||
| } | ||
| } | ||
| else if (varTypeIsSmall(expr)) | ||
| { | ||
| range = GetRangeFromType(expr->TypeGet()); | ||
| JITDUMP("%s\n", range.ToString(m_compiler)); | ||
| } | ||
| else if (expr->OperIs(GT_COMMA)) | ||
| { | ||
| range = GetRangeWorker(block, expr->gtEffectiveVal(), monIncreasing DEBUGARG(indent + 1)); | ||
| } | ||
| else if (expr->OperIs(GT_CAST)) | ||
| { | ||
| // TODO: consider computing range for CastOp and intersect it with this. | ||
| range = GetRangeFromType(expr->AsCast()->CastToType()); | ||
| } | ||
| else if (expr->OperIs(GT_ARR_LENGTH)) | ||
| { | ||
| ValueNum arrLenVN = m_compiler->optConservativeNormalVN(expr); | ||
|
|
@@ -2360,6 +2360,11 @@ Range RangeCheck::ComputeRange(BasicBlock* block, GenTree* expr, bool monIncreas | |
| range = Range(Limit(Limit::keConstant, 0), Limit(Limit::keConstant, CORINFO_Array_MaxLength)); | ||
| } | ||
| } | ||
| else if (genActualType(expr) == TYP_INT) | ||
| { | ||
| // Use GetRangeFromAssertions for everything else since they won't produce dependent or symbolic ranges | ||
| range = GetRangeFromAssertions(m_compiler, vn, block->bbAssertionIn); | ||
| } | ||
|
tannergooding marked this conversation as resolved.
|
||
| else | ||
| { | ||
| // The expression is not recognized, so the result is unknown. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.