Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
3244072
Hide align behind a jmp
kunalspathak Oct 8, 2021
e7c0710
Fix a problem where curIG==0 and loop might be emitted in curIG, adju…
kunalspathak Oct 22, 2021
bd922aa
Add stress mode to emit int3 for xarch
kunalspathak Oct 22, 2021
4d0f912
Add stress mode to emit bkpt for arm64
kunalspathak Oct 22, 2021
8d64351
Add a loop align instruction placement phase
kunalspathak Oct 29, 2021
9b9b616
review comments
kunalspathak Oct 29, 2021
6302975
Change from unsigned short to unsigned
kunalspathak Oct 29, 2021
d20da6d
review comments around cleanup
kunalspathak Nov 10, 2021
c6a2d70
emitForceNewIG
kunalspathak Nov 10, 2021
e9c5eec
Remove emitPrevIG
kunalspathak Nov 10, 2021
c1c5db3
Revert change to forceNewIG for align instruction
kunalspathak Nov 10, 2021
b8a9742
Use loopAlignCandidates
kunalspathak Nov 11, 2021
db98ec2
Use loopHeadIG reference
kunalspathak Nov 11, 2021
5ab9edc
jit format
kunalspathak Nov 11, 2021
c8a9e01
Remove unneeded method
kunalspathak Nov 11, 2021
5bb1563
Misc changes
kunalspathak Nov 11, 2021
2c6e81d
Review feedback
kunalspathak Nov 12, 2021
bbc2ac5
Do not include align behind Jmp in PerfScore calculation
kunalspathak Nov 13, 2021
64bba41
jit format and fix a bug
kunalspathak Nov 15, 2021
1e24fcb
fix the loopCandidates == 0 scenario
kunalspathak Nov 15, 2021
b301fa5
Add unmarkLoopAlign(), add check for fgFirstBB
kunalspathak Nov 16, 2021
57759d0
merge conflict fix
kunalspathak Nov 16, 2021
ef0e859
Add missing }
kunalspathak Nov 16, 2021
976b253
Grammar nit
kunalspathak Nov 18, 2021
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
Prev Previous commit
Next Next commit
jit format and fix a bug
  • Loading branch information
kunalspathak committed Nov 16, 2021
commit 64bba410fd7fd3c1676dd4642734b8c569b44a6e
1 change: 0 additions & 1 deletion src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5272,7 +5272,6 @@ void Compiler::placeLoopAlignInstructions()
minBlockSoFar = BB_MAX_WEIGHT;
bbHavingAlign = nullptr;


if (--loopsToProcess == 0)
{
break;
Expand Down
12 changes: 6 additions & 6 deletions src/coreclr/jit/emit.h
Original file line number Diff line number Diff line change
Expand Up @@ -1389,9 +1389,9 @@ class emitter
// If no 'jmp' instructions were found until idaLoopHeadPredIG,
// then idaLoopHeadPredIG == idaIG.
#ifdef DEBUG
bool isPlacedAfterJmp; // Is the 'align' instruction placed after jmp. Used to decide
// if the instruction cost should be included in PerfScore
// calculation or not.
bool isPlacedAfterJmp; // Is the 'align' instruction placed after jmp. Used to decide
// if the instruction cost should be included in PerfScore
// calculation or not.
#endif

inline insGroup* loopHeadIG()
Expand Down Expand Up @@ -1804,14 +1804,14 @@ class emitter

unsigned getLoopSize(insGroup* igLoopHeader,
unsigned maxLoopSize DEBUG_ARG(bool isAlignAdjusted)); // Get the smallest loop size
void emitLoopAlignment(DEBUG_ARG1(bool isPlacedBehindJmp));
void emitLoopAlignment(DEBUG_ARG1(bool isPlacedBehindJmp));
bool emitEndsWithAlignInstr(); // Validate if newLabel is appropriate
void emitSetLoopBackEdge(BasicBlock* loopTopBlock);
void emitLoopAlignAdjustments(); // Predict if loop alignment is needed and make appropriate adjustments
unsigned emitCalculatePaddingForLoopAlignment(insGroup* ig, size_t offset DEBUG_ARG(bool isAlignAdjusted));

void emitLoopAlign(unsigned paddingBytes, bool isFirstAlign DEBUG_ARG(bool isPlacedBehindJmp));
void emitLongLoopAlign(unsigned alignmentBoundary DEBUG_ARG(bool isPlacedBehindJmp));
void emitLoopAlign(unsigned paddingBytes, bool isFirstAlign DEBUG_ARG(bool isPlacedBehindJmp));
void emitLongLoopAlign(unsigned alignmentBoundary DEBUG_ARG(bool isPlacedBehindJmp));
instrDescAlign* emitAlignInNextIG(instrDescAlign* alignInstr);
void emitConnectAlignInstrWithCurIG();

Expand Down
12 changes: 9 additions & 3 deletions src/coreclr/jit/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2517,9 +2517,15 @@ void Compiler::optIdentifyLoopsForAlignment()
weight_t topWeight = top->getBBWeight(this);
if (topWeight >= (opts.compJitAlignLoopMinBlockWeight * BB_UNITY_WEIGHT))
{
loopAlignCandidates++;
JITDUMP(FMT_LP " that starts at " FMT_BB " needs alignment, weight=" FMT_WT ".\n", loopInd,
top->bbNum, topWeight);
// Sometimes with JitOptRepeat > 1, we might end up finding the loops twice. In such
// cases, make sure to count them just once.
if (!first->isLoopAlign())
{
loopAlignCandidates++;
top->bbFlags |= BBF_LOOP_ALIGN;
JITDUMP(FMT_LP " that starts at " FMT_BB " needs alignment, weight=" FMT_WT ".\n", loopInd,
top->bbNum, top->getBBWeight(this));
}
}
else
{
Expand Down