Skip to content

Commit

Permalink
Arm64: Use TYP_SIMD8 for AddAcross (#108727)
Browse files Browse the repository at this point in the history
* Use TYP_SIMD8 for AddAcross intrinsics

* add test cases

* Mark non interesting method private

* Remove method params

* wrap test code in try-catch
  • Loading branch information
kunalspathak authored Oct 11, 2024
1 parent 64b9ece commit 6fa2f17
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25602,7 +25602,7 @@ GenTree* Compiler::gtNewSimdSumNode(var_types type, GenTree* op1, CorInfoType si
case TYP_SHORT:
case TYP_USHORT:
{
tmp = gtNewSimdHWIntrinsicNode(simdType, op1, NI_AdvSimd_Arm64_AddAcross, simdBaseJitType, simdSize);
tmp = gtNewSimdHWIntrinsicNode(TYP_SIMD8, op1, NI_AdvSimd_Arm64_AddAcross, simdBaseJitType, simdSize);
return gtNewSimdToScalarNode(type, tmp, simdBaseJitType, 8);
}

Expand All @@ -25616,7 +25616,7 @@ GenTree* Compiler::gtNewSimdSumNode(var_types type, GenTree* op1, CorInfoType si
}
else
{
tmp = gtNewSimdHWIntrinsicNode(TYP_SIMD16, op1, NI_AdvSimd_Arm64_AddAcross, simdBaseJitType, 16);
tmp = gtNewSimdHWIntrinsicNode(TYP_SIMD8, op1, NI_AdvSimd_Arm64_AddAcross, simdBaseJitType, 16);
}
return gtNewSimdToScalarNode(type, tmp, simdBaseJitType, 8);
}
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/lowerarmarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2611,7 +2611,7 @@ GenTree* Lowering::LowerHWIntrinsicDot(GenTreeHWIntrinsic* node)
// ...

tmp2 =
comp->gtNewSimdHWIntrinsicNode(simdType, tmp1, NI_AdvSimd_Arm64_AddAcross, simdBaseJitType, simdSize);
comp->gtNewSimdHWIntrinsicNode(TYP_SIMD8, tmp1, NI_AdvSimd_Arm64_AddAcross, simdBaseJitType, simdSize);
BlockRange().InsertAfter(tmp1, tmp2);
LowerNode(tmp2);
}
Expand Down
58 changes: 58 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_108612/Runtime_108612.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// Found by Antigen
// Reduced from 18.05 KB to 1.2 KB.
// JIT assert failed:
// Assertion failed 'm_store->TypeGet() == m_src->TypeGet()' in 'TestClass:Method0():this' during 'Assertion prop' (IL size 91; hash 0x46e9aa75; FullOpts)
//
// File: /Users/runner/work/1/s/src/coreclr/jit/morphblock.cpp Line: 665


using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;
using System.Runtime.Intrinsics.X86;
using System.Numerics;
using Xunit;

public class Runtime_108612
{
static Vector128<byte> s_v128_byte_27 = Vector128.CreateScalar((byte)0);
static Vector128<int> s_v128_int_31 = Vector128<int>.Zero;
static Vector128<uint> s_v128_uint_32 = Vector128.CreateScalar((uint)5);
Vector64<byte> v64_byte_67 = Vector64.CreateScalar((byte)5);
Vector128<int> v128_int_81 = Vector128.Create(-1, 6, 2, 1);
private static List<string> toPrint = new List<string>();
private void Method0()
{
unchecked
{
v128_int_81 = AdvSimd.NegateSaturate(s_v128_int_31 *= 15|4);
s_v128_uint_32 = AdvSimd.ShiftRightLogicalRounded(s_v128_uint_32, Vector128.Sum(s_v128_byte_27 | s_v128_byte_27));
v64_byte_67 = AdvSimd.Arm64.AddAcross(s_v128_byte_27 | s_v128_byte_27);
return;
}
}

[Fact]
public static void TestEntryPoint()
{
if (AdvSimd.IsSupported)
{
Antigen();
}
}

private static int Antigen()
{
try
{
new Runtime_108612().Method0();
}
catch (Exception e) { }
return string.Join(Environment.NewLine, toPrint).GetHashCode();
}
}
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>

0 comments on commit 6fa2f17

Please sign in to comment.