From 132be64c3c4781106b8da4328d39dcd0c696921d Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Mon, 15 Jun 2020 23:40:16 -0700 Subject: [PATCH] Replace Create(ulong) with CreateScalar(uint) in PopCount (#37912) * Replace Create(ulong) with CreateScalar(uint) * Add CreateScalar() in shim --- .../System.Private.CoreLib/src/System/Numerics/BitOperations.cs | 6 +----- .../src/System/Runtime/Intrinsics/Intrinsics.Shims.cs | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/libraries/System.Private.CoreLib/src/System/Numerics/BitOperations.cs b/src/libraries/System.Private.CoreLib/src/System/Numerics/BitOperations.cs index 28b3416..a222296 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Numerics/BitOperations.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Numerics/BitOperations.cs @@ -241,11 +241,7 @@ namespace System.Numerics { // PopCount works on vector so convert input value to vector first. - // Vector64.CreateScalar(uint) generates suboptimal code by storing and - // loading the result to memory. - // See https://github.com/dotnet/runtime/issues/35976 for details. - // Hence use Vector64.Create(ulong) to create Vector64 and operate on that. - Vector64 input = Vector64.Create((ulong)value); + Vector64 input = Vector64.CreateScalar(value); Vector64 aggregated = AdvSimd.Arm64.AddAcross(AdvSimd.PopCount(input.AsByte())); return aggregated.ToScalar(); } diff --git a/src/libraries/System.Utf8String.Experimental/src/System/Runtime/Intrinsics/Intrinsics.Shims.cs b/src/libraries/System.Utf8String.Experimental/src/System/Runtime/Intrinsics/Intrinsics.Shims.cs index 38e129a..9d08032 100644 --- a/src/libraries/System.Utf8String.Experimental/src/System/Runtime/Intrinsics/Intrinsics.Shims.cs +++ b/src/libraries/System.Utf8String.Experimental/src/System/Runtime/Intrinsics/Intrinsics.Shims.cs @@ -7,6 +7,7 @@ namespace System.Runtime.Intrinsics internal static class Vector64 { public static Vector64 Create(ulong value) => throw new PlatformNotSupportedException(); + public static Vector64 CreateScalar(uint value) => throw new PlatformNotSupportedException(); public static Vector64 AsByte(this Vector64 vector) where T : struct => throw new PlatformNotSupportedException(); } internal readonly struct Vector64 -- 2.7.4