-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
JIT: Remove BBF_NONE_QUIRK check when optimizing branch to empty unconditional #99790
Conversation
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
cc @dotnet/jit-contrib, @AndyAyersMS PTAL. Diffs |
Don't we already screen for this? if (bDest->KindIs(BBJ_ALWAYS) && !bDest->TargetIs(bDest) && // special case for self jumps
bDest->isEmpty()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look like an improvement, but I'm still puzzled why we need the JumpsToNext
part.
I guess you are seeing cases where there is a two-block infinite loop where both blocks are empty, and the optimization just cycles around the loop trying to find the end. But it seems like we could have this kind of structure even w/o them being adjacent.
The right fix might be to add cycle detection of some kind...?
Sorry, I misspoke -- the problematic pattern is when
That's it. In other words, the pattern is a cycle like
I initially tried that, and it seemed to reduce the amount of loop cloning we do in some collections. If you'd like, I can open a follow-up PR with the cycle detection to show you the diffs. |
Both CI failures look like #99725. |
Looking at the JIT dumps for affected methods, I suspect |
This fixed some instances, though not all of them. In |
The post-merge comments ^^ are for a version with cycle detection? I think we should try and get the block weights correct, and if that changes cloning, I'm ok with it. At some point (perhaps soon) we need to look harder at the cloning heuristics. In particular |
Yes, that's all with cycle detection.
Sounds like a good plan. Maybe we can bookmark the cycle detection work and come back to this after we've made some progress on block weights? |
Part of #95998. Removing the
JumpsToNext
check altogether seems to affect loop cloning, and also exposes a rare pattern wherebDest
's jump target isbDest
, and we enter an infinite loop where we first try to optimizeblock -> bDest -> bDestTarget
, then we try to optimizeblock -> bDestTarget -> bDest
, etc. Just compactingbDest
later on seems easier, and if we are able to compact it, we end up withblock -> bDestTarget
.If this PR and #99783 are both merged, we can (finally) get rid of
BBF_NONE_QUIRK
.