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

Add loop alignment stats to JitLogCsv #50624

Merged
merged 3 commits into from
Apr 7, 2021
Merged
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
13 changes: 12 additions & 1 deletion src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8255,7 +8255,12 @@ void JitTimer::PrintCsvHeader()
fprintf(s_csvFile, "\"Min Opts\",");
fprintf(s_csvFile, "\"Loops\",");
fprintf(s_csvFile, "\"Loops Cloned\",");

#if FEATURE_LOOP_ALIGN
#ifdef DEBUG
fprintf(s_csvFile, "\"Alignment Candidates\",");
fprintf(s_csvFile, "\"Loops Aligned\",");
#endif // DEBUG
#endif // FEATURE_LOOP_ALIGN
for (int i = 0; i < PHASE_NUMBER_OF; i++)
{
fprintf(s_csvFile, "\"%s\",", PhaseNames[i]);
Expand Down Expand Up @@ -8329,6 +8334,12 @@ void JitTimer::PrintCsvMethodStats(Compiler* comp)
fprintf(s_csvFile, "%u,", comp->opts.MinOpts());
fprintf(s_csvFile, "%u,", comp->optLoopCount);
fprintf(s_csvFile, "%u,", comp->optLoopsCloned);
#if FEATURE_LOOP_ALIGN
#ifdef DEBUG
fprintf(s_csvFile, "%u,", comp->loopAlignCandidates);
fprintf(s_csvFile, "%u,", comp->loopsAligned);
#endif // DEBUG
#endif // FEATURE_LOOP_ALIGN
unsigned __int64 totCycles = 0;
for (int i = 0; i < PHASE_NUMBER_OF; i++)
{
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -6435,6 +6435,11 @@ class Compiler
LoopDsc* optLoopTable; // loop descriptor table
unsigned char optLoopCount; // number of tracked loops

#ifdef DEBUG
unsigned char loopAlignCandidates; // number of loops identified for alignment
unsigned char loopsAligned; // number of loops actually aligned
#endif // DEBUG

bool optRecordLoop(BasicBlock* head,
BasicBlock* first,
BasicBlock* top,
Expand Down
4 changes: 4 additions & 0 deletions src/coreclr/jit/emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4650,6 +4650,10 @@ void emitter::emitLoopAlignment()

JITDUMP("Adding 'align' instruction of %d bytes in G_M%03u_IG%02u.\n", paddingBytes, emitComp->compMethodID,
emitCurIG->igNum);

#ifdef DEBUG
emitComp->loopAlignCandidates++;
#endif // DEBUG
}

//-----------------------------------------------------------------------------
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/jit/emitxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9434,6 +9434,8 @@ BYTE* emitter::emitOutputAlign(insGroup* ig, instrDesc* id, BYTE* dst)
{
assert(paddingToAdd == paddingNeeded);
}

emitComp->loopsAligned++;
#endif

return emitOutputNOP(dst, paddingToAdd);
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/jit/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ void Compiler::optInit()
optLoopCount = 0;
optLoopTable = nullptr;

#ifdef DEBUG
loopAlignCandidates = 0;
loopsAligned = 0;
#endif

/* Keep track of the number of calls and indirect calls made by this method */
optCallCount = 0;
optIndirectCallCount = 0;
Expand Down