-
Notifications
You must be signed in to change notification settings - Fork 5.3k
JIT: Fix EvalHWIntrinsicFunBinary for ARM MultiplyByScalar
#94413
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
Changes from 4 commits
63fdc8c
2170ec2
134204d
2483e6e
74b2688
2d2d2a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| // 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.Numerics; | ||
| using Xunit; | ||
|
|
||
| public static class Runtime_93876 | ||
| { | ||
| [Fact] | ||
| public static void Problem() | ||
| { | ||
| Vector4 v = Mul(0, 1); | ||
| Assert.Equal(Vector4.One, v); | ||
| Vector64<float> v64 = Mul64(0, 1); | ||
| Assert.Equal(Vector64<float>.One, v64); | ||
| } | ||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| private static Vector4 Mul(float a, float b) => Vector4.Multiply(a + b, Vector4.One); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the type of
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
[000005] ----------- ▌ HWINTRINSIC simd16 float MultiplyByScalar
[000003] ----------- ├──▌ CNS_VEC simd16<0x3f800000, 0x3f800000, 0x3f800000, 0x3f800000>
[000004] ----------- └──▌ HWINTRINSIC simd8 float CreateScalarUnsafe
[000002] ----------- └──▌ ADD float
[000000] ----------- ├──▌ LCL_VAR float V00 arg0
[000001] ----------- └──▌ LCL_VAR float V01 arg1
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I think
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I pushed a change that handles |
||
|
|
||
| [MethodImpl(MethodImplOptions.NoInlining)] | ||
| private static Vector64<float> Mul64(float a, float b) => Vector64.Multiply(a + b, Vector64<float>.One); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
| <PropertyGroup> | ||
| <Optimize>True</Optimize> | ||
| </PropertyGroup> | ||
| <ItemGroup> | ||
| <Compile Include="$(MSBuildProjectName).cs" /> | ||
| </ItemGroup> | ||
| </Project> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this actually be hit given that we expect
TYP_SIMD8for the second operand?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question... let me add some strong asserts and simplify this a bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the same path down in the regular multiply handling is also "dead". It was likely intended to handle the
vector * scalarcase, but we don't actually ever produce aGT_HWINTRINSIC(TYP_SIMD, TYP_SCALAR)node anymore, afaict.We appear to always normalize to
Broadcaston x86/x64. We similarly normalize toBroadcastonArm64except for when aMultiplyByScalarvariant exists, in which case we always insertCreateScalarUnsafe.I then don't see any overloads of the instructions that would take a proper scalar register, so I don't think we'd ever hit it in practice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense... probably something to clean up separately at some point in the future.