JIT: Fix intrinsic recognition for System.Math.Tanh (#90227)
authorJakob Botsch Nielsen <Jakob.botsch.nielsen@gmail.com>
Wed, 9 Aug 2023 15:35:49 +0000 (17:35 +0200)
committerGitHub <noreply@github.com>
Wed, 9 Aug 2023 15:35:49 +0000 (17:35 +0200)
Fix #88451

src/coreclr/jit/importercalls.cpp
src/tests/JIT/Regression/JitBlue/Runtime_88451/Runtime_88451.cs [new file with mode: 0644]
src/tests/JIT/Regression/JitBlue/Runtime_88451/Runtime_88451.csproj [new file with mode: 0644]

index 3bb99bc..fc2d237 100644 (file)
@@ -9574,7 +9574,6 @@ NamedIntrinsic Compiler::lookupPrimitiveFloatNamedIntrinsic(CORINFO_METHOD_HANDL
                         result = NI_System_Math_Tanh;
                     }
                 }
-                result = NI_System_Math_Tan;
             }
             else if (strcmp(methodName, "Truncate") == 0)
             {
diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_88451/Runtime_88451.cs b/src/tests/JIT/Regression/JitBlue/Runtime_88451/Runtime_88451.cs
new file mode 100644 (file)
index 0000000..fae19b7
--- /dev/null
@@ -0,0 +1,15 @@
+// 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;
+using Xunit;
+
+public class Runtime_88451
+{
+    [Fact]
+    public static int TestEntryPoint()
+    {
+        return Math.Tanh(double.NegativeInfinity) == -1 ? 100 : 101;
+    }
+}
diff --git a/src/tests/JIT/Regression/JitBlue/Runtime_88451/Runtime_88451.csproj b/src/tests/JIT/Regression/JitBlue/Runtime_88451/Runtime_88451.csproj
new file mode 100644 (file)
index 0000000..de6d5e0
--- /dev/null
@@ -0,0 +1,8 @@
+<Project Sdk="Microsoft.NET.Sdk">
+  <PropertyGroup>
+    <Optimize>True</Optimize>
+  </PropertyGroup>
+  <ItemGroup>
+    <Compile Include="$(MSBuildProjectName).cs" />
+  </ItemGroup>
+</Project>