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

(WIP) Arm64/SVE: Implemented ConvertToSingle and ConvertToDouble #104259

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c738b77
Added ConverToInt32 and ConvertToUInt32 for float inputs.
ebepho Jun 5, 2024
35d39d9
Added flags to handle only low predicate registers.
ebepho Jun 5, 2024
7a781e1
Fixed merge conflicts.
ebepho Jun 5, 2024
1378d60
Fix whitespace
ebepho Jun 5, 2024
10c7a15
Remove special codegen flag
ebepho Jun 7, 2024
8004868
Added new test template for operations with different return types.
ebepho Jun 10, 2024
af7ccd4
Merge branch 'main' into ConvertToInt32
ebepho Jun 10, 2024
8cb76da
Add new test template.
ebepho Jun 11, 2024
abe25fc
Added api for ConvertToInt32 and ConvertToUInt 32 for double.
ebepho Jun 13, 2024
0f51f38
fix merge conflicts.
ebepho Jun 13, 2024
7fabb91
Merge branch 'dotnet:main' into main
ebepho Jun 14, 2024
d5374ca
Merge branch 'main' of github.com:ebepho/runtime
ebepho Jun 15, 2024
fe32a2f
ConvertToSingle for int and uint.
ebepho Jun 15, 2024
478b969
ConvertToSingle for long and ulong.
ebepho Jun 15, 2024
4aa224d
Merge branch 'main' of github.com:ebepho/runtime
ebepho Jun 15, 2024
cc63edf
Merge branch 'main' into ConvertToSingleDouble
ebepho Jun 15, 2024
ff54068
Started ConvertToDouble.
ebepho Jun 15, 2024
56601b4
Merge branch 'main' of github.com:ebepho/runtime
ebepho Jun 17, 2024
04071a3
Merge branch 'main' of github.com:ebepho/runtime
ebepho Jun 18, 2024
ffcd267
Merge branch 'main' of github.com:ebepho/runtime
ebepho Jun 18, 2024
5ac4a05
Merge branch 'main' into converttosingledouble
ebepho Jun 18, 2024
04c069a
addressed comments.
ebepho Jun 28, 2024
94d04f4
double or long to 32 bit value.
ebepho Jun 27, 2024
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
24 changes: 24 additions & 0 deletions src/coreclr/jit/hwintrinsiccodegenarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,30 @@ void CodeGen::genHWIntrinsic(GenTreeHWIntrinsic* node)
{
assert(!instrIsRMW);

// Special handling for ConvertTo* APIs
// Just need to change the opt here.
insOpts embOpt = opt;
switch (intrinEmbMask.id)
{
case NI_Sve_ConvertToInt32:
case NI_Sve_ConvertToUInt32:
case NI_Sve_ConvertToSingle:
{
embOpt = emitTypeSize(intrinEmbMask.baseType) == EA_8BYTE ? INS_OPTS_D_TO_S : INS_OPTS_SCALABLE_S;
break;
}

case NI_Sve_ConvertToInt64:
case NI_Sve_ConvertToUInt64:
case NI_Sve_ConvertToDouble:
{
embOpt = emitTypeSize(intrinEmbMask.baseType) == EA_4BYTE ? INS_OPTS_S_TO_D : INS_OPTS_SCALABLE_D;
break;
}
default:
break;
}

if (targetReg != falseReg)
{
// If targetReg is not the same as `falseReg` then need to move
Expand Down
2 changes: 2 additions & 0 deletions src/coreclr/jit/hwintrinsiclistarm64sve.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ HARDWARE_INTRINSIC(Sve, Compute16BitAddresses,
HARDWARE_INTRINSIC(Sve, Compute32BitAddresses, -1, 2, true, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_adr, INS_invalid, INS_sve_adr, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_SpecialCodeGen)
HARDWARE_INTRINSIC(Sve, Compute64BitAddresses, -1, 2, true, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_adr, INS_invalid, INS_sve_adr, INS_invalid, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_SpecialCodeGen)
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)
HARDWARE_INTRINSIC(Sve, ConvertToDouble, -1, -1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_scvtf, INS_sve_ucvtf, INS_sve_scvtf, INS_sve_ucvtf, INS_sve_fcvt, INS_invalid}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_BaseTypeFromFirstArg|HW_Flag_EmbeddedMaskedOperation|HW_Flag_LowMaskedOperation)
HARDWARE_INTRINSIC(Sve, ConvertToInt32, -1, -1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_fcvtzs, INS_sve_fcvtzs}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_BaseTypeFromFirstArg|HW_Flag_EmbeddedMaskedOperation|HW_Flag_LowMaskedOperation)
HARDWARE_INTRINSIC(Sve, ConvertToSingle, -1, -1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_scvtf, INS_sve_ucvtf, INS_sve_scvtf, INS_sve_ucvtf, INS_invalid, INS_sve_fcvt}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_BaseTypeFromFirstArg|HW_Flag_EmbeddedMaskedOperation|HW_Flag_LowMaskedOperation)
HARDWARE_INTRINSIC(Sve, ConvertToUInt32, -1, -1, false, {INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_invalid, INS_sve_fcvtzu, INS_sve_fcvtzu}, HW_Category_SIMD, HW_Flag_Scalable|HW_Flag_BaseTypeFromFirstArg|HW_Flag_EmbeddedMaskedOperation|HW_Flag_LowMaskedOperation)
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)
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,54 @@ internal Arm64() { }
public static unsafe Vector<double> ConditionalSelect(Vector<double> mask, Vector<double> left, Vector<double> right) { throw new PlatformNotSupportedException(); }


/// ConvertToDouble : Floating-point convert

/// <summary>
/// svfloat64_t svcvt_f64[_s32]_m(svfloat64_t inactive, svbool_t pg, svint32_t op)
/// SCVTF Ztied.D, Pg/M, Zop.S
/// svfloat64_t svcvt_f64[_s32]_x(svbool_t pg, svint32_t op)
/// SCVTF Ztied.D, Pg/M, Ztied.S
/// svfloat64_t svcvt_f64[_s32]_z(svbool_t pg, svint32_t op)
/// </summary>
public static unsafe Vector<double> ConvertToDouble(Vector<int> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svfloat64_t svcvt_f64[_s64]_m(svfloat64_t inactive, svbool_t pg, svint64_t op)
/// SCVTF Ztied.D, Pg/M, Zop.D
/// svfloat64_t svcvt_f64[_s64]_x(svbool_t pg, svint64_t op)
/// SCVTF Ztied.D, Pg/M, Ztied.D
/// svfloat64_t svcvt_f64[_s64]_z(svbool_t pg, svint64_t op)
/// </summary>
public static unsafe Vector<double> ConvertToDouble(Vector<long> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svfloat64_t svcvt_f64[_f32]_m(svfloat64_t inactive, svbool_t pg, svfloat32_t op)
/// FCVT Ztied.D, Pg/M, Zop.S
/// svfloat64_t svcvt_f64[_f32]_x(svbool_t pg, svfloat32_t op)
/// FCVT Ztied.D, Pg/M, Ztied.S
/// svfloat64_t svcvt_f64[_f32]_z(svbool_t pg, svfloat32_t op)
/// </summary>
public static unsafe Vector<double> ConvertToDouble(Vector<float> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svfloat64_t svcvt_f64[_u32]_m(svfloat64_t inactive, svbool_t pg, svuint32_t op)
/// UCVTF Ztied.D, Pg/M, Zop.S
/// svfloat64_t svcvt_f64[_u32]_x(svbool_t pg, svuint32_t op)
/// UCVTF Ztied.D, Pg/M, Ztied.S
/// svfloat64_t svcvt_f64[_u32]_z(svbool_t pg, svuint32_t op)
/// </summary>
public static unsafe Vector<double> ConvertToDouble(Vector<uint> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svfloat64_t svcvt_f64[_u64]_m(svfloat64_t inactive, svbool_t pg, svuint64_t op)
/// UCVTF Ztied.D, Pg/M, Zop.D
/// svfloat64_t svcvt_f64[_u64]_x(svbool_t pg, svuint64_t op)
/// UCVTF Ztied.D, Pg/M, Ztied.D
/// svfloat64_t svcvt_f64[_u64]_z(svbool_t pg, svuint64_t op)
/// </summary>
public static unsafe Vector<double> ConvertToDouble(Vector<ulong> value) { throw new PlatformNotSupportedException(); }


/// ConvertToInt32 : Floating-point convert

/// <summary>
Expand All @@ -869,6 +917,54 @@ internal Arm64() { }
public static unsafe Vector<int> ConvertToInt32(Vector<float> value) { throw new PlatformNotSupportedException(); }


/// ConvertToSingle : Floating-point convert

/// <summary>
/// svfloat32_t svcvt_f32[_f64]_m(svfloat32_t inactive, svbool_t pg, svfloat64_t op)
/// FCVT Ztied.S, Pg/M, Zop.D
/// svfloat32_t svcvt_f32[_f64]_x(svbool_t pg, svfloat64_t op)
/// FCVT Ztied.S, Pg/M, Ztied.D
/// svfloat32_t svcvt_f32[_f64]_z(svbool_t pg, svfloat64_t op)
/// </summary>
public static unsafe Vector<float> ConvertToSingle(Vector<double> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svfloat32_t svcvt_f32[_s32]_m(svfloat32_t inactive, svbool_t pg, svint32_t op)
/// SCVTF Ztied.S, Pg/M, Zop.S
/// svfloat32_t svcvt_f32[_s32]_x(svbool_t pg, svint32_t op)
/// SCVTF Ztied.S, Pg/M, Ztied.S
/// svfloat32_t svcvt_f32[_s32]_z(svbool_t pg, svint32_t op)
/// </summary>
public static unsafe Vector<float> ConvertToSingle(Vector<int> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svfloat32_t svcvt_f32[_s64]_m(svfloat32_t inactive, svbool_t pg, svint64_t op)
/// SCVTF Ztied.S, Pg/M, Zop.D
/// svfloat32_t svcvt_f32[_s64]_x(svbool_t pg, svint64_t op)
/// SCVTF Ztied.S, Pg/M, Ztied.D
/// svfloat32_t svcvt_f32[_s64]_z(svbool_t pg, svint64_t op)
/// </summary>
public static unsafe Vector<float> ConvertToSingle(Vector<long> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svfloat32_t svcvt_f32[_u32]_m(svfloat32_t inactive, svbool_t pg, svuint32_t op)
/// UCVTF Ztied.S, Pg/M, Zop.S
/// svfloat32_t svcvt_f32[_u32]_x(svbool_t pg, svuint32_t op)
/// UCVTF Ztied.S, Pg/M, Ztied.S
/// svfloat32_t svcvt_f32[_u32]_z(svbool_t pg, svuint32_t op)
/// </summary>
public static unsafe Vector<float> ConvertToSingle(Vector<uint> value) { throw new PlatformNotSupportedException(); }

/// <summary>
/// svfloat32_t svcvt_f32[_u64]_m(svfloat32_t inactive, svbool_t pg, svuint64_t op)
/// UCVTF Ztied.S, Pg/M, Zop.D
/// svfloat32_t svcvt_f32[_u64]_x(svbool_t pg, svuint64_t op)
/// UCVTF Ztied.S, Pg/M, Ztied.D
/// svfloat32_t svcvt_f32[_u64]_z(svbool_t pg, svuint64_t op)
/// </summary>
public static unsafe Vector<float> ConvertToSingle(Vector<ulong> value) { throw new PlatformNotSupportedException(); }


/// ConvertToUInt32 : Floating-point convert

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,54 @@ internal Arm64() { }
public static unsafe Vector<double> ConditionalSelect(Vector<double> mask, Vector<double> left, Vector<double> right) => ConditionalSelect(mask, left, right);


/// ConvertToDouble : Floating-point convert

/// <summary>
/// svfloat64_t svcvt_f64[_s32]_m(svfloat64_t inactive, svbool_t pg, svint32_t op)
/// SCVTF Ztied.D, Pg/M, Zop.S
/// svfloat64_t svcvt_f64[_s32]_x(svbool_t pg, svint32_t op)
/// SCVTF Ztied.D, Pg/M, Ztied.S
/// svfloat64_t svcvt_f64[_s32]_z(svbool_t pg, svint32_t op)
/// </summary>
public static unsafe Vector<double> ConvertToDouble(Vector<int> value) => ConvertToDouble(value);

/// <summary>
/// svfloat64_t svcvt_f64[_s64]_m(svfloat64_t inactive, svbool_t pg, svint64_t op)
/// SCVTF Ztied.D, Pg/M, Zop.D
/// svfloat64_t svcvt_f64[_s64]_x(svbool_t pg, svint64_t op)
/// SCVTF Ztied.D, Pg/M, Ztied.D
/// svfloat64_t svcvt_f64[_s64]_z(svbool_t pg, svint64_t op)
/// </summary>
public static unsafe Vector<double> ConvertToDouble(Vector<long> value) => ConvertToDouble(value);

/// <summary>
/// svfloat64_t svcvt_f64[_f32]_m(svfloat64_t inactive, svbool_t pg, svfloat32_t op)
/// FCVT Ztied.D, Pg/M, Zop.S
/// svfloat64_t svcvt_f64[_f32]_x(svbool_t pg, svfloat32_t op)
/// FCVT Ztied.D, Pg/M, Ztied.S
/// svfloat64_t svcvt_f64[_f32]_z(svbool_t pg, svfloat32_t op)
/// </summary>
public static unsafe Vector<double> ConvertToDouble(Vector<float> value) => ConvertToDouble(value);

/// <summary>
/// svfloat64_t svcvt_f64[_u32]_m(svfloat64_t inactive, svbool_t pg, svuint32_t op)
/// UCVTF Ztied.D, Pg/M, Zop.S
/// svfloat64_t svcvt_f64[_u32]_x(svbool_t pg, svuint32_t op)
/// UCVTF Ztied.D, Pg/M, Ztied.S
/// svfloat64_t svcvt_f64[_u32]_z(svbool_t pg, svuint32_t op)
/// </summary>
public static unsafe Vector<double> ConvertToDouble(Vector<uint> value) => ConvertToDouble(value);

/// <summary>
/// svfloat64_t svcvt_f64[_u64]_m(svfloat64_t inactive, svbool_t pg, svuint64_t op)
/// UCVTF Ztied.D, Pg/M, Zop.D
/// svfloat64_t svcvt_f64[_u64]_x(svbool_t pg, svuint64_t op)
/// UCVTF Ztied.D, Pg/M, Ztied.D
/// svfloat64_t svcvt_f64[_u64]_z(svbool_t pg, svuint64_t op)
/// </summary>
public static unsafe Vector<double> ConvertToDouble(Vector<ulong> value) => ConvertToDouble(value);


/// ConvertToInt32 : Floating-point convert

/// <summary>
Expand All @@ -926,6 +974,54 @@ internal Arm64() { }
public static unsafe Vector<int> ConvertToInt32(Vector<float> value) => ConvertToInt32(value);


/// ConvertToSingle : Floating-point convert

/// <summary>
/// svfloat32_t svcvt_f32[_f64]_m(svfloat32_t inactive, svbool_t pg, svfloat64_t op)
/// FCVT Ztied.S, Pg/M, Zop.D
/// svfloat32_t svcvt_f32[_f64]_x(svbool_t pg, svfloat64_t op)
/// FCVT Ztied.S, Pg/M, Ztied.D
/// svfloat32_t svcvt_f32[_f64]_z(svbool_t pg, svfloat64_t op)
/// </summary>
public static unsafe Vector<float> ConvertToSingle(Vector<double> value) => ConvertToSingle(value);

/// <summary>
/// svfloat32_t svcvt_f32[_s32]_m(svfloat32_t inactive, svbool_t pg, svint32_t op)
/// SCVTF Ztied.S, Pg/M, Zop.S
/// svfloat32_t svcvt_f32[_s32]_x(svbool_t pg, svint32_t op)
/// SCVTF Ztied.S, Pg/M, Ztied.S
/// svfloat32_t svcvt_f32[_s32]_z(svbool_t pg, svint32_t op)
/// </summary>
public static unsafe Vector<float> ConvertToSingle(Vector<int> value) => ConvertToSingle(value);

/// <summary>
/// svfloat32_t svcvt_f32[_s64]_m(svfloat32_t inactive, svbool_t pg, svint64_t op)
/// SCVTF Ztied.S, Pg/M, Zop.D
/// svfloat32_t svcvt_f32[_s64]_x(svbool_t pg, svint64_t op)
/// SCVTF Ztied.S, Pg/M, Ztied.D
/// svfloat32_t svcvt_f32[_s64]_z(svbool_t pg, svint64_t op)
/// </summary>
public static unsafe Vector<float> ConvertToSingle(Vector<long> value) => ConvertToSingle(value);

/// <summary>
/// svfloat32_t svcvt_f32[_u32]_m(svfloat32_t inactive, svbool_t pg, svuint32_t op)
/// UCVTF Ztied.S, Pg/M, Zop.S
/// svfloat32_t svcvt_f32[_u32]_x(svbool_t pg, svuint32_t op)
/// UCVTF Ztied.S, Pg/M, Ztied.S
/// svfloat32_t svcvt_f32[_u32]_z(svbool_t pg, svuint32_t op)
/// </summary>
public static unsafe Vector<float> ConvertToSingle(Vector<uint> value) => ConvertToSingle(value);

/// <summary>
/// svfloat32_t svcvt_f32[_u64]_m(svfloat32_t inactive, svbool_t pg, svuint64_t op)
/// UCVTF Ztied.S, Pg/M, Zop.D
/// svfloat32_t svcvt_f32[_u64]_x(svbool_t pg, svuint64_t op)
/// UCVTF Ztied.S, Pg/M, Ztied.D
/// svfloat32_t svcvt_f32[_u64]_z(svbool_t pg, svuint64_t op)
/// </summary>
public static unsafe Vector<float> ConvertToSingle(Vector<ulong> value) => ConvertToSingle(value);


/// ConvertToUInt32 : Floating-point convert

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4315,8 +4315,18 @@ internal Arm64() { }
public static System.Numerics.Vector<float> ConditionalSelect(System.Numerics.Vector<float> mask, System.Numerics.Vector<float> left, System.Numerics.Vector<float> right) { throw null; }
public static System.Numerics.Vector<double> ConditionalSelect(System.Numerics.Vector<double> mask, System.Numerics.Vector<double> left, System.Numerics.Vector<double> right) { throw null; }

public static System.Numerics.Vector<double> ConvertToDouble(System.Numerics.Vector<int> value) { throw null; }
public static System.Numerics.Vector<double> ConvertToDouble(System.Numerics.Vector<long> value) { throw null; }
public static System.Numerics.Vector<double> ConvertToDouble(System.Numerics.Vector<float> value) { throw null; }
public static System.Numerics.Vector<double> ConvertToDouble(System.Numerics.Vector<uint> value) { throw null; }
public static System.Numerics.Vector<double> ConvertToDouble(System.Numerics.Vector<ulong> value) { throw null; }
public static System.Numerics.Vector<int> ConvertToInt32(System.Numerics.Vector<double> value) { throw null; }
public static System.Numerics.Vector<int> ConvertToInt32(System.Numerics.Vector<float> value) { throw null; }
public static System.Numerics.Vector<float> ConvertToSingle(System.Numerics.Vector<double> value) { throw null; }
public static System.Numerics.Vector<float> ConvertToSingle(System.Numerics.Vector<int> value) { throw null; }
public static System.Numerics.Vector<float> ConvertToSingle(System.Numerics.Vector<long> value) { throw null; }
public static System.Numerics.Vector<float> ConvertToSingle(System.Numerics.Vector<uint> value) { throw null; }
public static System.Numerics.Vector<float> ConvertToSingle(System.Numerics.Vector<ulong> value) { throw null; }
public static System.Numerics.Vector<uint> ConvertToUInt32(System.Numerics.Vector<double> value) { throw null; }
public static System.Numerics.Vector<uint> ConvertToUInt32(System.Numerics.Vector<float> value) { throw null; }

Expand Down
Loading