-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Allow SIMD-returning calls as arguments #74184
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
BruceForstall
merged 2 commits into
dotnet:main
from
SingleAccretion:Simd-Calls-As-Args
Aug 24, 2022
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1419,7 +1419,7 @@ GenTree* Lowering::LowerFloatArg(GenTree** pArg, CallArg* callArg) | |
break; | ||
} | ||
GenTree* node = use.GetNode(); | ||
if (varTypeIsFloating(node)) | ||
if (varTypeUsesFloatReg(node)) | ||
{ | ||
GenTree* intNode = LowerFloatArgReg(node, currRegNumber); | ||
assert(intNode != nullptr); | ||
|
@@ -1441,7 +1441,7 @@ GenTree* Lowering::LowerFloatArg(GenTree** pArg, CallArg* callArg) | |
// List fields were replaced in place. | ||
return arg; | ||
} | ||
else if (varTypeIsFloating(arg)) | ||
else if (varTypeUsesFloatReg(arg)) | ||
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. Same here |
||
{ | ||
GenTree* intNode = LowerFloatArgReg(arg, callArg->AbiInfo.GetRegNum()); | ||
assert(intNode != nullptr); | ||
|
@@ -1464,11 +1464,13 @@ GenTree* Lowering::LowerFloatArg(GenTree** pArg, CallArg* callArg) | |
// | ||
GenTree* Lowering::LowerFloatArgReg(GenTree* arg, regNumber regNum) | ||
{ | ||
assert(varTypeUsesFloatReg(arg)); | ||
|
||
var_types floatType = arg->TypeGet(); | ||
assert(varTypeIsFloating(floatType)); | ||
var_types intType = (floatType == TYP_DOUBLE) ? TYP_LONG : TYP_INT; | ||
GenTree* intArg = comp->gtNewBitCastNode(intType, arg); | ||
var_types intType = (floatType == TYP_FLOAT) ? TYP_INT : TYP_LONG; | ||
SingleAccretion marked this conversation as resolved.
Show resolved
Hide resolved
|
||
GenTree* intArg = comp->gtNewBitCastNode(intType, arg); | ||
intArg->SetRegNum(regNum); | ||
|
||
#ifdef TARGET_ARM | ||
if (floatType == TYP_DOUBLE) | ||
{ | ||
|
@@ -3828,6 +3830,11 @@ void Lowering::LowerCallStruct(GenTreeCall* call) | |
assert(user->TypeIs(origType) || (returnType == user->TypeGet())); | ||
break; | ||
|
||
case GT_CALL: | ||
// Argument lowering will deal with register file mismatches if needed. | ||
assert(varTypeIsSIMD(origType)); | ||
break; | ||
|
||
Comment on lines
+3833
to
+3837
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. @BruceForstall it's this change that fixes the original failure. |
||
case GT_STOREIND: | ||
#ifdef FEATURE_SIMD | ||
if (varTypeIsSIMD(user)) | ||
|
82 changes: 82 additions & 0 deletions
82
src/tests/JIT/Regression/JitBlue/Runtime_74126/Runtime_74126.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,82 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Numerics; | ||
using System.Runtime.Intrinsics; | ||
using System.Runtime.CompilerServices; | ||
|
||
public class Runtime_74126 | ||
{ | ||
public static int Main() | ||
{ | ||
if (GetVtor(GetVtor2()) != GetVtor2()) | ||
{ | ||
return 101; | ||
} | ||
if (GetVtor(GetVtor3()) != GetVtor3()) | ||
{ | ||
return 102; | ||
} | ||
if (GetVtor(GetVtor4()) != GetVtor4()) | ||
{ | ||
return 103; | ||
} | ||
if (GetVtor(GetVtor64()) != GetVtor64()) | ||
{ | ||
return 104; | ||
} | ||
if (GetVtor(GetVtor128()) != GetVtor128()) | ||
{ | ||
return 105; | ||
} | ||
if (GetVtor(GetVtor256()) != GetVtor256()) | ||
{ | ||
return 106; | ||
} | ||
|
||
return 100; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static Vector2 GetVtor2() | ||
{ | ||
return new Vector2(1, 2); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static Vector3 GetVtor3() | ||
{ | ||
return new Vector3(1, 2, 3); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static Vector4 GetVtor4() | ||
{ | ||
return new Vector4(1, 2, 3, 4); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static Vector64<int> GetVtor64() | ||
{ | ||
return Vector64.Create(1, 2); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static Vector128<int> GetVtor128() | ||
{ | ||
return Vector128.Create(1, 2, 3, 4); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static Vector256<int> GetVtor256() | ||
{ | ||
return Vector256.Create(1, 2, 3, 4, 5, 6, 7, 8); | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.NoInlining)] | ||
private static T GetVtor<T>(T vtor) | ||
{ | ||
return vtor; | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/tests/JIT/Regression/JitBlue/Runtime_74126/Runtime_74126.csproj
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,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<Optimize>True</Optimize> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="$(MSBuildProjectName).cs" /> | ||
</ItemGroup> | ||
</Project> |
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.
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.
Should this be
varTypeUsesFloatArgReg()
? Effectively it's no difference, except for LoongArch64.Unrelated, but the code below seems odd:
I would expect the
TYPE_DOUBLE
== 2 registers code to only apply to arm32, but it's not ifdef'ed that way.Uh oh!
There was an error while loading. Please reload this page.
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.
Indeed, I thought the same but decided against
#ifdef
ing it in this change to keep the scope down.It so happens that we will never have
DOUBLE
here on ARM64 (which is the case of interest) because morph will construct theFIELD_LIST
withLONG
s. Looking what happens under Linux ARM soft FP, I see the same, so it seems likely that this code is actually dead.I'd think it's better with
varTypeUsesFloatReg
.varTypeUsesFloatArgReg
has the meaning of "can this type be used as an argument from an FP register file", while here we're asking the question of "does this node define an FP register".