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

ARM64-SVE: Avoid containing non-embedded conditional select #105719 #105812

Merged
merged 8 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions eng/pipelines/coreclr/jitstress-isas-sve.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ pr:
- main
paths:
include:
- src/coreclr/jit/codegenarmarch.cpp
- src/coreclr/jit/emitarm64sve.cpp
- src/coreclr/jit/emitfmtsarm64sve.h
- src/coreclr/jit/hwintrinsicarm64.cpp
- src/coreclr/jit/hwintrinsiccodegenarm64.cpp
- src/coreclr/jit/hwintrinsiclistarm64sve.h
- src/coreclr/jit/hwintrinsicarm64.cpp
- src/coreclr/jit/instrsarm64sve.h
- src/coreclr/jit/emitarm64sve.cpp
- src/coreclr/jit/emitfmtsarm64sve.h
- src/coreclr/jit/lowerarmarch.cpp
Copy link
Member

Choose a reason for hiding this comment

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

can you also add entries for following?

  • lsraarmarch.cpp
  • codegenarmarch.cpp

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.
Also alphabetically ordered the list.

- src/coreclr/jit/lsraarmarch.cpp
- src/coreclr/jit/lsraarm64.cpp

schedules:
Expand Down
46 changes: 44 additions & 2 deletions src/coreclr/jit/lowerarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4035,7 +4035,7 @@ GenTree* Lowering::LowerHWIntrinsicCndSel(GenTreeHWIntrinsic* cndSelNode)
GenTree* nestedOp2 = nestedCndSel->Op(2);
GenTree* nestedOp3 = nestedCndSel->Op(3);

JITDUMP("lowering ConditionalSelect HWIntrinisic (before):\n");
JITDUMP("lowering nested ConditionalSelect HWIntrinisic (before):\n");
DISPTREERANGE(BlockRange(), cndSelNode);
JITDUMP("\n");

Expand All @@ -4057,13 +4057,55 @@ GenTree* Lowering::LowerHWIntrinsicCndSel(GenTreeHWIntrinsic* cndSelNode)
BlockRange().Remove(nestedOp1);
BlockRange().Remove(nestedCndSel);

JITDUMP("lowering ConditionalSelect HWIntrinisic (after):\n");
JITDUMP("lowering nested ConditionalSelect HWIntrinisic (after):\n");
DISPTREERANGE(BlockRange(), cndSelNode);
JITDUMP("\n");

return cndSelNode;
}
}
else if (op1->IsMaskAllBitsSet())
{
// Any case where op2 is not an embedded HWIntrinsic
if (!op2->OperIsHWIntrinsic() ||
!HWIntrinsicInfo::IsEmbeddedMaskedOperation(op2->AsHWIntrinsic()->GetHWIntrinsicId()))
{
JITDUMP("lowering ConditionalSelect HWIntrinisic (before):\n");
DISPTREERANGE(BlockRange(), cndSelNode);
JITDUMP("\n");

// Transform
// CndSel(AllTrue, op2, op3) to
// op2

LIR::Use use;
if (BlockRange().TryGetUse(cndSelNode, &use))
{
use.ReplaceWith(op2);
}
else
{
op2->SetUnusedValue();
}

if (op3->IsMaskZero())
{
BlockRange().Remove(op3);
}
else
{
op3->SetUnusedValue();
}
op1->SetUnusedValue();
BlockRange().Remove(cndSelNode);

JITDUMP("lowering ConditionalSelect HWIntrinisic (after):\n");
DISPTREERANGE(BlockRange(), op2);
JITDUMP("\n");

return op2;
}
}

ContainCheckHWIntrinsic(cndSelNode);
return cndSelNode->gtNext;
Expand Down
31 changes: 31 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_105719/Runtime_105719.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using Xunit;
using System;
using System.Runtime.CompilerServices;
using System.Numerics;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;

public class Runtime_105723
{
[Fact]
public static void TestEntryPoint()
{
if (Sve.IsSupported)
{
var vr3 = Sve.CreateTrueMaskInt32();
var vr4 = Vector.Create<int>(1);
var vr5 = Vector128.CreateScalar(0).AsVector();
Vector<int> vr6 = Sve.ConditionalSelect(vr3, vr4, vr5);
Consume(vr6);
}
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static void Consume(Vector<int> v)
{
;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Optimize>True</Optimize>
<NoWarn>$(NoWarn);SYSLIB5003</NoWarn>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>
Loading