From cc0815f16b4d88079e8538d9dccdc7744219f44e Mon Sep 17 00:00:00 2001 From: Mikhail Ablakatov Date: Thu, 16 May 2024 09:48:25 +0000 Subject: [PATCH] JIT ARM64-SVE: Add AbsoluteCompare* APIs --- src/coreclr/jit/hwintrinsiccodegenarm64.cpp | 12 +- src/coreclr/jit/hwintrinsiclistarm64sve.h | 4 + .../Arm/Sve.PlatformNotSupported.cs | 60 ++++ .../src/System/Runtime/Intrinsics/Arm/Sve.cs | 60 ++++ .../ref/System.Runtime.Intrinsics.cs | 9 + .../GenerateHWIntrinsicTests_Arm.cs | 10 + .../HardwareIntrinsics/Arm/Shared/Helpers.cs | 264 ++++++++++++++++++ 7 files changed, 416 insertions(+), 3 deletions(-) diff --git a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp index 572b6f24e46cc3..669e15fd0ed534 100644 --- a/src/coreclr/jit/hwintrinsiccodegenarm64.cpp +++ b/src/coreclr/jit/hwintrinsiccodegenarm64.cpp @@ -502,9 +502,15 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node) case 2: { - assert(instrIsRMW); - - if (intrin.op3->IsVectorZero()) + if (!instrIsRMW) + { + assert(intrin.op3->IsVectorZero()); + // Finally, perform the actual "predicated" operation so that `targetReg` is the first operand + // and `embMaskOp2Reg` is the second operand. + GetEmitter()->emitIns_R_R_R_R(insEmbMask, emitSize, targetReg, maskReg, embMaskOp1Reg, + embMaskOp2Reg, opt); + } + else if (intrin.op3->IsVectorZero()) { // If `falseReg` is zero, then move the first operand of `intrinEmbMask` in the // destination using /Z. diff --git a/src/coreclr/jit/hwintrinsiclistarm64sve.h b/src/coreclr/jit/hwintrinsiclistarm64sve.h index ba1514d65fea66..83055cee536750 100644 --- a/src/coreclr/jit/hwintrinsiclistarm64sve.h +++ b/src/coreclr/jit/hwintrinsiclistarm64sve.h @@ -18,6 +18,10 @@ // Sve HARDWARE_INTRINSIC(Sve, Abs, -1, -1, false, {INS_sve_abs, INS_invalid, INS_sve_abs, INS_invalid, INS_sve_abs, INS_invalid, INS_sve_abs, INS_invalid, INS_sve_fabs, INS_sve_fabs}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation|HW_Flag_LowMaskedOperation) +HARDWARE_INTRINSIC(Sve, AbsoluteCompareGreaterThan, -1, -1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_facgt, INS_sve_facgt}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation|HW_Flag_LowMaskedOperation|HW_Flag_ReturnsPerElementMask) +HARDWARE_INTRINSIC(Sve, AbsoluteCompareGreaterThanOrEqual, -1, -1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_facge, INS_sve_facge}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation|HW_Flag_LowMaskedOperation|HW_Flag_ReturnsPerElementMask) +HARDWARE_INTRINSIC(Sve, AbsoluteCompareLessThan, -1, -1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_faclt, INS_sve_faclt}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation|HW_Flag_LowMaskedOperation|HW_Flag_ReturnsPerElementMask) +HARDWARE_INTRINSIC(Sve, AbsoluteCompareLessThanOrEqual, -1, -1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_facle, INS_sve_facle}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation|HW_Flag_LowMaskedOperation|HW_Flag_ReturnsPerElementMask) HARDWARE_INTRINSIC(Sve, AbsoluteDifference, -1, -1, false, {INS_sve_sabd, INS_sve_uabd, INS_sve_sabd, INS_sve_uabd, INS_sve_sabd, INS_sve_uabd, INS_sve_sabd, INS_sve_uabd, INS_sve_fabd, INS_sve_fabd}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_EmbeddedMaskedOperation|HW_Flag_HasRMWSemantics|HW_Flag_LowMaskedOperation) HARDWARE_INTRINSIC(Sve, Add, -1, -1, false, {INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_add, INS_sve_fadd, INS_sve_fadd}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_OptionalEmbeddedMaskedOperation|HW_Flag_HasRMWSemantics|HW_Flag_LowMaskedOperation) HARDWARE_INTRINSIC(Sve, AddAcross, -1, 1, true, {INS_sve_saddv, INS_sve_uaddv, INS_sve_saddv, INS_sve_uaddv, INS_sve_saddv, INS_sve_uaddv, INS_sve_uaddv, INS_sve_uaddv, INS_sve_faddv, INS_sve_faddv}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_BaseTypeFromFirstArg|HW_Flag_EmbeddedMaskedOperation|HW_Flag_LowMaskedOperation) diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sve.PlatformNotSupported.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sve.PlatformNotSupported.cs index 88af56e345ce5b..f75098a6afc9e0 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sve.PlatformNotSupported.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sve.PlatformNotSupported.cs @@ -157,6 +157,66 @@ internal Arm64() { } /// public static unsafe Vector AbsoluteDifference(Vector left, Vector right) { throw new PlatformNotSupportedException(); } + /// Absolute compare greater than + + /// + /// svbool_t svacgt[_f32](svbool_t pg, svfloat32_t op1, svfloat32_t op2) + /// FACGT Presult.S, Pg/Z, Zop1.S, Zop2.S + /// + public static unsafe Vector AbsoluteCompareGreaterThan(Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + /// + /// svbool_t svacgt[_f64](svbool_t pg, svfloat64_t op1, svfloat64_t op2) + /// FACGT Presult.D, Pg/Z, Zop1.D, Zop2.D + /// + public static unsafe Vector AbsoluteCompareGreaterThan(Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + + /// Absolute compare greater than or equal to + + /// + /// svbool_t svacge[_f32](svbool_t pg, svfloat32_t op1, svfloat32_t op2) + /// FACGE Presult.S, Pg/Z, Zop1.S, Zop2.S + /// + public static unsafe Vector AbsoluteCompareGreaterThanOrEqual(Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + /// + /// svbool_t svacge[_f64](svbool_t pg, svfloat64_t op1, svfloat64_t op2) + /// FACGE Presult.D, Pg/Z, Zop1.D, Zop2.D + /// + public static unsafe Vector AbsoluteCompareGreaterThanOrEqual(Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + + /// Absolute compare less than + + /// + /// svbool_t svaclt[_f32](svbool_t pg, svfloat32_t op1, svfloat32_t op2) + /// FACLT Presult.S, Pg/Z, Zop1.S, Zop2.S + /// + public static unsafe Vector AbsoluteCompareLessThan(Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + /// + /// svbool_t svaclt[_f64](svbool_t pg, svfloat64_t op1, svfloat64_t op2) + /// FACLT Presult.D, Pg/Z, Zop1.D, Zop2.D + /// + public static unsafe Vector AbsoluteCompareLessThan(Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + + /// Absolute compare less than or equal to + + /// + /// svbool_t svacle[_f32](svbool_t pg, svfloat32_t op1, svfloat32_t op2) + /// FACLE Presult.S, Pg/Z, Zop1.S, Zop2.S + /// + public static unsafe Vector AbsoluteCompareLessThanOrEqual(Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + /// + /// svbool_t svacle[_f64](svbool_t pg, svfloat64_t op1, svfloat64_t op2) + /// FACLE Presult.D, Pg/Z, Zop1.D, Zop2.D + /// + public static unsafe Vector AbsoluteCompareLessThanOrEqual(Vector left, Vector right) { throw new PlatformNotSupportedException(); } + + /// Add : Add /// diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sve.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sve.cs index 8d2d7704ce3623..fd4f861c8f31d4 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sve.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Arm/Sve.cs @@ -185,6 +185,66 @@ internal Arm64() { } /// public static unsafe Vector AbsoluteDifference(Vector left, Vector right) => AbsoluteDifference(left, right); + /// Absolute compare greater than + + /// + /// svbool_t svacgt[_f32](svbool_t pg, svfloat32_t op1, svfloat32_t op2) + /// FACGT Presult.S, Pg/Z, Zop1.S, Zop2.S + /// + public static unsafe Vector AbsoluteCompareGreaterThan(Vector left, Vector right) => AbsoluteCompareGreaterThan(left, right); + + /// + /// svbool_t svacgt[_f64](svbool_t pg, svfloat64_t op1, svfloat64_t op2) + /// FACGT Presult.D, Pg/Z, Zop1.D, Zop2.D + /// + public static unsafe Vector AbsoluteCompareGreaterThan(Vector left, Vector right) => AbsoluteCompareGreaterThan(left, right); + + + /// Absolute compare greater than or equal to + + /// + /// svbool_t svacge[_f32](svbool_t pg, svfloat32_t op1, svfloat32_t op2) + /// FACGE Presult.S, Pg/Z, Zop1.S, Zop2.S + /// + public static unsafe Vector AbsoluteCompareGreaterThanOrEqual(Vector left, Vector right) => AbsoluteCompareGreaterThanOrEqual(left, right); + + /// + /// svbool_t svacge[_f64](svbool_t pg, svfloat64_t op1, svfloat64_t op2) + /// FACGE Presult.D, Pg/Z, Zop1.D, Zop2.D + /// + public static unsafe Vector AbsoluteCompareGreaterThanOrEqual(Vector left, Vector right) => AbsoluteCompareGreaterThanOrEqual(left, right); + + + /// Absolute compare less than + + /// + /// svbool_t svaclt[_f32](svbool_t pg, svfloat32_t op1, svfloat32_t op2) + /// FACLT Presult.S, Pg/Z, Zop1.S, Zop2.S + /// + public static unsafe Vector AbsoluteCompareLessThan(Vector left, Vector right) => AbsoluteCompareLessThan(left, right); + + /// + /// svbool_t svaclt[_f64](svbool_t pg, svfloat64_t op1, svfloat64_t op2) + /// FACLT Presult.D, Pg/Z, Zop1.D, Zop2.D + /// + public static unsafe Vector AbsoluteCompareLessThan(Vector left, Vector right) => AbsoluteCompareLessThan(left, right); + + + /// Absolute compare less than or equal to + + /// + /// svbool_t svacle[_f32](svbool_t pg, svfloat32_t op1, svfloat32_t op2) + /// FACLE Presult.S, Pg/Z, Zop1.S, Zop2.S + /// + public static unsafe Vector AbsoluteCompareLessThanOrEqual(Vector left, Vector right) => AbsoluteCompareLessThanOrEqual(left, right); + + /// + /// svbool_t svacle[_f64](svbool_t pg, svfloat64_t op1, svfloat64_t op2) + /// FACLE Presult.D, Pg/Z, Zop1.D, Zop2.D + /// + public static unsafe Vector AbsoluteCompareLessThanOrEqual(Vector left, Vector right) => AbsoluteCompareLessThanOrEqual(left, right); + + /// Add : Add /// diff --git a/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs b/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs index d8d37180ecaf7c..e45f2a131291de 100644 --- a/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs +++ b/src/libraries/System.Runtime.Intrinsics/ref/System.Runtime.Intrinsics.cs @@ -4194,6 +4194,15 @@ internal Arm64() { } public static System.Numerics.Vector Abs(System.Numerics.Vector value) { throw null; } public static System.Numerics.Vector Abs(System.Numerics.Vector value) { throw null; } + public static System.Numerics.Vector AbsoluteCompareGreaterThan(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector AbsoluteCompareGreaterThan(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector AbsoluteCompareGreaterThanOrEqual(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector AbsoluteCompareGreaterThanOrEqual(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector AbsoluteCompareLessThan(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector AbsoluteCompareLessThan(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector AbsoluteCompareLessThanOrEqual(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector AbsoluteCompareLessThanOrEqual(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } + public static System.Numerics.Vector AbsoluteDifference(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } public static System.Numerics.Vector AbsoluteDifference(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } public static System.Numerics.Vector AbsoluteDifference(System.Numerics.Vector left, System.Numerics.Vector right) { throw null; } diff --git a/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs b/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs index 4fa05f18031dbc..e62062ddb8c676 100644 --- a/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs +++ b/src/tests/Common/GenerateHWIntrinsicTests/GenerateHWIntrinsicTests_Arm.cs @@ -3004,6 +3004,16 @@ ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_BooleanNot_uint", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "BooleanNot", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt32", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt32", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt32()", ["ValidateIterResult"] = "Helpers.BooleanNot(firstOp[i]) != result[i]", ["GetIterResult"] = "Helpers.BooleanNot(leftOp[i])"}), ("SveSimpleVecOpTest.template", new Dictionary { ["TestName"] = "Sve_BooleanNot_ulong", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "BooleanNot", ["RetVectorType"] = "Vector", ["RetBaseType"] = "UInt64", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "UInt64", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetUInt64()", ["ValidateIterResult"] = "Helpers.BooleanNot(firstOp[i]) != result[i]", ["GetIterResult"] = "Helpers.BooleanNot(leftOp[i])"}), +// Sve mask + ("SveVecBinOpTest.template", new Dictionary {["TestName"] = "Sve_AbsoluteCompareGreaterThan_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "AbsoluteCompareGreaterThan", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "Helpers.SveAbsoluteCompareGreaterThan(left[i], right[i]) != result[i]", ["GetIterResult"] = "Helpers.SveAbsoluteCompareGreaterThan(leftOp[i], rightOp[i])"}), + ("SveVecBinOpTest.template", new Dictionary {["TestName"] = "Sve_AbsoluteCompareGreaterThan_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "AbsoluteCompareGreaterThan", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "Helpers.SveAbsoluteCompareGreaterThan(left[i], right[i]) != result[i]", ["GetIterResult"] = "Helpers.SveAbsoluteCompareGreaterThan(leftOp[i], rightOp[i])"}), + ("SveVecBinOpTest.template", new Dictionary {["TestName"] = "Sve_AbsoluteCompareGreaterThanOrEqual_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "AbsoluteCompareGreaterThanOrEqual", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "Helpers.SveAbsoluteCompareGreaterThanOrEqual(left[i], right[i]) != result[i]", ["GetIterResult"] = "Helpers.SveAbsoluteCompareGreaterThanOrEqual(leftOp[i], rightOp[i])"}), + ("SveVecBinOpTest.template", new Dictionary {["TestName"] = "Sve_AbsoluteCompareGreaterThanOrEqual_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "AbsoluteCompareGreaterThanOrEqual", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "Helpers.SveAbsoluteCompareGreaterThanOrEqual(left[i], right[i]) != result[i]", ["GetIterResult"] = "Helpers.SveAbsoluteCompareGreaterThanOrEqual(leftOp[i], rightOp[i])"}), + ("SveVecBinOpTest.template", new Dictionary {["TestName"] = "Sve_AbsoluteCompareLessThan_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "AbsoluteCompareLessThan", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "Helpers.SveAbsoluteCompareLessThan(left[i], right[i]) != result[i]", ["GetIterResult"] = "Helpers.SveAbsoluteCompareLessThan(leftOp[i], rightOp[i])"}), + ("SveVecBinOpTest.template", new Dictionary {["TestName"] = "Sve_AbsoluteCompareLessThan_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "AbsoluteCompareLessThan", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "Helpers.SveAbsoluteCompareLessThan(left[i], right[i]) != result[i]", ["GetIterResult"] = "Helpers.SveAbsoluteCompareLessThan(leftOp[i], rightOp[i])"}), + ("SveVecBinOpTest.template", new Dictionary {["TestName"] = "Sve_AbsoluteCompareLessThanOrEqual_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "AbsoluteCompareLessThanOrEqual", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "Helpers.SveAbsoluteCompareLessThanOrEqual(left[i], right[i]) != result[i]", ["GetIterResult"] = "Helpers.SveAbsoluteCompareLessThanOrEqual(leftOp[i], rightOp[i])"}), + ("SveVecBinOpTest.template", new Dictionary {["TestName"] = "Sve_AbsoluteCompareLessThanOrEqual_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "AbsoluteCompareLessThanOrEqual", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Double", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "Helpers.SveAbsoluteCompareLessThanOrEqual(left[i], right[i]) != result[i]", ["GetIterResult"] = "Helpers.SveAbsoluteCompareLessThanOrEqual(leftOp[i], rightOp[i])"}), + ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_float", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Single", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Single", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Single", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Single", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp2"] = "TestLibrary.Generator.GetSingle()", ["NextValueOp3"] = "TestLibrary.Generator.GetSingle()", ["ValidateIterResult"] = "(firstOp[i] != 0 ? (result[i] != secondOp[i]) : (result[i] != thirdOp[i]))",}), ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_double", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "Double", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "Double", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "Double", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "Double", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp2"] = "TestLibrary.Generator.GetDouble()", ["NextValueOp3"] = "TestLibrary.Generator.GetDouble()", ["ValidateIterResult"] = "(firstOp[i] != 0 ? (result[i] != secondOp[i]) : (result[i] != thirdOp[i]))",}), ("SveConditionalSelect.template", new Dictionary { ["TestName"] = "Sve_ConditionalSelect_sbyte", ["Isa"] = "Sve", ["LoadIsa"] = "Sve", ["Method"] = "ConditionalSelect", ["RetVectorType"] = "Vector", ["RetBaseType"] = "SByte", ["Op1VectorType"] = "Vector", ["Op1BaseType"] = "SByte", ["Op2VectorType"] = "Vector", ["Op2BaseType"] = "SByte", ["Op3VectorType"] = "Vector", ["Op3BaseType"] = "SByte", ["LargestVectorSize"] = "64", ["NextValueOp1"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp2"] = "TestLibrary.Generator.GetSByte()", ["NextValueOp3"] = "TestLibrary.Generator.GetSByte()", ["ValidateIterResult"] = "(firstOp[i] != 0 ? (result[i] != secondOp[i]) : (result[i] != thirdOp[i]))",}), diff --git a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs index fa4424056b3978..0426dd5cce79c6 100644 --- a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs +++ b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs @@ -1524,6 +1524,270 @@ public static float CompareTest(float left, float right) return BitConverter.Int32BitsToSingle(result); } + public static double SveAbsoluteCompareGreaterThan(double left, double right) + { + long result = 0; + + left = Math.Abs(left); + right = Math.Abs(right); + + if (left > right) + { + result = 1; + } + + return BitConverter.Int64BitsToDouble(result); + } + + public static float SveAbsoluteCompareGreaterThan(float left, float right) + { + int result = 0; + + left = Math.Abs(left); + right = Math.Abs(right); + + if (left > right) + { + result = 1; + } + + return BitConverter.Int32BitsToSingle(result); + } + + public static double SveAbsoluteCompareGreaterThanOrEqual(double left, double right) + { + long result = 0; + + left = Math.Abs(left); + right = Math.Abs(right); + + if (left >= right) + { + result = 1; + } + + return BitConverter.Int64BitsToDouble(result); + } + + public static float SveAbsoluteCompareGreaterThanOrEqual(float left, float right) + { + int result = 0; + + left = Math.Abs(left); + right = Math.Abs(right); + + if (left >= right) + { + result = 1; + } + + return BitConverter.Int32BitsToSingle(result); + } + + public static double SveAbsoluteCompareLessThan(double left, double right) + { + long result = 0; + + left = Math.Abs(left); + right = Math.Abs(right); + + if (left < right) + { + result = 1; + } + + return BitConverter.Int64BitsToDouble(result); + } + + public static float SveAbsoluteCompareLessThan(float left, float right) + { + int result = 0; + + left = Math.Abs(left); + right = Math.Abs(right); + + if (left < right) + { + result = 1; + } + + return BitConverter.Int32BitsToSingle(result); + } + + public static double SveAbsoluteCompareLessThanOrEqual(double left, double right) + { + long result = 0; + + left = Math.Abs(left); + right = Math.Abs(right); + + if (left <= right) + { + result = 1; + } + + return BitConverter.Int64BitsToDouble(result); + } + + public static float SveAbsoluteCompareLessThanOrEqual(float left, float right) + { + int result = 0; + + left = Math.Abs(left); + right = Math.Abs(right); + + if (left <= right) + { + result = 1; + } + + return BitConverter.Int32BitsToSingle(result); + } + + public static double SveCompareEqual(double left, double right) + { + long result = 0; + + if (left == right) + { + result = 1; + } + + return BitConverter.Int64BitsToDouble(result); + } + + public static float SveCompareEqual(float left, float right) + { + int result = 0; + + if (left == right) + { + result = 1; + } + + return BitConverter.Int32BitsToSingle(result); + } + + public static double SveCompareGreaterThan(double left, double right) + { + long result = 0; + + if (left > right) + { + result = 1; + } + + return BitConverter.Int64BitsToDouble(result); + } + + public static float SveCompareGreaterThan(float left, float right) + { + int result = 0; + + if (left > right) + { + result = 1; + } + + return BitConverter.Int32BitsToSingle(result); + } + + public static double SveCompareGreaterThanOrEqual(double left, double right) + { + long result = 0; + + if (left >= right) + { + result = 1; + } + + return BitConverter.Int64BitsToDouble(result); + } + + public static float SveCompareGreaterThanOrEqual(float left, float right) + { + int result = 0; + + if (left >= right) + { + result = 1; + } + + return BitConverter.Int32BitsToSingle(result); + } + + public static double SveCompareLessThan(double left, double right) + { + long result = 0; + + if (left < right) + { + result = 1; + } + + return BitConverter.Int64BitsToDouble(result); + } + + public static float SveCompareLessThan(float left, float right) + { + int result = 0; + + if (left < right) + { + result = 1; + } + + return BitConverter.Int32BitsToSingle(result); + } + + public static double SveCompareLessThanOrEqual(double left, double right) + { + long result = 0; + + if (left <= right) + { + result = 1; + } + + return BitConverter.Int64BitsToDouble(result); + } + + public static float SveCompareLessThanOrEqual(float left, float right) + { + int result = 0; + + if (left <= right) + { + result = 1; + } + + return BitConverter.Int32BitsToSingle(result); + } + + public static double SveCompareTest(double left, double right) + { + long result = 0; + + if ((BitConverter.DoubleToInt64Bits(left) & BitConverter.DoubleToInt64Bits(right)) != 0) + { + result = 1; + } + + return BitConverter.Int64BitsToDouble(result); + } + + public static float SveCompareTest(float left, float right) + { + int result = 0; + + if ((BitConverter.SingleToInt32Bits(left) & BitConverter.SingleToInt32Bits(right)) != 0) + { + result = 1; + } + + return BitConverter.Int32BitsToSingle(result); + } + public static byte Abs(sbyte value) => value < 0 ? (byte)-value : (byte)value; public static ushort Abs(short value) => value < 0 ? (ushort)-value : (ushort)value;