-
Notifications
You must be signed in to change notification settings - Fork 5.4k
JIT: Handle edge cases around BlendVariableMask rewrite #126062
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
Merged
+193
−4
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f8fae7f
rewrite BlendVariableMask when mask is created from vector
saucecontrol a934fad
Merge branch 'main' into less-mask
tannergooding f7c1788
fix 127260
saucecontrol 17130ab
allow re-typing the blend
saucecontrol ae2c431
early return
saucecontrol 902ef7b
formatting
saucecontrol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
148 changes: 148 additions & 0 deletions
148
src/tests/JIT/Regression/JitBlue/Runtime_127260/Runtime_127260.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,148 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Runtime.CompilerServices; | ||
| using System.Runtime.Intrinsics; | ||
| using System.Runtime.Intrinsics.X86; | ||
| using Xunit; | ||
|
|
||
| public class Runtime_127260 | ||
| { | ||
| [ConditionalFact(typeof(Sse41), nameof(Sse41.IsSupported))] | ||
| public static void TestBlendVariable() | ||
| { | ||
| Assert.Equal(Vector128<float>.Zero, | ||
| BlendVariableSse41Single(Vector128.Create(-1.0f), Vector128<float>.Zero, Vector128.Create(-0.0f))); | ||
|
|
||
| Assert.Equal(Vector128<double>.Zero, | ||
| BlendVariableSse41Double(Vector128.Create(-1.0), Vector128<double>.Zero, Vector128.Create(-0.0))); | ||
|
|
||
| Assert.Equal(Vector128<sbyte>.Zero, | ||
| BlendVariableSse41Int8(Vector128.Create<sbyte>(-1), Vector128<sbyte>.Zero, Vector128.Create(sbyte.MinValue))); | ||
|
|
||
| Assert.Equal(Vector128.Create<short>(0x00FF), | ||
| BlendVariableSse41Int16(Vector128.Create<short>(-1), Vector128<short>.Zero, Vector128.Create(short.MinValue))); | ||
|
|
||
| Assert.Equal(Vector128.Create<int>(0x00FFFFFF), | ||
| BlendVariableSse41Int32(Vector128.Create<int>(-1), Vector128<int>.Zero, Vector128.Create(int.MinValue))); | ||
|
|
||
| Assert.Equal(Vector128.Create<long>(0x00FFFFFF_FFFFFFFF), | ||
| BlendVariableSse41Int64(Vector128.Create<long>(-1), Vector128<long>.Zero, Vector128.Create(long.MinValue))); | ||
| } | ||
|
|
||
| [ConditionalFact(typeof(Avx512BW.VL), nameof(Avx512BW.VL.IsSupported))] | ||
| public static void TestBlendVariableMask() | ||
| { | ||
| Assert.Equal(Vector128<float>.Zero, | ||
| BlendVariableAvx512Single(Vector128.Create(-1.0f), Vector128<float>.Zero, Vector128.Create(-0.0f))); | ||
|
|
||
| Assert.Equal(Vector128<double>.Zero, | ||
| BlendVariableAvx512Double(Vector128.Create(-1.0), Vector128<double>.Zero, Vector128.Create(-0.0))); | ||
|
|
||
| Assert.Equal(Vector128<sbyte>.Zero, | ||
| BlendVariableAvx512Int8(Vector128.Create<sbyte>(-1), Vector128<sbyte>.Zero, Vector128.Create(sbyte.MinValue))); | ||
|
|
||
| Assert.Equal(Vector128<short>.Zero, | ||
| BlendVariableAvx512Int16(Vector128.Create<short>(-1), Vector128<short>.Zero, Vector128.Create(short.MinValue))); | ||
|
|
||
| Assert.Equal(Vector128<int>.Zero, | ||
| BlendVariableAvx512Int32(Vector128.Create<int>(-1), Vector128<int>.Zero, Vector128.Create(int.MinValue))); | ||
|
|
||
| Assert.Equal(Vector128<long>.Zero, | ||
| BlendVariableAvx512Int64(Vector128.Create<long>(-1), Vector128<long>.Zero, Vector128.Create(long.MinValue))); | ||
| } | ||
|
|
||
| [ConditionalFact(typeof(Avx512BW.VL), nameof(Avx512BW.VL.IsSupported))] | ||
| public static void TestContainableMask() | ||
| { | ||
| Assert.Equal(Vector128<float>.Zero, | ||
| AddToNegativeSingle(Vector128.Create(-1.0f), Vector128<float>.One)); | ||
|
|
||
| Assert.Equal(Vector128<double>.Zero, | ||
| AddToNegativeDouble(Vector128.Create(-1.0), Vector128<double>.One)); | ||
|
|
||
| Assert.Equal(Vector128<sbyte>.Zero, | ||
| AddToNegativeInt8(Vector128.Create<sbyte>(-1), Vector128<sbyte>.One)); | ||
|
|
||
| Assert.Equal(Vector128<short>.Zero, | ||
| AddToNegativeInt16(Vector128.Create<short>(-1), Vector128<short>.One)); | ||
|
|
||
| Assert.Equal(Vector128<int>.Zero, | ||
| AddToNegativeInt32(Vector128.Create<int>(-1), Vector128<int>.One)); | ||
|
|
||
| Assert.Equal(Vector128<long>.Zero, | ||
| AddToNegativeInt64(Vector128.Create<long>(-1), Vector128<long>.One)); | ||
| } | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| static Vector128<float> BlendVariableSse41Single(Vector128<float> left, Vector128<float> right, Vector128<float> mask) | ||
| => Sse41.BlendVariable(left, right, mask); | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| static Vector128<double> BlendVariableSse41Double(Vector128<double> left, Vector128<double> right, Vector128<double> mask) | ||
| => Sse41.BlendVariable(left, right, mask); | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| static Vector128<sbyte> BlendVariableSse41Int8(Vector128<sbyte> left, Vector128<sbyte> right, Vector128<sbyte> mask) | ||
| => Sse41.BlendVariable(left, right, mask); | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| static Vector128<short> BlendVariableSse41Int16(Vector128<short> left, Vector128<short> right, Vector128<short> mask) | ||
| => Sse41.BlendVariable(left, right, mask); | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| static Vector128<int> BlendVariableSse41Int32(Vector128<int> left, Vector128<int> right, Vector128<int> mask) | ||
| => Sse41.BlendVariable(left, right, mask); | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| static Vector128<long> BlendVariableSse41Int64(Vector128<long> left, Vector128<long> right, Vector128<long> mask) | ||
| => Sse41.BlendVariable(left, right, mask); | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| static Vector128<float> BlendVariableAvx512Single(Vector128<float> left, Vector128<float> right, Vector128<float> mask) | ||
| => Avx512F.VL.BlendVariable(left, right, mask); | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| static Vector128<double> BlendVariableAvx512Double(Vector128<double> left, Vector128<double> right, Vector128<double> mask) | ||
| => Avx512F.VL.BlendVariable(left, right, mask); | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| static Vector128<sbyte> BlendVariableAvx512Int8(Vector128<sbyte> left, Vector128<sbyte> right, Vector128<sbyte> mask) | ||
| => Avx512BW.VL.BlendVariable(left, right, mask); | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| static Vector128<short> BlendVariableAvx512Int16(Vector128<short> left, Vector128<short> right, Vector128<short> mask) | ||
| => Avx512BW.VL.BlendVariable(left, right, mask); | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| static Vector128<int> BlendVariableAvx512Int32(Vector128<int> left, Vector128<int> right, Vector128<int> mask) | ||
| => Avx512F.VL.BlendVariable(left, right, mask); | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| static Vector128<long> BlendVariableAvx512Int64(Vector128<long> left, Vector128<long> right, Vector128<long> mask) | ||
| => Avx512F.VL.BlendVariable(left, right, mask); | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| static Vector128<float> AddToNegativeSingle(Vector128<float> left, Vector128<float> right) | ||
| => Sse41.BlendVariable(left, left + right, left); | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| static Vector128<double> AddToNegativeDouble(Vector128<double> left, Vector128<double> right) | ||
| => Sse41.BlendVariable(left, left + right, left); | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| static Vector128<sbyte> AddToNegativeInt8(Vector128<sbyte> left, Vector128<sbyte> right) | ||
| => Sse41.BlendVariable(left, left + right, left); | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| static Vector128<short> AddToNegativeInt16(Vector128<short> left, Vector128<short> right) | ||
| => Avx512BW.VL.BlendVariable(left, left + right, left); | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| static Vector128<int> AddToNegativeInt32(Vector128<int> left, Vector128<int> right) | ||
| => Avx512F.VL.BlendVariable(left, left + right, left); | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| static Vector128<long> AddToNegativeInt64(Vector128<long> left, Vector128<long> right) | ||
| => Avx512F.VL.BlendVariable(left, left + right, left); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.