-
Notifications
You must be signed in to change notification settings - Fork 5k
Vector256.Shuffle() produces bad results in release mode #86432
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
Comments
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsDescriptionRun the following code with release and debug configuration, it will give different outputs: ** Correct **
** Wrong **
Note that the last 4 elements are getting what appear to be random values. Repeated runs get different values. Reproduction StepsRun:
In release and debug mode. Expected behaviorShould generate the same output in both cases Actual behaviorWrong output Regression?No response Known WorkaroundsNo response Configurationdotnet --version Tested on x64 Windows machine. Other informationNo response
|
7.0.400-preview.23225.8 (Debug): vmovupd ymm0, ymmword ptr[reloc @RWD00]
vmovupd ymm1, ymmword ptr[reloc @RWD32]
vpermd ymm1,ymm1,ymmword ptr [rcx]
vpand ymm1,ymm0,ymm1
vxorps ymm2,ymm2,ymm2
vpandn ymm0,ymm0,ymm2
vpor ymm6,ymm1,ymm0
vextractf128 xmm7,ymm6,1
vinsertf128 ymm6,ymm6,xmm7,1
vmovupd ymmword ptr [rax+8],ymm6 7.0.400-preview.23225.8 (Release): vmovupd ymm0, ymmword ptr[reloc @RWD00]
vmovupd ymm1, ymmword ptr[reloc @RWD32]
vpermd ymm1,ymm1,ymmword ptr [rcx]
vpand ymm1,ymm0,ymm1
vxorps ymm2,ymm2,ymm2
vpandn ymm0,ymm0,ymm2
vpor ymm0,ymm1,ymm0
vmovupd ymmword ptr [rax+8],ymm0 8.0.100-preview.4.23260.5 (Debug/Release): vmovups ymm0, ymmword ptr [reloc @RWD00]
vpermd ymm0, ymm0, ymmword ptr [rax]
vpand ymm0, ymm0, ymmword ptr [reloc @RWD32]
vmovups ymmword ptr [rcx], ymm0 |
@EgorBo Annotating method containing the code above with [MethodImpl(MethodImplOptions.NoInlining)]
private static Vector256<uint> Sh()
{
Span<uint> a = stackalloc uint[8] { 0, 21, 2063, 2066, 3095, 0, 0, 0 };
var d = Vector256.Shuffle(
Vector256.LoadUnsafe(ref a[0]),
Vector256.Create(8u, 0, 1, 2, 3, 4, 5, 6)
);
return d;
} |
The problem that Vector256.Shuffle emits an unnecessary |
As long as we are talking about it, I was expecting that it would do something like:
Translated into:
|
This is a duplicate of #85132 There was a relatively simple issue with the codegen for out of bounds indices that needs to be backported to .NET 7 (we were only copying the lower 128-bits of the zeroing mask)
The
There are a few optimizations for |
why? the indexes are compile-time known, aren't they? |
Because out of bounds indices are documented as zeroing the corresponding result element; the underlying permute instruction doesn't do any zeroing, that's only the behavior of |
My intent was to actually do just that, zero the unimportant elements, by the way |
Uh oh!
There was an error while loading. Please reload this page.
Description
Run the following code with release and debug configuration, it will give different outputs:
Correct
Wrong
Note that the last 4 elements are getting what appear to be random values. Repeated runs get different values.
Reproduction Steps
Run:
In release and debug mode.
Expected behavior
Should generate the same output in both cases
Actual behavior
Wrong output
Regression?
No response
Known Workarounds
No response
Configuration
dotnet --version
7.0.203
Tested on x64 Windows machine.
Other information
No response
The text was updated successfully, but these errors were encountered: