Skip to content

Commit

Permalink
Add an IsKnownConstant path to SinCos (#103724)
Browse files Browse the repository at this point in the history
  • Loading branch information
tannergooding authored and pull[bot] committed Jul 22, 2024
1 parent f10b39b commit 292934c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/coreclr/System.Private.CoreLib/src/System/Math.CoreCLR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ public static partial class Math
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe (double Sin, double Cos) SinCos(double x)
{
if (RuntimeHelpers.IsKnownConstant(x))
{
return (Sin(x), Cos(x));
}

double sin, cos;
SinCos(x, &sin, &cos);
return (sin, cos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ public static partial class MathF
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static unsafe (float Sin, float Cos) SinCos(float x)
{
if (RuntimeHelpers.IsKnownConstant(x))
{
return (Sin(x), Cos(x));
}

float sin, cos;
SinCos(x, &sin, &cos);
return (sin, cos);
Expand Down

0 comments on commit 292934c

Please sign in to comment.