diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index 2bfa7d81c84685..072a664890af79 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -58,6 +58,10 @@ XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX #include "emit.h" +// Forward declaration +template +inline var_types genActualType(T value); + #include "hwintrinsic.h" #include "simd.h" #include "simdashwintrinsic.h" diff --git a/src/coreclr/jit/hwintrinsic.h b/src/coreclr/jit/hwintrinsic.h index e15f3ae6029ab0..b9d9e69df50804 100644 --- a/src/coreclr/jit/hwintrinsic.h +++ b/src/coreclr/jit/hwintrinsic.h @@ -866,6 +866,11 @@ struct HWIntrinsic final { baseType = node->TypeGet(); } + + if (category == HW_Category_Scalar) + { + baseType = genActualType(baseType); + } } } }; diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_73804/Runtime_73804.cs b/src/tests/JIT/Regression/JitBlue/Runtime_73804/Runtime_73804.cs new file mode 100644 index 00000000000000..02dfe5918d732c --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_73804/Runtime_73804.cs @@ -0,0 +1,29 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Runtime.CompilerServices; + +public unsafe class Runtime_73804 +{ + public static int Main() + { + short value = 0x1000; + int r = Problem(&value); + + return 100 + r - System.Numerics.BitOperations.LeadingZeroCount((uint)value); + } + + [MethodImpl(MethodImplOptions.NoInlining)] + private static int Problem(short* s) + { + if (System.Runtime.Intrinsics.Arm.ArmBase.IsSupported) + { + return System.Runtime.Intrinsics.Arm.ArmBase.LeadingZeroCount(*s); + } + else + { + return System.Numerics.BitOperations.LeadingZeroCount((uint)*s); + } + } +} diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_73804/Runtime_73804.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_73804/Runtime_73804.csproj new file mode 100644 index 00000000000000..cf94135633b19a --- /dev/null +++ b/src/tests/JIT/Regression/JitBlue/Runtime_73804/Runtime_73804.csproj @@ -0,0 +1,10 @@ + + + Exe + True + true + + + + + \ No newline at end of file