JIT: bail on flipping post-layout JTRUE when reversal needs new IR#127746
Draft
JIT: bail on flipping post-layout JTRUE when reversal needs new IR#127746
Conversation
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/5d85b59c-0590-49b1-9854-94014903fa1a Co-authored-by: jakobbotsch <7887810+jakobbotsch@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix assertion failure in JIT during optimize post-layout
JIT: bail on flipping post-layout JTRUE when reversal needs new IR
May 4, 2026
jakobbotsch
reviewed
May 4, 2026
Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/c3a02af3-6597-451c-ad3c-267603ddb8ba Co-authored-by: jakobbotsch <7887810+jakobbotsch@users.noreply.github.com>
Copilot
AI
requested review from
Copilot and
jakobbotsch
and removed request for
Copilot
May 4, 2026 13:10
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
jakobbotsch
approved these changes
May 4, 2026
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.
optOptimizePostLayoutruns after LSRA and calledgtReverseCond, which can fall back to wrapping the operand in a freshGT_EQ(tree, 0). The newGT_INT_CONchild is never inserted into the LIR, trippingfound use of a node that is not in the LIR sequencein checked builds (reported by Fuzzlyn on linux-arm32). The fallback was also reached whenever LSRA inserted aGT_COPY/GT_RELOADon top of the JTRUE operand, since the wrapper is not itself a comparison.Description
gentree.cpp/compiler.h— ExtractgtTryReverseCond(GenTree*) -> boolthat reverses compares,JCC/SETCC,JCMP/JTEST, and integral constants in place.gtReverseCondbecomes a thin wrapper that adds theGT_EQ(tree, 0)fallback when in-place reversal isn't possible, preserving semantics for all existing callers.optimizer.cpp— InoptOptimizePostLayout, peelGT_COPY/GT_RELOADoff theGT_JTRUEoperand viagtSkipReloadOrCopy(), then usegtTryReverseCondand skip flipping the block if it returnsfalserather than mutating the LIR.