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

Revert "JIT: remove phis right after optimizing" #110854

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5006,9 +5006,6 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
// Iterate if requested, resetting annotations first.
if (opts.optRepeatIteration == opts.optRepeatCount)
{
// If we're done optimizing, just remove the PHIs
//
fgResetForSsa(/* deepClean */ false);
break;
}

Expand Down Expand Up @@ -5852,7 +5849,7 @@ void Compiler::ResetOptAnnotations()
{
assert(opts.optRepeat);
assert(JitConfig.JitOptRepeatCount() > 0);
fgResetForSsa(/* deepClean */ true);
fgResetForSsa();
vnStore = nullptr;
m_blockToEHPreds = nullptr;
m_dominancePreds = nullptr;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -5725,7 +5725,7 @@ class Compiler
PhaseStatus fgSsaBuild();

// Reset any data structures to the state expected by "fgSsaBuild", so it can be run again.
void fgResetForSsa(bool deepClean);
void fgResetForSsa();

unsigned fgSsaPassesCompleted = 0; // Number of times fgSsaBuild has been run.
bool fgSsaValid = false; // True if SSA info is valid and can be cross-checked versus IR
Expand Down
52 changes: 17 additions & 35 deletions src/coreclr/jit/ssabuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ PhaseStatus Compiler::fgSsaBuild()
// If this is not the first invocation, reset data structures for SSA.
if (fgSsaPassesCompleted > 0)
{
fgResetForSsa(/* deepClean */ true);
fgResetForSsa();
}

SsaBuilder builder(this);
Expand All @@ -29,36 +29,21 @@ PhaseStatus Compiler::fgSsaBuild()
return PhaseStatus::MODIFIED_EVERYTHING;
}

//------------------------------------------------------------------------
// fgResetForSsa: remove SSA artifacts
//
// Arguments:
// deepClean - if true, remove all SSA artifacts
// if false, just remove PHIs
//
// Notes:
// deepCleaning is needed in order to rebuild SSA.
//
void Compiler::fgResetForSsa(bool deepClean)
void Compiler::fgResetForSsa()
{
JITDUMP("Removing %s\n", deepClean ? "all SSA artifacts" : "PHI functions");

if (deepClean)
for (unsigned i = 0; i < lvaCount; ++i)
{
for (unsigned i = 0; i < lvaCount; ++i)
{
lvaTable[i].lvPerSsaData.Reset();
}
lvMemoryPerSsaData.Reset();
for (MemoryKind memoryKind : allMemoryKinds())
{
m_memorySsaMap[memoryKind] = nullptr;
}
lvaTable[i].lvPerSsaData.Reset();
}
lvMemoryPerSsaData.Reset();
for (MemoryKind memoryKind : allMemoryKinds())
{
m_memorySsaMap[memoryKind] = nullptr;
}

if (m_outlinedCompositeSsaNums != nullptr)
{
m_outlinedCompositeSsaNums->Reset();
}
if (m_outlinedCompositeSsaNums != nullptr)
{
m_outlinedCompositeSsaNums->Reset();
}

for (BasicBlock* const blk : Blocks())
Expand All @@ -78,16 +63,13 @@ void Compiler::fgResetForSsa(bool deepClean)
}
}

if (deepClean)
for (Statement* const stmt : blk->Statements())
{
for (Statement* const stmt : blk->Statements())
for (GenTree* const tree : stmt->TreeList())
{
for (GenTree* const tree : stmt->TreeList())
if (tree->IsAnyLocal())
{
if (tree->IsAnyLocal())
{
tree->AsLclVarCommon()->SetSsaNum(SsaConfig::RESERVED_SSA_NUM);
}
tree->AsLclVarCommon()->SetSsaNum(SsaConfig::RESERVED_SSA_NUM);
}
}
}
Expand Down
Loading