From 257d712f3e2e043fd7d88c1be9670b5cf9620ced Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Thu, 3 Apr 2025 22:31:50 -0700 Subject: [PATCH 1/5] fix the mask values returned by Helper --- src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs index 4f5243c1641319..ef76d223c8bc3d 100644 --- a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs +++ b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs @@ -7744,12 +7744,12 @@ public static ulong getMaskUInt64() public static float getMaskSingle() { - return (float)(BitConverter.Int32BitsToSingle(TestLibrary.Generator.GetInt32()%(int)2)); + return (float)(TestLibrary.Generator.GetInt32()%(int)2); } public static double getMaskDouble() { - return (double)(BitConverter.Int64BitsToDouble(TestLibrary.Generator.GetInt64()%(long)2)); + return (double)(TestLibrary.Generator.GetInt64()%(long)2); } public static int MaskNumberOfElementsVector(int elems, SveMaskPattern pattern) From ac619033f0f9dac7e28719923f71ab7ab9793ba7 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Thu, 3 Apr 2025 22:43:35 -0700 Subject: [PATCH 2/5] Address review feedback from copilot --- src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs index ef76d223c8bc3d..d489d07d394b6e 100644 --- a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs +++ b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs @@ -7744,12 +7744,12 @@ public static ulong getMaskUInt64() public static float getMaskSingle() { - return (float)(TestLibrary.Generator.GetInt32()%(int)2); + return (float)(TestLibrary.Generator.GetUInt32()%(int)2); } public static double getMaskDouble() { - return (double)(TestLibrary.Generator.GetInt64()%(long)2); + return (double)(TestLibrary.Generator.GetUInt64()%(long)2); } public static int MaskNumberOfElementsVector(int elems, SveMaskPattern pattern) From 4324101f9e55dc28d0eb097e8c8153fb4a4387af Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Fri, 4 Apr 2025 10:13:43 -0700 Subject: [PATCH 3/5] Remove unrequired cast --- .../HardwareIntrinsics/Arm/Shared/Helpers.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs index d489d07d394b6e..6b2f41af220048 100644 --- a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs +++ b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs @@ -7704,52 +7704,52 @@ public static ulong MaskBothSet(double[] op1, double[] op2) public static byte getMaskByte() { - return (byte)(TestLibrary.Generator.GetByte()%(byte)2); + return (byte)(TestLibrary.Generator.GetByte() % 2); } public static sbyte getMaskSByte() { - return (sbyte)(TestLibrary.Generator.GetSByte()%(sbyte)2); + return (sbyte)(TestLibrary.Generator.GetSByte() % 2); } public static short getMaskInt16() { - return (short)(TestLibrary.Generator.GetInt16()%(short)2); + return (short)(TestLibrary.Generator.GetInt16() % 2); } public static ushort getMaskUInt16() { - return (ushort)(TestLibrary.Generator.GetUInt16()%(ushort)2); + return (ushort)(TestLibrary.Generator.GetUInt16() % 2); } public static int getMaskInt32() { - return (int)(TestLibrary.Generator.GetInt32()%(int)2); + return (int)(TestLibrary.Generator.GetInt32() % 2); } public static uint getMaskUInt32() { - return (uint)(TestLibrary.Generator.GetUInt32()%(uint)2); + return (uint)(TestLibrary.Generator.GetUInt32() % 2); } public static long getMaskInt64() { - return (long)(TestLibrary.Generator.GetInt64()%(long)2); + return (long)(TestLibrary.Generator.GetInt64() % 2); } public static ulong getMaskUInt64() { - return (ulong)(TestLibrary.Generator.GetUInt64()%(ulong)2); + return (ulong)(TestLibrary.Generator.GetUInt64() % 2); } public static float getMaskSingle() { - return (float)(TestLibrary.Generator.GetUInt32()%(int)2); + return (float)(TestLibrary.Generator.GetUInt32() % 2); } public static double getMaskDouble() { - return (double)(TestLibrary.Generator.GetUInt64()%(long)2); + return (double)(TestLibrary.Generator.GetUInt64() % 2); } public static int MaskNumberOfElementsVector(int elems, SveMaskPattern pattern) From 2e532eab3c5291cfb2c872f039f629c078696ac9 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Fri, 4 Apr 2025 10:17:05 -0700 Subject: [PATCH 4/5] Fix MaskBothSet method --- src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs index 6b2f41af220048..f6cfafdc687e01 100644 --- a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs +++ b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs @@ -7687,7 +7687,7 @@ public static ulong MaskBothSet(float[] op1, float[] op2) ulong acc = 0; for (var i = 0; i < op1.Length; i++) { - acc += (ulong)((BitConverter.SingleToInt32Bits(op1[i]) == 1 && BitConverter.SingleToInt32Bits(op2[i]) == 1) ? 1 : 0); + acc += (ulong)((op1[i] == 1) && (op2[i] == 1) ? 1 : 0); } return acc; } @@ -7697,7 +7697,7 @@ public static ulong MaskBothSet(double[] op1, double[] op2) ulong acc = 0; for (var i = 0; i < op1.Length; i++) { - acc += (ulong)((BitConverter.DoubleToInt64Bits(op1[i]) == 1 && BitConverter.DoubleToInt64Bits(op2[i]) == 1) ? 1 : 0); + acc += (ulong)((op1[i] == 1) && (op2[i] == 1) ? 1 : 0); } return acc; } From f3c9050c5f7e6b5ac5ef41da016e227a9891c1c6 Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Fri, 4 Apr 2025 10:18:41 -0700 Subject: [PATCH 5/5] Make sure to use unsigned version for GetMask* --- src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs index f6cfafdc687e01..ef91904ae2bc40 100644 --- a/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs +++ b/src/tests/JIT/HardwareIntrinsics/Arm/Shared/Helpers.cs @@ -7709,12 +7709,12 @@ public static byte getMaskByte() public static sbyte getMaskSByte() { - return (sbyte)(TestLibrary.Generator.GetSByte() % 2); + return (sbyte)(TestLibrary.Generator.GetByte() % 2); } public static short getMaskInt16() { - return (short)(TestLibrary.Generator.GetInt16() % 2); + return (short)(TestLibrary.Generator.GetUInt16() % 2); } public static ushort getMaskUInt16() @@ -7724,7 +7724,7 @@ public static ushort getMaskUInt16() public static int getMaskInt32() { - return (int)(TestLibrary.Generator.GetInt32() % 2); + return (int)(TestLibrary.Generator.GetUInt32() % 2); } public static uint getMaskUInt32() @@ -7734,7 +7734,7 @@ public static uint getMaskUInt32() public static long getMaskInt64() { - return (long)(TestLibrary.Generator.GetInt64() % 2); + return (long)(TestLibrary.Generator.GetUInt64() % 2); } public static ulong getMaskUInt64()