Skip to content
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

JIT: Avoid introducing GT_NULLCHECK in gtTryRemoveBoxUpstreamEffects #71439

Merged
merged 1 commit into from
Jun 30, 2022

Conversation

jakobbotsch
Copy link
Member

Adding GT_NULLCHECK nodes requires knowledge of which basic block the
nullcheck will end up in. We do not have this easily available in all
places this method is called, and regardless using GT_NULLCHECK here has
minimal diffs.

Alternative we could store the BasicBlock together with GenTreeBox::gtCopyStmtWhenInlinedBoxValue,
but the diffs here are so small that I didn't bother.

Fix #71193

Also an unrelated comment clean-up that I have noticed while looking at early prop (we do not do this optimization here anymore).

Adding GT_NULLCHECK nodes requires knowledge of which basic block the
nullcheck will end up in. We do not have this easily available in all
places this method is called, and regardless using GT_NULLCHECK here has
minimal diffs.

Fix dotnet#71193
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Jun 29, 2022
@ghost ghost assigned jakobbotsch Jun 29, 2022
@ghost
Copy link

ghost commented Jun 29, 2022

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

Issue Details

Adding GT_NULLCHECK nodes requires knowledge of which basic block the
nullcheck will end up in. We do not have this easily available in all
places this method is called, and regardless using GT_NULLCHECK here has
minimal diffs.

Alternative we could store the BasicBlock together with GenTreeBox::gtCopyStmtWhenInlinedBoxValue,
but the diffs here are so small that I didn't bother.

Fix #71193

Also an unrelated comment clean-up that I have noticed while looking at early prop (we do not do this optimization here anymore).

Author: jakobbotsch
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@jakobbotsch
Copy link
Member Author

cc @dotnet/jit-contrib PTAL @AndyAyersMS

@jakobbotsch jakobbotsch requested a review from AndyAyersMS June 29, 2022 19:11
Copy link
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

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

This is reverting the code back to how I originally wrote it long ago.

Won't we now miss early folding opportunities because we may not see OMF_HAS_NULLCHECK and/or BBF_HAS_NULLCHECK in early prop?

@jakobbotsch
Copy link
Member Author

Won't we now miss early folding opportunities because we may not see OMF_HAS_NULLCHECK and/or BBF_HAS_NULLCHECK in early prop?

Yes, there are a handful of missed opportunities in the diffs, but it is minimal.
FWIW, the function is trying to put BBF_HAS_NULLCHECK on compCurBB which is incorrect when it is used during inlining (global variables strike again...).
Correct marking here requires us to store the BasicBlock in GenTreeBox. But as you can see from the diffs it is not very impactful.

This whole area could do with some unifying. gtTryRemoveBoxUpstreamEffects and gtExtractSideEffList both convert struct indirs into GT_NULLCHECK but leave primitive indirs alone. Top-level indirs are also always just left alone. Leaving primitive indirs alone probably benefits CSE, but this already constitutes lots of missed opportunities in early prop. As I have mentioned offline I think we would be better served with removing GT_NULLCHECK, at least until lowering, and then supporting folding the unused indirs in early prop.

Copy link
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

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

I'm fine with the direction you want to head in -- we should also decide if all this opportunity flagging we use to gate early prop is worth the trouble.

@jakobbotsch
Copy link
Member Author

we should also decide if all this opportunity flagging we use to gate early prop is worth the trouble

Yes, this part is also unfortunate. At the very least we could probably use one of the full IR walks that are happening just prior to SSA to mark this information so that we don't need to keep it up to date all the time.

@jakobbotsch jakobbotsch merged commit 9e703be into dotnet:main Jun 30, 2022
@jakobbotsch jakobbotsch deleted the fix-71193 branch June 30, 2022 09:43
@ghost ghost locked as resolved and limited conversation to collaborators Jul 30, 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.

JIT: BBF_HAS_NULLCHECK is not set on BB but is required
2 participants