Skip to content

JIT: Run liveness + DCE in tier0#124060

Closed
jakobbotsch wants to merge 1 commit intodotnet:mainfrom
jakobbotsch:tier0-liveness
Closed

JIT: Run liveness + DCE in tier0#124060
jakobbotsch wants to merge 1 commit intodotnet:mainfrom
jakobbotsch:tier0-liveness

Conversation

@jakobbotsch
Copy link
Member

Just an experiment after seeing the results of #123500. Unlike for runtime async this may not prevent as much IR being generated, so probably won't see throughput wins.

Copilot AI review requested due to automatic review settings February 5, 2026 21:11
@github-actions github-actions bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Feb 5, 2026
@dotnet-policy-service
Copy link
Contributor

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces an experimental optimization to run liveness analysis during tier0 compilation (when not in debug mode and not using forced MinOpts). The change is inspired by PR #123500, which showed that running full liveness for async methods in MinOpts can reduce IR generation sufficiently to offset the cost of the analysis itself.

Changes:

  • Adds a new fgTier0Liveness() function that runs liveness analysis in tier0 and immediately discards the results after use
  • The function performs liveness analysis temporarily, then cleans up all tracking state so the rest of the compilation pipeline is unaffected

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/coreclr/jit/liveness.cpp Implements fgTier0Liveness() with a Tier0Liveness configuration that runs basic liveness analysis with full state cleanup afterwards
src/coreclr/jit/compiler.h Declares the new fgTier0Liveness() method
src/coreclr/jit/compiler.cpp Calls fgTier0Liveness() when tier0 optimizations are enabled (after optimization loop, before lowering phases)

}

//------------------------------------------------------------------------
// fgSsaLiveness: Run SSA liveness.
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The comment incorrectly states "Run SSA liveness" which is a copy-paste error from the fgSsaLiveness function above. This should say something like "Run tier0 liveness" or "Run liveness for tier0 optimization" to accurately describe what this function does.

Suggested change
// fgSsaLiveness: Run SSA liveness.
// fgTier0Liveness: Run tier0 liveness.

Copilot uses AI. Check for mistakes.
Comment on lines +2836 to +2844
struct Tier0Liveness : public Liveness<Tier0Liveness>
{
enum
{
SsaLiveness = false,
ComputeMemoryLiveness = false,
IsLIR = false,
IsEarly = false,
};
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

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

The PR title states "Run liveness + DCE in tier0", but dead code elimination (DCE) will not actually run with this configuration. DCE only runs when IsEarly=true, which causes the compiler to use the TryRemoveDeadStoreEarly path during liveness analysis. The Tier0Liveness struct sets IsEarly=false, so it will follow the standard liveness path without DCE.

At the call site, fgNodeThreading is NodeThreading::AllTrees, and with IsEarly=false, the liveness analysis follows the code path at lines 1265-1313 in liveness.cpp which does not perform dead store removal. The DCE path at lines 1314-1387 only executes when IsEarly=true.

If the intent is to run DCE in tier0, IsEarly should be set to true. If DCE is not intended, the PR title and description should be updated to remove the mention of DCE.

Copilot uses AI. Check for mistakes.
@jakobbotsch
Copy link
Member Author

Significant TP regressions from this, and the improvements aren't all that impressive.

image image

@jakobbotsch jakobbotsch closed this Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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.

1 participant