diff --git a/src/coreclr/jit/compiler.cpp b/src/coreclr/jit/compiler.cpp index 421614c291fda6..0219f104b47f22 100644 --- a/src/coreclr/jit/compiler.cpp +++ b/src/coreclr/jit/compiler.cpp @@ -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]); @@ -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++) { diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index b5528e7b5b7908..e3afb451f69955 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -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, diff --git a/src/coreclr/jit/emit.cpp b/src/coreclr/jit/emit.cpp index cd626cbd335d05..74b62dd4b208a8 100644 --- a/src/coreclr/jit/emit.cpp +++ b/src/coreclr/jit/emit.cpp @@ -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 } //----------------------------------------------------------------------------- diff --git a/src/coreclr/jit/emitxarch.cpp b/src/coreclr/jit/emitxarch.cpp index 65a82c1c7b9ea3..fdf964c9b5c559 100644 --- a/src/coreclr/jit/emitxarch.cpp +++ b/src/coreclr/jit/emitxarch.cpp @@ -9434,6 +9434,8 @@ BYTE* emitter::emitOutputAlign(insGroup* ig, instrDesc* id, BYTE* dst) { assert(paddingToAdd == paddingNeeded); } + + emitComp->loopsAligned++; #endif return emitOutputNOP(dst, paddingToAdd); diff --git a/src/coreclr/jit/optimizer.cpp b/src/coreclr/jit/optimizer.cpp index 680c7b90719149..17b4a1858cea72 100644 --- a/src/coreclr/jit/optimizer.cpp +++ b/src/coreclr/jit/optimizer.cpp @@ -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;