Skip to content

Do not over-align code when JitAlignLoops=0 is set #107340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 6, 2024
Merged
Changes from all commits
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
8 changes: 3 additions & 5 deletions src/coreclr/jit/emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6773,12 +6773,10 @@ unsigned emitter::emitEndCodeGen(Compiler* comp,
#endif

#if defined(TARGET_XARCH) || defined(TARGET_ARM64)
// For x64/x86/arm64, align methods that are "optimizations enabled" to 32 byte boundaries if
// they are larger than 16 bytes and contain a loop.
// For x64/x86/arm64, align methods that contain a loop to 32 byte boundaries if
// they are larger than 16 bytes and loop alignment is enabled.
//
if (emitComp->opts.OptimizationEnabled() &&
(!emitComp->opts.jitFlags->IsSet(JitFlags::JIT_FLAG_PREJIT) || comp->IsTargetAbi(CORINFO_NATIVEAOT_ABI)) &&
(emitTotalHotCodeSize > 16) && emitComp->fgHasLoops)
if (codeGen->ShouldAlignLoops() && (emitTotalHotCodeSize > 16) && emitComp->fgHasLoops)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also set JitAlignLoops to false if we are optimizing for size and hence, here we will also adjust the method alignment to 8 bytes instead of 32 bytes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d say yes. I wanted to unblock my testing first which is why I submitted this separately.

{
codeAlignment = 32;
}
Expand Down
Loading