Skip to content

Commit 2205729

Browse files
mikabl-armpull[bot]
authored andcommitted
JIT ARM64-SVE: Add Compact API (#102992)
* JIT ARM64-SVE: Add Compact API * Cleanup: replace tabs with spaces and change array type in the template
1 parent 05bd581 commit 2205729

File tree

8 files changed

+228
-4
lines changed

8 files changed

+228
-4
lines changed

src/coreclr/jit/hwintrinsiccodegenarm64.cpp

+11-4
Original file line numberDiff line numberDiff line change
@@ -808,10 +808,17 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node)
808808
else if (HWIntrinsicInfo::IsScalable(intrin.id))
809809
{
810810
assert(!node->IsEmbMaskOp());
811-
// This generates an unpredicated version
812-
// Predicated should be taken care above `intrin.op2->IsEmbMaskOp()`
813-
GetEmitter()->emitIns_R_R_R(ins, emitSize, targetReg, op1Reg, op2Reg, opt,
814-
INS_SCALABLE_OPTS_UNPREDICATED);
811+
if (HWIntrinsicInfo::IsExplicitMaskedOperation(intrin.id))
812+
{
813+
GetEmitter()->emitIns_R_R_R(ins, emitSize, targetReg, op1Reg, op2Reg, opt);
814+
}
815+
else
816+
{
817+
// This generates an unpredicated version
818+
// Implicitly predicated should be taken care above `intrin.op2->IsEmbMaskOp()`
819+
GetEmitter()->emitIns_R_R_R(ins, emitSize, targetReg, op1Reg, op2Reg, opt,
820+
INS_SCALABLE_OPTS_UNPREDICATED);
821+
}
815822
}
816823
else if (isRMW)
817824
{

src/coreclr/jit/hwintrinsiclistarm64sve.h

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ HARDWARE_INTRINSIC(Sve, And,
2626
HARDWARE_INTRINSIC(Sve, AndAcross, -1, -1, false, {INS_sve_andv, INS_sve_andv, INS_sve_andv, INS_sve_andv, INS_sve_andv, INS_sve_andv, INS_sve_andv, INS_sve_andv, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation|HW_Flag_LowMaskedOperation)
2727
HARDWARE_INTRINSIC(Sve, BitwiseClear, -1, -1, false, {INS_sve_bic, INS_sve_bic, INS_sve_bic, INS_sve_bic, INS_sve_bic, INS_sve_bic, INS_sve_bic, INS_sve_bic, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_OptionalEmbeddedMaskedOperation|HW_Flag_HasRMWSemantics|HW_Flag_LowMaskedOperation)
2828
HARDWARE_INTRINSIC(Sve, BooleanNot, -1, -1, false, {INS_sve_cnot, INS_sve_cnot, INS_sve_cnot, INS_sve_cnot, INS_sve_cnot, INS_sve_cnot, INS_sve_cnot, INS_sve_cnot, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation|HW_Flag_LowMaskedOperation)
29+
HARDWARE_INTRINSIC(Sve, Compact, -1, 2, true, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_compact, INS_sve_compact, INS_sve_compact, INS_sve_compact, INS_sve_compact, INS_sve_compact}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_ExplicitMaskedOperation|HW_Flag_LowMaskedOperation)
2930
HARDWARE_INTRINSIC(Sve, ConditionalSelect, -1, 3, true, {INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel, INS_sve_sel}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_ExplicitMaskedOperation|HW_Flag_SupportsContainment)
3031
HARDWARE_INTRINSIC(Sve, Count16BitElements, 0, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_cnth, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Scalar, HW_Flag_Scalable|HW_Flag_HasEnumOperand|HW_Flag_SpecialCodeGen|HW_Flag_NoFloatingPointUsed)
3132
HARDWARE_INTRINSIC(Sve, Count32BitElements, 0, 1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_cntw, INS_invalid, INS_invalid, INS_invalid}, HW_Category_Scalar, HW_Flag_Scalable|HW_Flag_HasEnumOperand|HW_Flag_SpecialCodeGen|HW_Flag_NoFloatingPointUsed)

src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sve.PlatformNotSupported.cs

+40
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,46 @@ internal Arm64() { }
641641
public static unsafe Vector<ulong> BooleanNot(Vector<ulong> value) { throw new PlatformNotSupportedException(); }
642642

643643

644+
/// Shuffle active elements of vector to the right and fill with zero
645+
646+
/// <summary>
647+
/// svfloat64_t svcompact[_f64](svbool_t pg, svfloat64_t op)
648+
/// COMPACT Zresult.D, Pg, Zop.D
649+
/// </summary>
650+
public static unsafe Vector<double> Compact(Vector<double> mask, Vector<double> value) { throw new PlatformNotSupportedException(); }
651+
652+
/// <summary>
653+
/// svint32_t svcompact[_s32](svbool_t pg, svint32_t op)
654+
/// COMPACT Zresult.S, Pg, Zop.S
655+
/// </summary>
656+
public static unsafe Vector<int> Compact(Vector<int> mask, Vector<int> value) { throw new PlatformNotSupportedException(); }
657+
658+
/// <summary>
659+
/// svint64_t svcompact[_s64](svbool_t pg, svint64_t op)
660+
/// COMPACT Zresult.D, Pg, Zop.D
661+
/// </summary>
662+
public static unsafe Vector<long> Compact(Vector<long> mask, Vector<long> value) { throw new PlatformNotSupportedException(); }
663+
664+
/// <summary>
665+
/// svfloat32_t svcompact[_f32](svbool_t pg, svfloat32_t op)
666+
/// COMPACT Zresult.S, Pg, Zop.S
667+
/// </summary>
668+
public static unsafe Vector<float> Compact(Vector<float> mask, Vector<float> value) { throw new PlatformNotSupportedException(); }
669+
670+
/// <summary>
671+
/// svuint32_t svcompact[_u32](svbool_t pg, svuint32_t op)
672+
/// COMPACT Zresult.S, Pg, Zop.S
673+
/// </summary>
674+
public static unsafe Vector<uint> Compact(Vector<uint> mask, Vector<uint> value) { throw new PlatformNotSupportedException(); }
675+
676+
/// <summary>
677+
/// svuint64_t svcompact[_u64](svbool_t pg, svuint64_t op)
678+
/// COMPACT Zresult.D, Pg, Zop.D
679+
/// </summary>
680+
public static unsafe Vector<ulong> Compact(Vector<ulong> mask, Vector<ulong> value) { throw new PlatformNotSupportedException(); }
681+
682+
683+
/// Compare equal to
644684
/// ConditionalSelect : Conditionally select elements
645685

646686
/// <summary>

src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sve.cs

+40
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,46 @@ internal Arm64() { }
670670
public static unsafe Vector<ulong> BooleanNot(Vector<ulong> value) => BooleanNot(value);
671671

672672

673+
/// Shuffle active elements of vector to the right and fill with zero
674+
675+
/// <summary>
676+
/// svfloat64_t svcompact[_f64](svbool_t pg, svfloat64_t op)
677+
/// COMPACT Zresult.D, Pg, Zop.D
678+
/// </summary>
679+
public static unsafe Vector<double> Compact(Vector<double> mask, Vector<double> value) => Compact(mask, value);
680+
681+
/// <summary>
682+
/// svint32_t svcompact[_s32](svbool_t pg, svint32_t op)
683+
/// COMPACT Zresult.S, Pg, Zop.S
684+
/// </summary>
685+
public static unsafe Vector<int> Compact(Vector<int> mask, Vector<int> value) => Compact(mask, value);
686+
687+
/// <summary>
688+
/// svint64_t svcompact[_s64](svbool_t pg, svint64_t op)
689+
/// COMPACT Zresult.D, Pg, Zop.D
690+
/// </summary>
691+
public static unsafe Vector<long> Compact(Vector<long> mask, Vector<long> value) => Compact(mask, value);
692+
693+
/// <summary>
694+
/// svfloat32_t svcompact[_f32](svbool_t pg, svfloat32_t op)
695+
/// COMPACT Zresult.S, Pg, Zop.S
696+
/// </summary>
697+
public static unsafe Vector<float> Compact(Vector<float> mask, Vector<float> value) => Compact(mask, value);
698+
699+
/// <summary>
700+
/// svuint32_t svcompact[_u32](svbool_t pg, svuint32_t op)
701+
/// COMPACT Zresult.S, Pg, Zop.S
702+
/// </summary>
703+
public static unsafe Vector<uint> Compact(Vector<uint> mask, Vector<uint> value) => Compact(mask, value);
704+
705+
/// <summary>
706+
/// svuint64_t svcompact[_u64](svbool_t pg, svuint64_t op)
707+
/// COMPACT Zresult.D, Pg, Zop.D
708+
/// </summary>
709+
public static unsafe Vector<ulong> Compact(Vector<ulong> mask, Vector<ulong> value) => Compact(mask, value);
710+
711+
712+
/// Compare equal to
673713
/// ConditionalSelect : Conditionally select elements
674714

675715
/// <summary>

src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs

+7
Original file line numberDiff line numberDiff line change
@@ -4272,6 +4272,13 @@ internal Arm64() { }
42724272
public static System.Numerics.Vector<uint> BooleanNot(System.Numerics.Vector<uint> value) { throw null; }
42734273
public static System.Numerics.Vector<ulong> BooleanNot(System.Numerics.Vector<ulong> value) { throw null; }
42744274

4275+
public static System.Numerics.Vector<double> Compact(System.Numerics.Vector<double> mask, System.Numerics.Vector<double> value) { throw null; }
4276+
public static System.Numerics.Vector<int> Compact(System.Numerics.Vector<int> mask, System.Numerics.Vector<int> value) { throw null; }
4277+
public static System.Numerics.Vector<long> Compact(System.Numerics.Vector<long> mask, System.Numerics.Vector<long> value) { throw null; }
4278+
public static System.Numerics.Vector<float> Compact(System.Numerics.Vector<float> mask, System.Numerics.Vector<float> value) { throw null; }
4279+
public static System.Numerics.Vector<uint> Compact(System.Numerics.Vector<uint> mask, System.Numerics.Vector<uint> value) { throw null; }
4280+
public static System.Numerics.Vector<ulong> Compact(System.Numerics.Vector<ulong> mask, System.Numerics.Vector<ulong> value) { throw null; }
4281+
42754282
public static ulong Count16BitElements([ConstantExpected] SveMaskPattern pattern = SveMaskPattern.All) { throw null; }
42764283
public static ulong Count32BitElements([ConstantExpected] SveMaskPattern pattern = SveMaskPattern.All) { throw null; }
42774284
public static ulong Count64BitElements([ConstantExpected] SveMaskPattern pattern = SveMaskPattern.All) { throw null; }

0 commit comments

Comments
 (0)