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 NI_Vector128_AsVector128 (aka Vector128<T> AsVector128(this Vector<T> value)) doesn't have a side-effect in its assert #76460

Merged
merged 2 commits into from
Oct 2, 2022

Conversation

tannergooding
Copy link
Member

This resolves #76347

…ector<T> value)`) doesn't have a side-effect in its assert
@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 Sep 30, 2022
@ghost ghost assigned tannergooding Sep 30, 2022
@tannergooding
Copy link
Member Author

CC. @BruceForstall, @dotnet/jit-contrib

@ghost
Copy link

ghost commented Sep 30, 2022

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

Issue Details

This resolves #76347

Author: tannergooding
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@tannergooding
Copy link
Member Author

This bug also exists in .NET 6

Copy link
Member

@BruceForstall BruceForstall left a comment

Choose a reason for hiding this comment

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

Good find!

I suppose this could have been avoided by not re-using the simdSize argument as what is really a argumentSimdSize value. btw, simdSize isn't documented in the function header.

LGTM

@BruceForstall
Copy link
Member

(btw, this contributes to #76347, but doesn't fully resolve it. I have other changes to the test running infrastructure that will do the rest of the work)

@BruceForstall
Copy link
Member

@tannergooding Do you think this fix should be ported back to .NET 7? .NET 6? What kind of bad codegen implications are there with the unfixed code? Presumably Vector<T> v = ...; v.AsVector128(); could give incorrect results?

Does a complete fix also require some (or all) of #76456?

@tannergooding
Copy link
Member Author

tannergooding commented Oct 1, 2022

Does a complete fix also require some (or all) of #76456?

No. That's independent and just helps ensure codegen is better it shouldn't have any impact on the correctness of the codegen.

Do you think this fix should be ported back to .NET 7? .NET 6? What kind of bad codegen implications are there with the unfixed code? Presumably Vector v = ...; v.AsVector128(); could give incorrect results?

Its probably better to take it than not given its a 1 line fix putting it back inline with .NET Core 3.1 and .NET 5. That being said, I don't think users will see any negative side effects from us doing nothing...

The impact here is that on a system with AVX2 support (which I'd presume is a majority) a user calling vector.AsVector128 will get treated as a "nop" and the value will be consumed directly. Whether that's coming from memory or a register should be fine since the memory slot will be 32-bytes or we'll preserve the 32-bit register.

The potential negative would be if CSE or another optimization tries to look at this local and sees TYP_SIMD32 when it should see TYP_SIMD16. However, I'm not aware of any code that would be directly impacted by that...

@BruceForstall
Copy link
Member

The superpmi-replay failure looks like a timeout. We've had a few of those lately and need to investigate (separately).

@BruceForstall BruceForstall merged commit 144a33a into dotnet:main Oct 2, 2022
@tannergooding
Copy link
Member Author

@BruceForstall, should I go ahead and backport this to 7.0 and go through the approval process? What about 6.0?

@SingleAccretion or @EgorBo might have a better idea if there is potential CSE impact here.

@BruceForstall
Copy link
Member

I would suggest trying to get it in 7.0, since it is silent bad codegen. However, your description of the impact indicates there really is no impact, so that might not persuade the approvers.

@BruceForstall
Copy link
Member

One argument for porting it is it will (help) clean up our checked/release asm diffs testing on 7.0, so it could be argued it is a benefit to testing.

@tannergooding
Copy link
Member Author

/backport to release/7.0

@github-actions
Copy link
Contributor

github-actions bot commented Oct 3, 2022

Started backporting to release/7.0: https://github.com/dotnet/runtime/actions/runs/3175903125

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.

Failures in checked/release asm diffs
2 participants