Skip to content

Commit 132be64

Browse files
authored
Replace Create(ulong) with CreateScalar(uint) in PopCount (#37912)
* Replace Create(ulong) with CreateScalar(uint) * Add CreateScalar() in shim
1 parent bbb5902 commit 132be64

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

src/libraries/System.Private.CoreLib/src/System/Numerics/BitOperations.cs

+1-5
Original file line numberDiff line numberDiff line change
@@ -241,11 +241,7 @@ public static int PopCount(uint value)
241241
{
242242
// PopCount works on vector so convert input value to vector first.
243243

244-
// Vector64.CreateScalar(uint) generates suboptimal code by storing and
245-
// loading the result to memory.
246-
// See https://github.com/dotnet/runtime/issues/35976 for details.
247-
// Hence use Vector64.Create(ulong) to create Vector64<ulong> and operate on that.
248-
Vector64<ulong> input = Vector64.Create((ulong)value);
244+
Vector64<uint> input = Vector64.CreateScalar(value);
249245
Vector64<byte> aggregated = AdvSimd.Arm64.AddAcross(AdvSimd.PopCount(input.AsByte()));
250246
return aggregated.ToScalar();
251247
}

src/libraries/System.Utf8String.Experimental/src/System/Runtime/Intrinsics/Intrinsics.Shims.cs

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ namespace System.Runtime.Intrinsics
77
internal static class Vector64
88
{
99
public static Vector64<ulong> Create(ulong value) => throw new PlatformNotSupportedException();
10+
public static Vector64<uint> CreateScalar(uint value) => throw new PlatformNotSupportedException();
1011
public static Vector64<byte> AsByte<T>(this Vector64<T> vector) where T : struct => throw new PlatformNotSupportedException();
1112
}
1213
internal readonly struct Vector64<T>

0 commit comments

Comments
 (0)