Skip to content

JIT: fix loop alignment issue - #70936

Merged
AndyAyersMS merged 1 commit into
dotnet:mainfrom
AndyAyersMS:Fix70152
Jun 21, 2022
Merged

AndyAyersMS merged 1 commit into
dotnet:mainfrom
AndyAyersMS:Fix70152

Conversation

@AndyAyersMS

Copy link
Copy Markdown
Member

When scanning to figure out which blocks should have alignment padding, we can
sometimes encounter a block in a loop before we see the block at the top of the
loop.. If so, remove alignment for that loop, otherwise the emitter code
handling alignment gets tripped up. Even if the emitter could handle this case,
it would be padding with the loop, not before it.

The problematic block reordering is done much earlier. At some point we need to
revisit this as it is making nonsensical ordering decisions. But we'll tolerate
it for now.

Fixes #70152.

When scanning to figure out which blocks should have alignment padding, we can
sometimes encounter a block in a loop before we see the block at the top of the
loop.. If so, remove alignment for that loop, otherwise the emitter code
handling alignment gets tripped up. Even if the emitter could handle this case,
it would be padding with the loop, not before it.

The problematic block reordering is done much earlier. At some point we need to
revisit this as it is making nonsensical ordering decisions. But we'll tolerate
it for now.

Fixes dotnet#70152.
@ghost ghost added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 18, 2022
@ghost ghost assigned AndyAyersMS Jun 18, 2022
@ghost

ghost commented Jun 18, 2022

Copy link
Copy Markdown

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

Issue Details

When scanning to figure out which blocks should have alignment padding, we can
sometimes encounter a block in a loop before we see the block at the top of the
loop.. If so, remove alignment for that loop, otherwise the emitter code
handling alignment gets tripped up. Even if the emitter could handle this case,
it would be padding with the loop, not before it.

The problematic block reordering is done much earlier. At some point we need to
revisit this as it is making nonsensical ordering decisions. But we'll tolerate
it for now.

Fixes #70152.

Author: AndyAyersMS
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@AndyAyersMS

Copy link
Copy Markdown
Member Author

@kunalspathak PTAL
cc @dotnet/jit-contrib

No diffs expected (test case came from pgo stress).

@kunalspathak

Copy link
Copy Markdown
Contributor

Do you mind sharing the problematic JITDUMP, just that I can see with an example?

@kunalspathak kunalspathak left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Changes LGTM

@AndyAyersMS

Copy link
Copy Markdown
Member Author

Do you mind sharing the problematic JITDUMP, just that I can see with an example?

It is too big to share via gist. I'll send it to you privately.

@AndyAyersMS
AndyAyersMS merged commit 95138dd into dotnet:main Jun 21, 2022
@kunalspathak

Copy link
Copy Markdown
Contributor

I'll send it to you privately.

Thanks, I see the problem that this PR will fix.

BB133 [0285]  2       BB132,BB134         320.26    15693    [2A0..2A1)-> BB137 ( cond )                     i bwd IBC LIR 
BB136 [0288]  1       BB133               316.15    15491  6 [2A0..2A1)-> BB137 ( cond )                     i bwd bwd-src IBC LIR 
BB134 [0286]  1       BB136               316.15    15491  6 [2A0..2A1)-> BB133 (always)                     i Loop Loop0 bwd bwd-target IBC LIR align 

...
Marking BB136 before the loop with BBF_HAS_ALIGN for loop at BB134

@AndyAyersMS

Copy link
Copy Markdown
Member Author

Should have mentioned that there was similar info over on the issue. But yeah, the loop blocks are out of order.

@ghost ghost locked as resolved and limited conversation to collaborators Jul 21, 2022
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[libraries-pgo] Assertion failed '(igInLoop->igLoopBackEdge == nullptr) || (igInLoop->igLoopBackEdge == igLoopHeader)' during 'Generate code'

2 participants