Uh oh!
There was an error while loading. Please reload this page.
Change bbAssertionOut if BBJ_COND was folded in morph - #125222
Conversation
During Global Assertion Propagation's second loop, fgMorphBlockStmt can fold a BBJ_COND to BBJ_ALWAYS via fgFoldConditional. When the true edge is retained, block->bbAssertionOut still has the false-edge assertions. Fix by detecting when a BBJ_COND is folded to BBJ_ALWAYS via the true edge and copying bbJtrueAssertionOut[block->bbNum] into bbAssertionOut. Use FlowEdge* comparison (not BasicBlock*) to correctly handle the case where both edges target the same block. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
Pull request overview
This PR updates CoreCLR JIT assertion propagation to keep bbAssertionOut consistent when re-morphing folds a BBJ_COND into a non-conditional block (typically BBJ_ALWAYS), ensuring the outgoing assertion set reflects the retained edge’s semantics.
Changes:
- Capture a block’s pre-morph conditional targets before
fgMorphBlockStmt. - After morphing, if a former
BBJ_CONDis folded, adjustbbAssertionOutto match the retained successor edge (true vs false). - If morphing changes conditional edges in unexpected ways, conservatively reset outgoing assertion sets to
bbAssertionIn.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
AndyAyersMS
left a comment
There was a problem hiding this comment.
Think you should revise this for local AP.
Maybe also worry about degenerate BBJ_COND?
Uh oh!
There was an error while loading. Please reload this page.
EgorBo
commented
Mar 5, 2026
Thanks! Forgot about LocalAP. There are a few diffs implying we probably had bugs because of it |
EgorBo
commented
Mar 6, 2026
/ba-g deadletter |
Uh oh!
There was an error while loading. Please reload this page.
Address @AndyAyersMS concerns regarding assertion sets (#125093 (review))