Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Retain LOOP_ALIGN flag of loops whose start are same
  • Loading branch information
kunalspathak committed Jul 2, 2021
commit 5d777fa92293bbf8fc2696c8e1e141e428446c2c
25 changes: 9 additions & 16 deletions src/coreclr/jit/emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4854,9 +4854,7 @@ void emitter::emitSetLoopBackEdge(BasicBlock* loopTopBlock)
emitLastLoopStart = currLoopStart;
emitLastLoopEnd = currLoopEnd;
}
// else if current loop completely encloses last loop,
// then current loop should not be aligned.
else if ((currLoopStart <= emitLastLoopStart) && (emitLastLoopEnd < currLoopEnd))
else if (currLoopStart == emitLastLoopStart)
{
// Note: If current and last loop starts at same point,
// retain the alignment flag of the smaller loop.
Expand All @@ -4868,23 +4866,18 @@ void emitter::emitSetLoopBackEdge(BasicBlock* loopTopBlock)
// | |
// |-----.
//
}
// else if current loop completely encloses last loop,
// then current loop should not be aligned.
else if ((currLoopStart < emitLastLoopStart) && (emitLastLoopEnd < currLoopEnd))
{
noAlignCurrentLoop = true;
}

// else if last loop completely encloses current loop,
// then last loop should not be aligned.
else if ((emitLastLoopStart <= currLoopStart) && (currLoopEnd < emitLastLoopEnd))
else if ((emitLastLoopStart < currLoopStart) && (currLoopEnd < emitLastLoopEnd))
{
// Note: If current and last loop starts at same point,
// retain the alignment flag of the smaller loop.
// |
// .---->|<----.
// last | | |
// loop | | | current
// | |-----. loop
// | |
// .---->|
//
noAlignLastLoop = true;
}
else
Expand All @@ -4907,7 +4900,7 @@ void emitter::emitSetLoopBackEdge(BasicBlock* loopTopBlock)
assert(!markedCurrLoop);
alignInstr->idaIG->igFlags &= ~IGF_LOOP_ALIGN;
markedCurrLoop = true;
JITDUMP("** Skip alignment for loop IG%02u ~ IG%02u because it encloses an aligned loop IG%02u ~ IG%02u.\n",
JITDUMP("** Skip alignment for current loop IG%02u ~ IG%02u because it encloses an aligned loop IG%02u ~ IG%02u.\n",
currLoopStart, currLoopEnd, emitLastLoopStart, emitLastLoopEnd);
}

Expand All @@ -4919,7 +4912,7 @@ void emitter::emitSetLoopBackEdge(BasicBlock* loopTopBlock)
assert(alignInstr->idaIG->isLoopAlign());
alignInstr->idaIG->igFlags &= ~IGF_LOOP_ALIGN;
markedLastLoop = true;
JITDUMP("** Skip alignment for loop IG%02u ~ IG%02u because it encloses an aligned loop IG%02u ~ IG%02u.\n",
JITDUMP("** Skip alignment for aligned loop IG%02u ~ IG%02u because it encloses the current loop IG%02u ~ IG%02u.\n",
emitLastLoopStart, emitLastLoopEnd, currLoopStart, currLoopEnd);
}

Expand Down