Skip to content

Commit

Permalink
ARM64-SVE: Avoid containing non-embedded conditional select dotnet#10…
Browse files Browse the repository at this point in the history
  • Loading branch information
a74nh committed Aug 8, 2024
1 parent dbdfabf commit da757a1
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 5 deletions.
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
- 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 @@ -4050,7 +4050,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 @@ -4072,13 +4072,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>

0 comments on commit da757a1

Please sign in to comment.