Skip to content

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

Merged
kunalspathak merged 1 commit intodotnet:mainfrom
filipnavara:loop-align-code-align
Sep 6, 2024
Merged

Do not over-align code when JitAlignLoops=0 is set#107340
kunalspathak merged 1 commit intodotnet:mainfrom
filipnavara:loop-align-code-align

Conversation

@filipnavara
Copy link
Member

Simplify the condition for alignment of methods with loop. The check for optimizations, R2R and NativeAOT already guards the SetAlignLoops code path, so there's no need to repeat it. Additionally, explicitly disabling loop alignment with JitAlignLoops=0 should disable the extra method alignment.

@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Sep 4, 2024
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Sep 4, 2024
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

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
Contributor

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.

Copy link
Contributor

@kunalspathak kunalspathak left a comment

Choose a reason for hiding this comment

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

LGTM

@kunalspathak kunalspathak merged commit d1ecd63 into dotnet:main Sep 6, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Oct 7, 2024
@filipnavara filipnavara deleted the loop-align-code-align branch June 5, 2025 07:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants