Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a significant refactoring of assertion representation in the JIT compiler, specifically for relational operators. The goal is to simplify how constant bound assertions are stored and processed.
Changes:
- Adds new assertion kinds for relational operators (OAK_LT, OAK_LE, OAK_GT, OAK_GE and their unsigned variants)
- Removes O1K_CONSTANT_LOOP_BND and O1K_CONSTANT_LOOP_BND_UN operand kinds
- Changes assertion storage from "relopVN ==/!= 0" format to direct "vn1 oper vn2" format
- Adds helper methods for converting between VNFunc and assertion kinds
- Simplifies CreateConstantLoopBound to extract and store relop components directly
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/coreclr/jit/compiler.h | Adds 8 new OAK_* relop kinds, removes 2 O1K_CONSTANT_LOOP_BND kinds, adds VNFuncToKind/KindToOper/ReverseKind helper methods, refactors CreateConstantLoopBound to extract relop components |
| src/coreclr/jit/assertionprop.cpp | Updates optPrintAssertion with new relop kinds, removes O1K_CONSTANT_LOOP_BND handling, simplifies optCreateJTrueBoundsAssertion, updates optAssertionProp_RangeProperties to use new representation |
| src/coreclr/jit/rangecheck.cpp | Simplifies MergeEdgeAssertions to work with new relop representation instead of extracting from stored VN |
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/coreclr/jit/compiler.h:8143
- The
vnBasedparameter is not used in this method. This parameter should either be removed if it's no longer needed, or the implementation should be updated to use it if it was previously used for determining comparison logic.
bool HasSameOp2(const AssertionDsc& that, bool vnBased) const
{
if (!GetOp2().KindIs(that.GetOp2().GetKind()))
{
return false;
}
switch (GetOp2().GetKind())
{
case O2K_CONST_INT:
return ((GetOp2().GetIntConstant() == that.GetOp2().GetIntConstant()) &&
(GetOp2().GetIconFlag() == that.GetOp2().GetIconFlag()));
case O2K_CONST_DOUBLE:
// exact match because of positive and negative zero.
return (memcmp(&GetOp2().m_dconVal, &that.GetOp2().m_dconVal, sizeof(double)) == 0);
case O2K_ZEROOBJ:
return true;
case O2K_BOUND:
return GetOp2().GetVN() == that.GetOp2().GetVN();
case O2K_LCLVAR_COPY:
return GetOp2().GetLclNum() == that.GetOp2().GetLclNum();
case O2K_SUBRANGE:
return GetOp2().GetIntegralRange().Equals(that.GetOp2().GetIntegralRange());
case O2K_INVALID:
default:
assert(!"Unexpected value for GetOp2().m_kind in AssertionDsc.");
break;
}
return false;
}
Member
Author
|
PTAL @AndyAyersMS @dotnet/jit-contrib |
AndyAyersMS
approved these changes
Feb 5, 2026
Member
Author
|
/ba-g tvos infra issue |
lewing
pushed a commit
to lewing/runtime
that referenced
this pull request
Feb 9, 2026
Today, assertions for relops are represented as `relopVN OAK_[NOT]_EQUAL 0` - this forces most assertion consumers to call GetVNFunc over the relopVN to see if one of the operands matches thiers. This PR attempts to remove them and introduce `OAK_<relop>` so all assertions become just e.g. `op1VN OAK_LE op2VN`. The plan is to remove these: ``` (removed in this PR) O1K_CONSTANT_LOOP_BND (removed in this PR) O1K_CONSTANT_LOOP_BND_UN (removed in this PR) O1K_ARR_BND (will be removed in a follow up) O1K_BOUND_LOOP_BND, // X < CHECKED_BND (will be removed in a follow up) O1K_BOUND_OPER_BND, // X < CHECKED_BND + Y (removed in this PR) OAK_NO_THROW ``` Also, no longer weird `OAK_NO_THROW` without `op2`. It's now represented as a normal `op1VN (idx) OAK_LT_UN op2VN (len)` I need this simplification for some of the optimizations I have in mind (and enable many existing ops for 64-bit integers and floating points). Also, it makes it easier to implement a VN-mapped hash set to quickly validate that we definitely don't have assertions for the given VN. [Diffs](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1281385&view=ms.vss-build-web.run-extensions-tab) - slight improvements in size and TP. I tried to keep the size diffs minimal for the refactoring PR, but it was not possible without ugly hacks to make them exactly zero.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Today, assertions for relops are represented as
relopVN OAK_[NOT]_EQUAL 0- this forces most assertion consumers to call GetVNFunc over the relopVN to see if one of the operands matches thiers. This PR attempts to remove them and introduceOAK_<relop>so all assertions become just e.g.op1VN OAK_LE op2VN.The plan is to remove these:
Also, no longer weird
OAK_NO_THROWwithoutop2. It's now represented as a normalop1VN (idx) OAK_LT_UN op2VN (len)I need this simplification for some of the optimizations I have in mind (and enable many existing ops for 64-bit integers and floating points). Also, it makes it easier to implement a VN-mapped hash set to quickly validate that we definitely don't have assertions for the given VN.
Diffs - slight improvements in size and TP. I tried to keep the size diffs minimal for the refactoring PR, but it was not possible without ugly hacks to make them exactly zero.