@@ -5175,6 +5175,20 @@ void emitter::emitSetLoopBackEdge(BasicBlock* loopTopBlock)
5175
5175
5176
5176
emitLastLoopStart = currLoopStart;
5177
5177
emitLastLoopEnd = currLoopEnd;
5178
+
5179
+ for (insGroup* igInLoop = dstIG; igInLoop != nullptr ; igInLoop = igInLoop->igNext )
5180
+ {
5181
+ // Presence of an IG that ends with an align instruction is misleading to the loop size calculation of
5182
+ // current loop, because the padding amount is not known when loop size is calculated.
5183
+ if (igInLoop->endsWithAlignInstr ())
5184
+ {
5185
+ alignCurrentLoop = false ;
5186
+ JITDUMP (" ** Skip alignment for current loop IG%02u ~ IG%02u because it has IG%02u that contains an align instruction for a different loop.\n " ,
5187
+ currLoopStart, currLoopEnd, igInLoop->igNum );
5188
+
5189
+ break ;
5190
+ }
5191
+ }
5178
5192
}
5179
5193
else if (currLoopStart == emitLastLoopStart)
5180
5194
{
@@ -5194,18 +5208,27 @@ void emitter::emitSetLoopBackEdge(BasicBlock* loopTopBlock)
5194
5208
// if current loop completely encloses last loop,
5195
5209
// then current loop should not be aligned.
5196
5210
alignCurrentLoop = false ;
5211
+ JITDUMP (" ** Skip alignment for current loop IG%02u ~ IG%02u because it encloses an aligned loop "
5212
+ " IG%02u ~ IG%02u.\n " ,
5213
+ currLoopStart, currLoopEnd, emitLastLoopStart, emitLastLoopEnd);
5197
5214
}
5198
5215
else if ((emitLastLoopStart < currLoopStart) && (currLoopEnd < emitLastLoopEnd))
5199
5216
{
5200
5217
// if last loop completely encloses current loop,
5201
5218
// then last loop should not be aligned.
5202
5219
alignLastLoop = false ;
5220
+ JITDUMP (" ** Skip alignment for aligned loop IG%02u ~ IG%02u because it encloses the current loop "
5221
+ " IG%02u ~ IG%02u.\n " ,
5222
+ emitLastLoopStart, emitLastLoopEnd, currLoopStart, currLoopEnd);
5203
5223
}
5204
5224
else
5205
5225
{
5206
5226
// The loops intersect and should not align either of the loops
5207
5227
alignLastLoop = false ;
5208
5228
alignCurrentLoop = false ;
5229
+ JITDUMP (" ** Skip alignment for aligned loop IG%02u ~ IG%02u that intersects with the current loop "
5230
+ " IG%02u ~ IG%02u.\n " ,
5231
+ emitLastLoopStart, emitLastLoopEnd, currLoopStart, currLoopEnd);
5209
5232
}
5210
5233
5211
5234
if (!alignLastLoop || !alignCurrentLoop)
@@ -5225,11 +5248,7 @@ void emitter::emitSetLoopBackEdge(BasicBlock* loopTopBlock)
5225
5248
5226
5249
// This IG should no longer contain alignment instruction
5227
5250
alignInstr->removeAlignFlags ();
5228
-
5229
5251
markedCurrLoop = true ;
5230
- JITDUMP (" ** Skip alignment for current loop IG%02u ~ IG%02u because it encloses an aligned loop "
5231
- " IG%02u ~ IG%02u.\n " ,
5232
- currLoopStart, currLoopEnd, emitLastLoopStart, emitLastLoopEnd);
5233
5252
}
5234
5253
5235
5254
// Find the IG that has 'align' instruction to align the last loop
@@ -5241,11 +5260,7 @@ void emitter::emitSetLoopBackEdge(BasicBlock* loopTopBlock)
5241
5260
5242
5261
// This IG should no longer contain alignment instruction
5243
5262
alignInstr->removeAlignFlags ();
5244
-
5245
5263
markedLastLoop = true ;
5246
- JITDUMP (" ** Skip alignment for aligned loop IG%02u ~ IG%02u because it encloses the current loop "
5247
- " IG%02u ~ IG%02u.\n " ,
5248
- emitLastLoopStart, emitLastLoopEnd, currLoopStart, currLoopEnd);
5249
5264
}
5250
5265
5251
5266
if (markedLastLoop && markedCurrLoop)
0 commit comments