Repository navigation
Follow DivMod flags instead of re-deriving the exception set - #137026
Open
NinoFloris wants to merge 5 commits into
Open
NinoFloris wants to merge 5 commits into
NinoFloris wants to merge 5 commits into
Conversation
|
Azure Pipelines: Successfully started running 5 pipeline(s). 10 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
NinoFloris
marked this pull request as ready for review
November 5, 2026 16:12
Every other oper's exception set is a property of the node. A signed division's overflow was derived from the never-negative status of its operands, read from the local descriptor, the integral range and the value number store, so the set moved whenever a later phase learned something about an operand while GTF_EXCEPT stayed what morph computed. OperExceptions consults only the GTF_DIV_MOD_NO flags and constant operands. Whoever proves an operand safe records it on the node with SetDivModExceptionFlags: morph on every target, assertion propagation, and the stack level setter before codegen. Zero diffs on the osx-arm64 libraries pmi collection.
A flag set from a property of the operand's value holds wherever the node ends up and needs no GTF_ORDER_SIDEEFF. optAssertionProp_ModDiv records those through SetDivModExceptionFlags first and pins the node only for what its assertions add under a dominating check.
Keep the constant dividend proof when the operand becomes a temp. A nonnegative dividend also rules out signed overflow, so record that fact before assertion propagation considers pinning the operation. Check assertion-dependent overflow before converting a signed operation to unsigned.
NinoFloris
force-pushed
the
jit/division-exception-set
branch
from
November 23, 2026 10:28
b898ec5 to
48e8111
Compare
Convert DIV and MOD when both operands are nonnegative. Only the operations that stay signed need the assertion-dependent overflow pin. Keep the separate pin for a divisor proven nonzero by a dominating check.
Rewrite (x + -y) + c as (x + c) - y during global morph. This lets lowering fold the offset into an address without a separate negation or another morph pass. Preserve operand evaluation order when the negated addend comes first.
NinoFloris
commented
Nov 23, 2026
| } | ||
| } | ||
|
|
||
| // Reassociation can expose (x + -y) + c after the inner add has been morphed. |
Contributor
Author
There was a problem hiding this comment.
Assertion prop used to pin the DIV or MOD and mark its statement as changed. That caused the JIT to re-morph the statement, which happened to fold this pattern
3 tasks
This branch has not been deployed
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.
This is a cleanup PR. Zero diffs on the windows-x64 and osx-arm64 libraries pmi collections. The diffs elsewhere are divisions that assertion prop had pinned with GTF_ORDER_SIDEEFF for operand facts as well, which don't need to be pinned.
I stumbled over this quirky behavior in #136994. The exception set of a signed division is currently re-derived from its operands on every read. This is unlike every other oper, whose set is a property of the node. This PR just aligns the behavior with that.
I'm not the first to run into this, that was in #97201 previously, which only added a workaround. The recent change to pin the node in dominated cases in #129533 is still respected.