Skip to content

Commit aa660d5

Browse files
authored
Do not align cloned loops (#48090)
* Do not align cloned loops
1 parent df719dd commit aa660d5

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/coreclr/jit/emitxarch.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9223,6 +9223,12 @@ void emitter::emitDispIns(
92239223
break;
92249224

92259225
case IF_NONE:
9226+
#if FEATURE_LOOP_ALIGN
9227+
if (ins == INS_align)
9228+
{
9229+
printf("[%d bytes]", id->idCodeSize());
9230+
}
9231+
#endif
92269232
break;
92279233

92289234
default:

src/coreclr/jit/optimizer.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5319,6 +5319,18 @@ void Compiler::optCloneLoop(unsigned loopInd, LoopCloneContext* context)
53195319
// checked them to guarantee they are clonable.
53205320
bool cloneOk = BasicBlock::CloneBlockState(this, newBlk, blk);
53215321
noway_assert(cloneOk);
5322+
5323+
#if FEATURE_LOOP_ALIGN
5324+
// If the original loop is aligned, do not align the cloned loop because cloned loop will be executed in
5325+
// rare scenario. Additionally, having to align cloned loop will force us to disable some VEX prefix encoding
5326+
// and adding compensation for over-estimated instructions.
5327+
if (blk->isLoopAlign())
5328+
{
5329+
newBlk->bbFlags &= ~BBF_LOOP_ALIGN;
5330+
JITDUMP("Removing LOOP_ALIGN flag from cloned loop in " FMT_BB "\n", newBlk->bbNum);
5331+
}
5332+
#endif
5333+
53225334
// TODO-Cleanup: The above clones the bbNatLoopNum, which is incorrect. Eventually, we should probably insert
53235335
// the cloned loop in the loop table. For now, however, we'll just make these blocks be part of the surrounding
53245336
// loop, if one exists -- the parent of the loop we're cloning.

0 commit comments

Comments
 (0)