Skip to content
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: Reuse (new) loop-finding DFS tree in SSA #95809

Merged
merged 2 commits into from
Dec 9, 2023

Conversation

jakobbotsch
Copy link
Member

@jakobbotsch jakobbotsch commented Dec 8, 2023

  • Add a new phase to canonicalize the entry BB, way back before we compute reachability
  • Switch SSA to reuse the DFS tree computed for (new) loop finding
  • Switch SSA to use post-order traits instead of bbNum-based traits
  • Quirk old loop finding to avoid finding new loops now

Some improvements are expected from RBO no longer getting caught up in this early-out:

if (fgCurBBEpochSize != (fgBBNumMax + 1))
{
JITDUMP("Looks like we've added a new block (e.g. during optLoopHoist) since last renumber, so no threading\n");
return false;
}

* Add a new phase to canonicalize the entry BB, way back before we
  compute reachability
* Switch SSA to reuse the DFS computed for (new) loop finding
* Switch SSA to use post-order traits instead of bbNum-based traits
@ghost ghost assigned jakobbotsch Dec 8, 2023
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Dec 8, 2023
@ghost
Copy link

ghost commented Dec 8, 2023

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details
  • Add a new phase to canonicalize the entry BB, way back before we compute reachability
  • Switch SSA to reuse the DFS computed for (new) loop finding
  • Switch SSA to use post-order traits instead of bbNum-based traits
Author: jakobbotsch
Assignees: jakobbotsch
Labels:

area-CodeGen-coreclr

Milestone: -

@jakobbotsch jakobbotsch changed the title JIT: Reuse (new) loop-finding DFS in SSA JIT: Reuse (new) loop-finding DFS tree in SSA Dec 9, 2023
@jakobbotsch jakobbotsch marked this pull request as ready for review December 9, 2023 01:14
@jakobbotsch
Copy link
Member Author

cc @dotnet/jit-contrib PTAL @AndyAyersMS @BruceForstall

Diffs. ASM diffs from the RBO case mentioned above. TP improvements from doing one less DFS.

Copy link
Member

@BruceForstall BruceForstall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

I wonder if we could simplify things by just always creating a "scratch" first BB when the flow graph is created, and then teaching flow opts (e.g., block compaction) to not remove it even if empty. Then we could get rid of fgEnsureFirstBBisScratch and this new phase. Codegen wouldn't generate any code if the block ends up empty.

@jakobbotsch
Copy link
Member Author

I wonder if we could simplify things by just always creating a "scratch" first BB when the flow graph is created, and then teaching flow opts (e.g., block compaction) to not remove it even if empty. Then we could get rid of fgEnsureFirstBBisScratch and this new phase. Codegen wouldn't generate any code if the block ends up empty.

Yeah, I think that kind of canonicalization would be good. It would also benefit us earlier by allowing us to use the DFS I added in #95726 in e.g. physical promotion. Currently physical promotion may need to create a scratch BB and would thus invalidate the DFS tree.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants