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

Ensure that we don't try to constant fold BSF(0) or BSR(0) #81516

Merged
merged 4 commits into from
Feb 2, 2023

Conversation

tannergooding
Copy link
Member

@tannergooding tannergooding commented Feb 2, 2023

This resolves #81460

Even with the qmark (x == 0) ? 31 : BSR(x), we'd end up getting something like:

lcl = 0;
if (lcl == 0)
   return 31;
return BSR(lcl);

So even though the BSF(0)/BSR(0) is dead code, we don't know it yet and it leads to VN trying to fold and therefore triggering the assert.

The fix is to simply bail out if the constant is zero.

@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 Feb 2, 2023
@ghost ghost assigned tannergooding Feb 2, 2023
@ghost
Copy link

ghost commented Feb 2, 2023

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

Issue Details

This resolves #81460

Even with the qmark, we'd end up getting something like:

lcl = 0;
if (lcl == 0)
   return 31;
return BSR(lcl);

So even though the BSF(0)/BSR(0) is dead code, we don't know it yet and it leads to VN trying to fold and therefore triggering the assert.

The fix is to simply bail out if the constant is zero.

Author: tannergooding
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@tannergooding
Copy link
Member Author

There is potentially something here to be handled in the future in that we are doing VN on things which are "dead".

If we had some minimal early constant propagation or similar, we could avoid doing VN/CSE/folding or other potentially expensive things for code that will just be dropped in one of the next few phases.

@tannergooding
Copy link
Member Author

Brought in latest main to pickup the CI fix

@tannergooding tannergooding merged commit 4354abd into dotnet:main Feb 2, 2023
@tannergooding tannergooding deleted the fix-81460 branch February 2, 2023 05:46
@ghost ghost locked as resolved and limited conversation to collaborators Mar 4, 2023
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
2 participants