Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
5dab5ad
Use packedsimd in hexconverter
lewing Apr 25, 2025
358ba36
Flip the slect mask
lewing Apr 25, 2025
821cca7
Merge branch 'main' into hexconvert-packedsimd
lewing Apr 26, 2025
367f39b
Merge branch 'main' into hexconvert-packedsimd
lewing Apr 27, 2025
8392d8c
Merge branch 'main' into hexconvert-packedsimd
lewing Apr 27, 2025
f1aaf74
Add a PackedSimd.IsSupported test to validate invariants
lewing Apr 28, 2025
4052df3
fix test
lewing Apr 28, 2025
4289cb6
Merge branch 'main' into hexconvert-packedsimd
lewing Apr 29, 2025
717e4e0
Make sure we pass the intrinsics trimmer args in all cases
lewing May 1, 2025
91ad37c
Fix packsimd aot min/max definitions
lewing May 1, 2025
fd835c9
Enable SRI/tests in the smoke build
lewing May 1, 2025
2745546
Temporarily disable tests that cause the aot compiler to crash
lewing May 1, 2025
77434d5
Small changes to the PackedSimd tests
lewing May 1, 2025
f677339
Fix stray characters
lewing May 1, 2025
dbaa44d
Fix
lewing May 1, 2025
493041a
update the tests a bit
lewing May 1, 2025
6e0ae2e
More test work
lewing May 1, 2025
d22e654
Don't disable simd based on debug level we'll respect WasmEnableSIMD …
lewing May 1, 2025
39cd5ff
Rewrite wasm Shuffle to avoid llvm non-constant mask crash
lewing May 2, 2025
bef02bc
fix fill
lewing May 2, 2025
1204495
fix impl
lewing May 2, 2025
5490938
oof
lewing May 2, 2025
87fe9e0
get all the tests passing
lewing May 3, 2025
e1e7924
Add BitwiseSelect test that fails on AOT
lewing May 3, 2025
610a6f8
More tests
lewing May 4, 2025
dbf30a7
Fill ome missing intrinsics case
lewing Apr 29, 2025
01e4bda
Don't try to process instance methods in emit_sri_vector
lewing May 4, 2025
5263810
More tests
lewing May 4, 2025
e34f3d5
Fix PackedSimd.BitwiseSelect argument ordering
lewing May 5, 2025
71d5b74
fix build
lewing May 5, 2025
ef804c8
Fix build for other platforms
lewing May 5, 2025
4cb4844
Merge branch 'main' into hexconvert-packedsimd
lewing May 5, 2025
c3f480e
simplyfy the #ifdefs a little
lewing May 5, 2025
5aac304
Merge branch 'hexconvert-packedsimd' of https://github.com/lewing/run…
lewing May 5, 2025
96e72ca
get the vector type from before the cast
lewing May 5, 2025
9ac0720
Fix accidental change
lewing May 5, 2025
286c835
Fix comment
lewing May 5, 2025
b4e3245
Remove the OP_WASM_ONESCOMPLEMENT path now that the llvm bug has been…
lewing May 5, 2025
d9af19f
revert back to the PackedSimd intrinsic now that it works
lewing May 5, 2025
933fa0a
Make Unsafe.Bitcast intrinsic work on wasm like it works on 64bit pla…
lewing May 5, 2025
4f3d18e
Add more tests
lewing May 5, 2025
954f50e
Merge branch 'main' into hexconvert-packedsimd
lewing May 5, 2025
8632b0a
fix formatting
lewing May 5, 2025
1128a9c
Remove changes that were split out into separate prs
lewing May 6, 2025
5c52e69
remove pointless comment
lewing May 6, 2025
e2c7e89
Merge branch 'main' into hexconvert-packedsimd
lewing May 6, 2025
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
12 changes: 10 additions & 2 deletions src/libraries/Common/src/System/HexConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using System.Runtime.InteropServices;
using System.Runtime.Intrinsics;
using System.Runtime.Intrinsics.Arm;
using System.Runtime.Intrinsics.Wasm;
using System.Runtime.Intrinsics.X86;
using System.Text;
using System.Text.Unicode;
Expand Down Expand Up @@ -243,7 +244,7 @@ public static char ToCharLower(int value)
public static bool TryDecodeFromUtf16(ReadOnlySpan<char> chars, Span<byte> bytes, out int charsProcessed)
{
#if SYSTEM_PRIVATE_CORELIB
if (BitConverter.IsLittleEndian && (Ssse3.IsSupported || AdvSimd.Arm64.IsSupported) &&
if (BitConverter.IsLittleEndian && (Ssse3.IsSupported || AdvSimd.Arm64.IsSupported || PackedSimd.IsSupported) &&
chars.Length >= Vector128<ushort>.Count * 2)
{
return TryDecodeFromUtf16_Vector128(chars, bytes, out charsProcessed);
Expand All @@ -255,9 +256,10 @@ public static bool TryDecodeFromUtf16(ReadOnlySpan<char> chars, Span<byte> bytes
#if SYSTEM_PRIVATE_CORELIB
[CompExactlyDependsOn(typeof(AdvSimd.Arm64))]
[CompExactlyDependsOn(typeof(Ssse3))]
[CompExactlyDependsOn(typeof(PackedSimd))]
public static bool TryDecodeFromUtf16_Vector128(ReadOnlySpan<char> chars, Span<byte> bytes, out int charsProcessed)
{
Debug.Assert(Ssse3.IsSupported || AdvSimd.Arm64.IsSupported);
Debug.Assert(Ssse3.IsSupported || AdvSimd.Arm64.IsSupported || PackedSimd.IsSupported);
Debug.Assert(chars.Length <= bytes.Length * 2);
Debug.Assert(chars.Length % 2 == 0);
Debug.Assert(chars.Length >= Vector128<ushort>.Count * 2);
Expand Down Expand Up @@ -314,6 +316,12 @@ public static bool TryDecodeFromUtf16_Vector128(ReadOnlySpan<char> chars, Span<b
even = AdvSimd.ShiftLeftLogical(even, 4).AsInt16();
output = AdvSimd.AddSaturate(even, odd).AsByte();
}
else if (PackedSimd.IsSupported)
{
Vector128<byte> shiftedNibbles = PackedSimd.ShiftLeft(nibbles, 4);
Vector128<byte> zipped = PackedSimd.BitwiseSelect(nibbles, shiftedNibbles, Vector128.Create((ushort)0xFF00).AsByte());
output = PackedSimd.AddPairwiseWidening(zipped).AsByte();
}
else
{
// We explicitly recheck each IsSupported query to ensure that the trimmer can see which paths are live/dead
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4296,12 +4296,17 @@ internal static Vector128<byte> UnpackHigh(Vector128<byte> left, Vector128<byte>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[CompExactlyDependsOn(typeof(AdvSimd.Arm64))]
[CompExactlyDependsOn(typeof(Sse2))]
[CompExactlyDependsOn(typeof(PackedSimd))]
internal static Vector128<byte> AddSaturate(Vector128<byte> left, Vector128<byte> right)
{
if (Sse2.IsSupported)
{
return Sse2.AddSaturate(left, right);
}
else if (PackedSimd.IsSupported)
{
return PackedSimd.AddSaturate(left, right);
}
else if (!AdvSimd.Arm64.IsSupported)
{
ThrowHelper.ThrowNotSupportedException();
Expand All @@ -4312,12 +4317,17 @@ internal static Vector128<byte> AddSaturate(Vector128<byte> left, Vector128<byte
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[CompExactlyDependsOn(typeof(AdvSimd.Arm64))]
[CompExactlyDependsOn(typeof(Sse2))]
[CompExactlyDependsOn(typeof(PackedSimd))]
internal static Vector128<byte> SubtractSaturate(Vector128<byte> left, Vector128<byte> right)
{
if (Sse2.IsSupported)
{
return Sse2.SubtractSaturate(left, right);
}
else if (PackedSimd.IsSupported)
{
return PackedSimd.SubtractSaturate(left, right);
}
else if (!AdvSimd.Arm64.IsSupported)
{
ThrowHelper.ThrowNotSupportedException();
Expand All @@ -4328,12 +4338,17 @@ internal static Vector128<byte> SubtractSaturate(Vector128<byte> left, Vector128
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[CompExactlyDependsOn(typeof(AdvSimd.Arm64))]
[CompExactlyDependsOn(typeof(Sse2))]
[CompExactlyDependsOn(typeof(PackedSimd))]
internal static Vector128<ushort> AddSaturate(Vector128<ushort> left, Vector128<ushort> right)
{
if (Sse2.IsSupported)
{
return Sse2.AddSaturate(left, right);
}
else if (PackedSimd.IsSupported)
{
return PackedSimd.AddSaturate(left, right);
}
else if (!AdvSimd.Arm64.IsSupported)
{
ThrowHelper.ThrowNotSupportedException();
Expand Down
Loading
Loading