Some cleanup of the Math functions from #20788 (#20912)
authorTanner Gooding <tagoo@outlook.com>
Mon, 12 Nov 2018 18:51:16 +0000 (10:51 -0800)
committerGitHub <noreply@github.com>
Mon, 12 Nov 2018 18:51:16 +0000 (10:51 -0800)
* Fixing Max, MaxMagnitude, Min, and MinMagnitude for Math/MathF to be IEEE compliant

* Disabling the System.Math.Max/Min tests

* Adding the new c_runtime PAL tests to the CMakeLists to ensure they actually get run.

* Fixing the casing of IlogB to ILogB

* Fixing the new PAL tests to match the correct/expected outputs

* Fixing up PAL_ilogb to correctly handle 0 and NaN

26 files changed:
cross/android/arm/tryrun.cmake
cross/android/arm64/tryrun.cmake
cross/tryrun.cmake
src/System.Private.CoreLib/shared/System/Math.cs
src/System.Private.CoreLib/shared/System/MathF.cs
src/System.Private.CoreLib/src/System/Math.CoreCLR.cs
src/System.Private.CoreLib/src/System/MathF.CoreCLR.cs
src/classlibnative/float/floatdouble.cpp
src/classlibnative/float/floatsingle.cpp
src/classlibnative/inc/floatdouble.h
src/classlibnative/inc/floatsingle.h
src/pal/src/config.h.in
src/pal/src/configure.cmake
src/pal/src/cruntime/math.cpp
src/pal/tests/palsuite/c_runtime/CMakeLists.txt
src/pal/tests/palsuite/c_runtime/fma/test1/test1.cpp
src/pal/tests/palsuite/c_runtime/fmaf/test1/test1.c
src/pal/tests/palsuite/c_runtime/ilogb/test1/test1.cpp
src/pal/tests/palsuite/c_runtime/ilogbf/test1/CMakeLists.txt
src/pal/tests/palsuite/c_runtime/ilogbf/test1/test1.cpp [moved from src/pal/tests/palsuite/c_runtime/ilogbf/test1/test1.c with 70% similarity]
src/pal/tests/palsuite/c_runtime/log2/test1/test1.cpp
src/pal/tests/palsuite/c_runtime/log2f/test1/test1.c
src/pal/tests/palsuite/paltestlist.txt
src/pal/tests/palsuite/palverify.dat
src/vm/ecalllist.h
tests/CoreFX/CoreFX.issues.json

index bcc2cd2..69b7158 100644 (file)
@@ -6,6 +6,14 @@ SET( HAVE_COMPATIBLE_EXP_EXITCODE
      1
      CACHE STRING "Result from TRY_RUN" FORCE)
 
+SET( HAVE_COMPATIBLE_ILOGB0_EXITCODE 
+     0
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( HAVE_COMPATIBLE_ILOGBNAN_EXITCODE 
+     0
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
 SET( REALPATH_SUPPORTS_NONEXISTENT_FILES_EXITCODE 
      1
      CACHE STRING "Result from TRY_RUN" FORCE)
index f32065a..93a2250 100644 (file)
@@ -2,6 +2,14 @@ SET( HAVE_COMPATIBLE_EXP_EXITCODE
      1
      CACHE STRING "Result from TRY_RUN" FORCE)
 
+SET( HAVE_COMPATIBLE_ILOGB0_EXITCODE 
+     0
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
+SET( HAVE_COMPATIBLE_ILOGBNAN_EXITCODE 
+     0
+     CACHE STRING "Result from TRY_RUN" FORCE)
+
 SET( REALPATH_SUPPORTS_NONEXISTENT_FILES_EXITCODE 
      1
      CACHE STRING "Result from TRY_RUN" FORCE)
index d0bd77d..47aa7b4 100644 (file)
@@ -23,6 +23,8 @@ if(TARGET_ARCH_NAME MATCHES "^(armel|arm|arm64|x86)$")
   set_cache_value(HAVE_COMPATIBLE_ACOS_EXITCODE 0)
   set_cache_value(HAVE_COMPATIBLE_ASIN_EXITCODE 0)
   set_cache_value(HAVE_COMPATIBLE_ATAN2_EXITCODE 0)
+  set_cache_value(HAVE_COMPATIBLE_ILOGB0_EXITCODE 0)
+  set_cache_value(HAVE_COMPATIBLE_ILOGBNAN_EXITCODE 0)
   set_cache_value(HAVE_COMPATIBLE_LOG10_EXITCODE 0)
   set_cache_value(HAVE_COMPATIBLE_LOG_EXITCODE 0)
   set_cache_value(HAVE_COMPATIBLE_POW_EXITCODE 0)
index 41a0806..e278486 100644 (file)
@@ -538,17 +538,31 @@ namespace System
 
         public static double Max(double val1, double val2)
         {
-            if (val1 > val2)
+            // When val1 and val2 are both finite or infinite, return the larger
+            //  * We count +0.0 as larger than -0.0 to match MSVC
+            // When val1 or val2, but not both, are NaN return the opposite
+            //  * We return the opposite if either is NaN to match MSVC
+
+            if (double.IsNaN(val1))
             {
-                return val1;
+                return val2;
             }
 
-            if (double.IsNaN(val1))
+            if (double.IsNaN(val2))
             {
                 return val1;
             }
 
-            return val2;
+            // We do this comparison first and separately to handle the -0.0 to +0.0 comparision
+            // * Doing (val1 < val2) first could get transformed into (val2 >= val1) by the JIT
+            //   which would then return an incorrect value
+
+            if (val1 == val2)
+            {
+                return double.IsNegative(val1) ? val2 : val1;
+            }
+
+            return (val1 < val2) ? val2 : val1;
         }
 
         [NonVersionable]
@@ -578,17 +592,31 @@ namespace System
         
         public static float Max(float val1, float val2)
         {
-            if (val1 > val2)
+            // When val1 and val2 are both finite or infinite, return the larger
+            //  * We count +0.0 as larger than -0.0 to match MSVC
+            // When val1 or val2, but not both, are NaN return the opposite
+            //  * We return the opposite if either is NaN to match MSVC
+
+            if (float.IsNaN(val1))
             {
-                return val1;
+                return val2;
             }
 
-            if (float.IsNaN(val1))
+            if (float.IsNaN(val2))
             {
                 return val1;
             }
 
-            return val2;
+            // We do this comparison first and separately to handle the -0.0 to +0.0 comparision
+            // * Doing (val1 < val2) first could get transformed into (val2 >= val1) by the JIT
+            //   which would then return an incorrect value
+
+            if (val1 == val2)
+            {
+                return float.IsNegative(val1) ? val2 : val1;
+            }
+
+            return (val1 < val2) ? val2 : val1;
         }
 
         [CLSCompliant(false)]
@@ -614,7 +642,31 @@ namespace System
 
         public static double MaxMagnitude(double x, double y)
         {
-            return Max(Abs(x), Abs(y));
+            // When x and y are both finite or infinite, return the larger magnitude
+            //  * We count +0.0 as larger than -0.0 to match MSVC
+            // When x or y, but not both, are NaN return the opposite
+            //  * We return the opposite if either is NaN to match MSVC
+
+            if (double.IsNaN(x))
+            {
+                return y;
+            }
+
+            if (double.IsNaN(y))
+            {
+                return x;
+            }
+
+            // We do this comparison first and separately to handle the -0.0 to +0.0 comparision
+            // * Doing (x < y) first could get transformed into (y >= x) by the JIT which would
+            //   then return an incorrect value
+
+            if (x == y)
+            {
+                return double.IsNegative(x) ? y : x;
+            }
+
+            return (Abs(x) < Abs(y)) ? y : x;
         }
 
         [NonVersionable]
@@ -631,17 +683,31 @@ namespace System
 
         public static double Min(double val1, double val2)
         {
-            if (val1 < val2)
+            // When val1 and val2 are both finite or infinite, return the smaller
+            //  * We count -0.0 as smaller than -0.0 to match MSVC
+            // When val1 or val2, but not both, are NaN return the opposite
+            //  * We return the opposite if either is NaN to match MSVC
+
+            if (double.IsNaN(val1))
             {
-                return val1;
+                return val2;
             }
 
-            if (double.IsNaN(val1))
+            if (double.IsNaN(val2))
             {
                 return val1;
             }
 
-            return val2;
+            // We do this comparison first and separately to handle the -0.0 to +0.0 comparision
+            // * Doing (val1 < val2) first could get transformed into (val2 >= val1) by the JIT
+            //   which would then return an incorrect value
+
+            if (val1 == val2)
+            {
+                return double.IsNegative(val1) ? val1 : val2;
+            }
+
+            return (val1 < val2) ? val1 : val2;
         }
 
         [NonVersionable]
@@ -671,17 +737,31 @@ namespace System
 
         public static float Min(float val1, float val2)
         {
-            if (val1 < val2)
+            // When val1 and val2 are both finite or infinite, return the smaller
+            //  * We count -0.0 as smaller than -0.0 to match MSVC
+            // When val1 or val2, but not both, are NaN return the opposite
+            //  * We return the opposite if either is NaN to match MSVC
+
+            if (float.IsNaN(val1))
             {
-                return val1;
+                return val2;
             }
 
-            if (float.IsNaN(val1))
+            if (float.IsNaN(val2))
             {
                 return val1;
             }
 
-            return val2;
+            // We do this comparison first and separately to handle the -0.0 to +0.0 comparision
+            // * Doing (val1 < val2) first could get transformed into (val2 >= val1) by the JIT
+            //   which would then return an incorrect value
+
+            if (val1 == val2)
+            {
+                return float.IsNegative(val1) ? val1 : val2;
+            }
+
+            return (val1 < val2) ? val1 : val2;
         }
 
         [CLSCompliant(false)]
@@ -707,7 +787,31 @@ namespace System
 
         public static double MinMagnitude(double x, double y)
         {
-            return Min(Abs(x), Abs(y));
+            // When x and y are both finite or infinite, return the smaller magnitude
+            //  * We count -0.0 as smaller than -0.0 to match MSVC
+            // When x or y, but not both, are NaN return the opposite
+            //  * We return the opposite if either is NaN to match MSVC
+
+            if (double.IsNaN(x))
+            {
+                return y;
+            }
+
+            if (double.IsNaN(y))
+            {
+                return x;
+            }
+
+            // We do this comparison first and separately to handle the -0.0 to +0.0 comparision
+            // * Doing (x < y) first could get transformed into (y >= x) by the JIT which would
+            //   then return an incorrect value
+
+            if (x == y)
+            {
+                return double.IsNegative(x) ? x : y;
+            }
+
+            return (Abs(x) < Abs(y)) ? x : y;
         }
 
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
index 9eac890..428f9f8 100644 (file)
@@ -190,7 +190,31 @@ namespace System
 
         public static float MaxMagnitude(float x, float y)
         {
-            return Max(Abs(x), Abs(y));
+            // When x and y are both finite or infinite, return the larger magnitude
+            //  * We count +0.0 as larger than -0.0 to match MSVC
+            // When x or y, but not both, are NaN return the opposite
+            //  * We return the opposite if either is NaN to match MSVC
+
+            if (float.IsNaN(x))
+            {
+                return y;
+            }
+
+            if (float.IsNaN(y))
+            {
+                return x;
+            }
+
+            // We do this comparison first and separately to handle the -0.0 to +0.0 comparision
+            // * Doing (x < y) first could get transformed into (y >= x) by the JIT which would
+            //   then return an incorrect value
+
+            if (x == y)
+            {
+                return float.IsNegative(x) ? y : x;
+            }
+
+            return (Abs(x) < Abs(y)) ? y : x;
         }
 
         [MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -201,7 +225,31 @@ namespace System
 
         public static float MinMagnitude(float x, float y)
         {
-            return Min(Abs(x), Abs(y));
+            // When x and y are both finite or infinite, return the smaller magnitude
+            //  * We count -0.0 as smaller than -0.0 to match MSVC
+            // When x or y, but not both, are NaN return the opposite
+            //  * We return the opposite if either is NaN to match MSVC
+
+            if (float.IsNaN(x))
+            {
+                return y;
+            }
+
+            if (float.IsNaN(y))
+            {
+                return x;
+            }
+
+            // We do this comparison first and separately to handle the -0.0 to +0.0 comparision
+            // * Doing (x < y) first could get transformed into (y >= x) by the JIT which would
+            //   then return an incorrect value
+
+            if (x == y)
+            {
+                return float.IsNegative(x) ? x : y;
+            }
+
+            return (Abs(x) < Abs(y)) ? x : y;
         }
 
         [Intrinsic]
index 5331353..0378bcb 100644 (file)
@@ -68,7 +68,7 @@ namespace System
         public static extern double FusedMultiplyAdd(double x, double y, double z);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        public static extern int IlogB(double x);
+        public static extern int ILogB(double x);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         public static extern double Log(double d);
index fa99f1f..fb04fcd 100644 (file)
@@ -59,7 +59,7 @@ namespace System
         public static extern float FusedMultiplyAdd(float x, float y, float z);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
-        public static extern int IlogB(float x);
+        public static extern int ILogB(float x);
 
         [MethodImpl(MethodImplOptions.InternalCall)]
         public static extern float Log(float x);
index 2e4b382..e0d0fd9 100644 (file)
@@ -212,7 +212,7 @@ FCIMPLEND
 /*=====================================Ilog2====================================
 **
 ==============================================================================*/
-FCIMPL1_V(int, COMDouble::IlogB, double x)
+FCIMPL1_V(int, COMDouble::ILogB, double x)
     FCALL_CONTRACT;
 
     return (int)ilogb(x);
index 23c1445..39b9fd6 100644 (file)
@@ -199,7 +199,7 @@ FCIMPLEND
 /*=====================================Ilog2====================================
 **
 ==============================================================================*/
-FCIMPL1_V(int, COMSingle::IlogB, float x)
+FCIMPL1_V(int, COMSingle::ILogB, float x)
     FCALL_CONTRACT;
 
     return (int)ilogbf(x);
index 602b45b..40d5e2e 100644 (file)
@@ -26,7 +26,7 @@ public:
     FCDECL1_V(static double, Floor, double x);
     FCDECL2_VV(static double, FMod, double x, double y);
     FCDECL3_VVV(static double, FusedMultiplyAdd, double x, double y, double z);
-    FCDECL1_V(static int, IlogB, double x);
+    FCDECL1_V(static int, ILogB, double x);
     FCDECL1_V(static double, Log, double x);
     FCDECL1_V(static double, Log2, double x);
     FCDECL1_V(static double, Log10, double x);
index f54a650..b23aea3 100644 (file)
@@ -26,7 +26,7 @@ public:
     FCDECL1_V(static float, Floor, float x);
     FCDECL2_VV(static float, FMod, float x, float y);
     FCDECL3_VVV(static float, FusedMultiplyAdd, float x, float y, float z);
-    FCDECL1_V(static int, IlogB, float x);
+    FCDECL1_V(static int, ILogB, float x);
     FCDECL1_V(static float, Log, float x);
     FCDECL1_V(static float, Log2, float x);
     FCDECL1_V(static float, Log10, float x);
index 24ea14d..1ed071e 100644 (file)
 #cmakedefine01 HAVE_VALID_POSITIVE_INF_POW
 #cmakedefine01 HAVE_COMPATIBLE_ATAN2
 #cmakedefine01 HAVE_COMPATIBLE_EXP
+#cmakedefine01 HAVE_COMPATIBLE_ILOGB0
+#cmakedefine01 HAVE_COMPATIBLE_ILOGBNAN
 #cmakedefine01 HAVE_COMPATIBLE_LOG
 #cmakedefine01 HAVE_COMPATIBLE_LOG10
 #cmakedefine01 UNGETC_NOT_RETURN_EOF
index c8b4d44..d105d85 100644 (file)
@@ -833,6 +833,32 @@ check_cxx_source_runs("
 #include <stdlib.h>
 
 int main(void) {
+  if (FP_ILOGB0 != -2147483648) {
+    exit(1);
+  }
+
+  exit(0);
+}" HAVE_COMPATIBLE_ILOGB0)
+set(CMAKE_REQUIRED_LIBRARIES)
+set(CMAKE_REQUIRED_LIBRARIES m)
+check_cxx_source_runs("
+#include <math.h>
+#include <stdlib.h>
+
+int main(void) {
+  if (FP_ILOGBNAN != 2147483647) {
+    exit(1);
+  }
+
+  exit(0);
+}" HAVE_COMPATIBLE_ILOGBNAN)
+set(CMAKE_REQUIRED_LIBRARIES)
+set(CMAKE_REQUIRED_LIBRARIES m)
+check_cxx_source_runs("
+#include <math.h>
+#include <stdlib.h>
+
+int main(void) {
   if (!isnan(log(-10000))) {
     exit(1);
   }
index 126bbff..9628cbd 100644 (file)
@@ -340,7 +340,25 @@ PALIMPORT int __cdecl PAL_ilogb(double x)
     PERF_ENTRY(ilogb);
     ENTRY("ilogb (x=%f)\n", x);
 
-    ret = ilogb(x);
+#if !HAVE_COMPATIBLE_ILOGB0
+    if (x == 0.0)
+    {
+        ret = -2147483648;
+    }
+    else 
+#endif // !HAVE_COMPATIBLE_ILOGB0
+
+#if !HAVE_COMPATIBLE_ILOGBNAN
+    if (isnan(x))
+    {
+        ret = 2147483647;
+    }
+    else
+#endif // !HAVE_COMPATIBLE_ILOGBNAN
+
+    {
+        ret = ilogb(x);
+    }
 
     LOGEXIT("ilogb returns int %d\n", ret);
     PERF_EXIT(ilogb);
@@ -855,7 +873,25 @@ PALIMPORT int __cdecl PAL_ilogbf(float x)
     PERF_ENTRY(ilogbf);
     ENTRY("ilogbf (x=%f)\n", x);
 
-    ret = ilogbf(x);
+#if !HAVE_COMPATIBLE_ILOGB0
+    if (x == 0.0f)
+    {
+        ret = -2147483648;
+    }
+    else 
+#endif // !HAVE_COMPATIBLE_ILOGB0
+
+#if !HAVE_COMPATIBLE_ILOGBNAN
+    if (isnan(x))
+    {
+        ret = 2147483647;
+    }
+    else
+#endif // !HAVE_COMPATIBLE_ILOGBNAN
+
+    {
+        ret = ilogbf(x);
+    }
 
     LOGEXIT("ilogbf returns int %d\n", ret);
     PERF_EXIT(ilogbf);
index ba11c91..3f3db60 100644 (file)
@@ -44,6 +44,8 @@ add_subdirectory(fflush)
 add_subdirectory(fgets)
 add_subdirectory(floor)
 add_subdirectory(floorf)
+add_subdirectory(fma)
+add_subdirectory(fmaf)
 add_subdirectory(fmod)
 add_subdirectory(fmodf)
 add_subdirectory(fopen)
@@ -57,6 +59,8 @@ add_subdirectory(fwprintf)
 add_subdirectory(fwrite)
 add_subdirectory(getc)
 add_subdirectory(getenv)
+add_subdirectory(ilogb)
+add_subdirectory(ilogbf)
 add_subdirectory(isalnum)
 add_subdirectory(isalpha)
 add_subdirectory(isdigit)
@@ -73,6 +77,8 @@ add_subdirectory(labs)
 add_subdirectory(llabs)
 add_subdirectory(localtime)
 add_subdirectory(log)
+add_subdirectory(log2)
+add_subdirectory(log2f)
 add_subdirectory(log10)
 add_subdirectory(log10f)
 add_subdirectory(logf)
@@ -90,6 +96,8 @@ add_subdirectory(printf)
 add_subdirectory(qsort)
 add_subdirectory(rand_srand)
 add_subdirectory(realloc)
+add_subdirectory(scalbn)
+add_subdirectory(scalbnf)
 add_subdirectory(sin)
 add_subdirectory(sinf)
 add_subdirectory(sinh)
index f6918d6..b7d515d 100644 (file)
@@ -93,8 +93,8 @@ int __cdecl main(int argc, char **argv)
     {
         /* x                       y                       z                       expected                   variance */
         {  PAL_NEGINF,             PAL_NEGINF,             PAL_NEGINF,             PAL_NEGINF,                0 },
-        { -1e308,                  2,                      1e300,                 -1e300,                     0 },
-        {  1e308,                  2,                     -1e300,                  1e300,                     0 },
+        { -1e308,                  2,                      1e308,                 -1e308,                     0 },
+        {  1e308,                  2,                     -1e308,                  1e308,                     0 },
         {  PAL_POSINF,             PAL_POSINF,             PAL_POSINF,             PAL_POSINF,                0 },
     };
 
@@ -132,19 +132,14 @@ int __cdecl main(int argc, char **argv)
 
     // Returns NaN if (x * y) is infinite, and z is an infinite of the opposite sign
     validate_isnan(PAL_POSINF, PAL_POSINF, PAL_NEGINF);
-    validate_isnan(PAL_NEGINF, PAL_NEGINF, PAL_POSINF);
+    validate_isnan(PAL_NEGINF, PAL_NEGINF, PAL_NEGINF);
     validate_isnan(PAL_POSINF, PAL_NEGINF, PAL_POSINF);
     validate_isnan(PAL_NEGINF, PAL_POSINF, PAL_POSINF);
 
     validate_isnan(PAL_POSINF, 1, PAL_NEGINF);
     validate_isnan(PAL_NEGINF, 1, PAL_POSINF);
-    validate_isnan(PAL_POSINF, 1, PAL_POSINF);
-    validate_isnan(PAL_NEGINF, 1, PAL_POSINF);
-
     validate_isnan(1, PAL_POSINF, PAL_NEGINF);
     validate_isnan(1, PAL_NEGINF, PAL_POSINF);
-    validate_isnan(1, PAL_NEGINF, PAL_POSINF);
-    validate_isnan(1, PAL_POSINF, PAL_POSINF);
 
     PAL_Terminate();
     return PASS;
index 7c3b5e3..6c48d56 100644 (file)
@@ -131,19 +131,14 @@ int __cdecl main(int argc, char **argv)
 
     // Returns NaN if (x * y) is infinite, and z is an infinite of the opposite sign
     validate_isnan(PAL_POSINF, PAL_POSINF, PAL_NEGINF);
-    validate_isnan(PAL_NEGINF, PAL_NEGINF, PAL_POSINF);
+    validate_isnan(PAL_NEGINF, PAL_NEGINF, PAL_NEGINF);
     validate_isnan(PAL_POSINF, PAL_NEGINF, PAL_POSINF);
     validate_isnan(PAL_NEGINF, PAL_POSINF, PAL_POSINF);
 
     validate_isnan(PAL_POSINF, 1, PAL_NEGINF);
     validate_isnan(PAL_NEGINF, 1, PAL_POSINF);
-    validate_isnan(PAL_POSINF, 1, PAL_POSINF);
-    validate_isnan(PAL_NEGINF, 1, PAL_POSINF);
-
     validate_isnan(1, PAL_POSINF, PAL_NEGINF);
     validate_isnan(1, PAL_NEGINF, PAL_POSINF);
-    validate_isnan(1, PAL_NEGINF, PAL_POSINF);
-    validate_isnan(1, PAL_POSINF, PAL_POSINF);
 
     PAL_Terminate();
     return PASS;
index 5df6fcf..0757e4e 100644 (file)
@@ -36,7 +36,7 @@ void __cdecl validate(double value, int expected)
 
     if (result != expected)
     {
-        Fail("ilogb(%g) returned %10.10g when it should have returned %10.10g",
+        Fail("ilogb(%g) returned %d when it should have returned %d",
              value, result, expected);
     }
 }
@@ -51,23 +51,23 @@ int __cdecl main(int argc, char **argv)
     struct test tests[] = 
     {
         /* value                       expected */
-        {  PAL_NEGINF,                 0x80000000 },
-        {  0,                          0x80000000 },
-        {  PAL_POSINF,                 0x80000000 },
-        {  0.11331473229676087,       -3          },   // expected: -(pi)
-        {  0.15195522325791297,       -2          },   // expected: -(e)
-        {  0.20269956628651730,       -2          },   // expected: -(ln(10))
-        {  0.33662253682241906,       -1          },   // expected: -(pi / 2)
-        {  0.36787944117144232,       -1          },   // expected: -(log2(e))
-        {  0.37521422724648177,       -1          },   // expected: -(sqrt(2))
-        {  0.45742934732229695,       -1          },   // expected: -(2 / sqrt(pi))
+        {  PAL_NEGINF,                 2147483647 },
+        {  0,                         -2147483648 },
+        {  PAL_POSINF,                 2147483647 },
+        {  0.11331473229676087,       -4          },   // expected: -(pi)
+        {  0.15195522325791297,       -3          },   // expected: -(e)
+        {  0.20269956628651730,       -3          },   // expected: -(ln(10))
+        {  0.33662253682241906,       -2          },   // expected: -(pi / 2)
+        {  0.36787944117144232,       -2          },   // expected: -(log2(e))
+        {  0.37521422724648177,       -2          },   // expected: -(sqrt(2))
+        {  0.45742934732229695,       -2          },   // expected: -(2 / sqrt(pi))
         {  0.5,                       -1          },   // expected: -(1)
-        {  0.58019181037172444,        0          },   // expected: -(pi / 4)
-        {  0.61254732653606592,        0          },   // expected: -(1 / sqrt(2))
-        {  0.61850313780157598,        0          },   // expected: -(ln(2))
-        {  0.64321824193300488,        0          },   // expected: -(2 / pi)
-        {  0.74005557395545179,        0          },   // expected: -(log10(e))
-        {  0.80200887896145195,        0          },   // expected: -(1 / pi)
+        {  0.58019181037172444,       -1          },   // expected: -(pi / 4)
+        {  0.61254732653606592,       -1          },   // expected: -(1 / sqrt(2))
+        {  0.61850313780157598,       -1          },   // expected: -(ln(2))
+        {  0.64321824193300488,       -1          },   // expected: -(2 / pi)
+        {  0.74005557395545179,       -1          },   // expected: -(log10(e))
+        {  0.80200887896145195,       -1          },   // expected: -(1 / pi)
         {  1,                          0          },
         {  1.2468689889006383,         0          },   // expected:  1 / pi
         {  1.3512498725672678,         0          },   // expected:  log10(e)
index b478f69..0bebef8 100644 (file)
@@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 2.8.12.2)
 set(CMAKE_INCLUDE_CURRENT_DIR ON)
 
 set(SOURCES
-  test1.c
+  test1.cpp
 )
 
 add_executable(paltest_ilogbf_test1
@@ -32,11 +32,11 @@ struct test
  */
 void __cdecl validate(float value, int expected)
 {
-    float result = ilogbf(value);
+    int result = ilogbf(value);
 
     if (result != expected)
     {
-        Fail("ilogbf(%g) returned %10.10g when it should have returned %10.10g",
+        Fail("ilogbf(%g) returned %d when it should have returned %d",
              value, result, expected);
     }
 }
@@ -51,23 +51,23 @@ int __cdecl main(int argc, char **argv)
     struct test tests[] = 
     {
         /* value                expected */
-        {  PAL_NEGINF,          0x80000000 },
-        {  0,                   0x80000000 },
-        {  PAL_POSINF,          0x80000000 },
-        {  0.113314732f,       -3          },   // expected: -(pi)
-        {  0.151955223f,       -2          },   // expected: -(e)
-        {  0.202699566f,       -2          },   // expected: -(ln(10))
-        {  0.336622537f,       -1          },   // expected: -(pi / 2)
-        {  0.367879441f,       -1          },   // expected: -(log2(e))
-        {  0.375214227f,       -1          },   // expected: -(sqrt(2))
-        {  0.457429347f,       -1          },   // expected: -(2 / sqrt(pi))
+        {  PAL_NEGINF,          2147483647 },
+        {  0,                  -2147483648 },
+        {  PAL_POSINF,          2147483647 },
+        {  0.113314732f,       -4          },   // expected: -(pi)
+        {  0.151955223f,       -3          },   // expected: -(e)
+        {  0.202699566f,       -3          },   // expected: -(ln(10))
+        {  0.336622537f,       -2          },   // expected: -(pi / 2)
+        {  0.367879441f,       -2          },   // expected: -(log2(e))
+        {  0.375214227f,       -2          },   // expected: -(sqrt(2))
+        {  0.457429347f,       -2          },   // expected: -(2 / sqrt(pi))
         {  0.5f,               -1          },   // expected: -(1)
-        {  0.580191810f,        0          },   // expected: -(pi / 4)
-        {  0.612547327f,        0          },   // expected: -(1 / sqrt(2))
-        {  0.618503138f,        0          },   // expected: -(ln(2))
-        {  0.643218242f,        0          },   // expected: -(2 / pi)
-        {  0.740055574f,        0          },   // expected: -(log10(e))
-        {  0.802008879f,        0          },   // expected: -(1 / pi)
+        {  0.580191810f,       -1          },   // expected: -(pi / 4)
+        {  0.612547327f,       -1          },   // expected: -(1 / sqrt(2))
+        {  0.618503138f,       -1          },   // expected: -(ln(2))
+        {  0.643218242f,       -1          },   // expected: -(2 / pi)
+        {  0.740055574f,       -1          },   // expected: -(log10(e))
+        {  0.802008879f,       -1          },   // expected: -(1 / pi)
         {  1,                   0          },
         {  1.24686899f,         0          },   // expected:  1 / pi
         {  1.35124987f,         0          },   // expected:  log10(e)
index c7900a0..0f73fa1 100644 (file)
@@ -128,7 +128,7 @@ int __cdecl main(int argc, char **argv)
 
     for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
     {
-        validate(tests[i].x, tests[i].y, tests[i].z, tests[i].expected, tests[i].variance);
+        validate(tests[i].value, tests[i].expected, tests[i].variance);
     }
 
     validate_isnan(PAL_NEGINF);
index 5231aa5..ed62e63 100644 (file)
@@ -127,7 +127,7 @@ int __cdecl main(int argc, char **argv)
 
     for (int i = 0; i < (sizeof(tests) / sizeof(struct test)); i++)
     {
-        validate(tests[i].x, tests[i].y, tests[i].z, tests[i].expected, tests[i].variance);
+        validate(tests[i].value, tests[i].expected, tests[i].variance);
     }
 
     validate_isnan(PAL_NEGINF);
index 43998d0..861892a 100644 (file)
@@ -41,6 +41,8 @@ c_runtime/fgets/test2/paltest_fgets_test2
 c_runtime/fgets/test3/paltest_fgets_test3
 c_runtime/floor/test1/paltest_floor_test1
 c_runtime/floorf/test1/paltest_floorf_test1
+c_runtime/fma/test1/paltest_fma_test1
+c_runtime/fmaf/test1/paltest_fmaf_test1
 c_runtime/fmod/test1/paltest_fmod_test1
 c_runtime/fmodf/test1/paltest_fmodf_test1
 c_runtime/fopen/test1/paltest_fopen_test1
@@ -93,6 +95,8 @@ c_runtime/getc/test1/paltest_getc_test1
 c_runtime/getenv/test1/paltest_getenv_test1
 c_runtime/getenv/test2/paltest_getenv_test2
 c_runtime/getenv/test3/paltest_getenv_test3
+c_runtime/ilogb/test1/paltest_ilogb_test1
+c_runtime/ilogbf/test1/paltest_ilogbf_test1
 c_runtime/isalnum/test1/paltest_isalnum_test1
 c_runtime/isalpha/test1/paltest_isalpha_test1
 c_runtime/isdigit/test1/paltest_isdigit_test1
@@ -110,6 +114,8 @@ c_runtime/labs/test1/paltest_labs_test1
 c_runtime/llabs/test1/paltest_llabs_test1
 c_runtime/localtime/test1/paltest_localtime_test1
 c_runtime/log/test1/paltest_log_test1
+c_runtime/log2/test1/paltest_log2_test1
+c_runtime/log2f/test1/paltest_log2f_test1
 c_runtime/log10/test1/paltest_log10_test1
 c_runtime/log10f/test1/paltest_log10f_test1
 c_runtime/logf/test1/paltest_logf_test1
@@ -147,6 +153,8 @@ c_runtime/qsort/test1/paltest_qsort_test1
 c_runtime/qsort/test2/paltest_qsort_test2
 c_runtime/rand_srand/test1/paltest_rand_srand_test1
 c_runtime/realloc/test1/paltest_realloc_test1
+c_runtime/scalbn/test1/paltest_scalbn_test1
+c_runtime/scalbnf/test1/paltest_scalbnf_test1
 c_runtime/sin/test1/paltest_sin_test1
 c_runtime/sinf/test1/paltest_sinf_test1
 c_runtime/sinh/test1/paltest_sinh_test1
index 697a080..b39e7e7 100644 (file)
@@ -160,6 +160,8 @@ c_runtime/fgets/test2,1
 c_runtime/fgets/test3,1
 c_runtime/floor/test1,1
 c_runtime/floorf/test1,1
+c_runtime/fma/test1,1
+c_runtime/fmaf/test1,1
 c_runtime/fmod/test1,1
 c_runtime/fmodf/test1,1
 c_runtime/fopen/test1,1
@@ -220,6 +222,8 @@ c_runtime/getc/test1,1
 c_runtime/getenv/test1,0
 c_runtime/getenv/test2,1
 c_runtime/getenv/test3,1
+c_runtime/ilogb/test1,1
+c_runtime/ilogbf/test1,1
 c_runtime/isalnum/test1,1
 c_runtime/isalpha/test1,1
 c_runtime/isdigit/test1,1
@@ -238,6 +242,8 @@ c_runtime/labs/test1,1
 c_runtime/llabs/test1,1
 c_runtime/localtime/test1,1
 c_runtime/log/test1,1
+c_runtime/log2/test1,1
+c_runtime/log2f/test1,1
 c_runtime/log10/test1,1
 c_runtime/log10f/test1,1
 c_runtime/logf/test1,1
@@ -273,6 +279,8 @@ c_runtime/qsort/test1,1
 c_runtime/qsort/test2,1
 c_runtime/rand_srand/test1,1
 c_runtime/realloc/test1,1
+c_runtime/scalbn/test1,1
+c_runtime/scalbnf/test1,1
 c_runtime/sin/test1,1
 c_runtime/sinf/test1,1
 c_runtime/sinh/test1,1
index 31d3661..6f812b3 100644 (file)
@@ -625,7 +625,7 @@ FCFuncStart(gMathFuncs)
     FCIntrinsic("Floor", COMDouble::Floor, CORINFO_INTRINSIC_Floor)
     FCFuncElement("FMod", COMDouble::FMod)
     FCFuncElement("FusedMultiplyAdd", COMDouble::FusedMultiplyAdd)
-    FCFuncElement("IlogB", COMDouble::IlogB)
+    FCFuncElement("ILogB", COMDouble::ILogB)
     FCFuncElement("Log", COMDouble::Log)
     FCFuncElement("Log2", COMDouble::Log2)
     FCIntrinsic("Log10", COMDouble::Log10, CORINFO_INTRINSIC_Log10)
@@ -655,7 +655,7 @@ FCFuncStart(gMathFFuncs)
     FCIntrinsic("Floor", COMSingle::Floor, CORINFO_INTRINSIC_Floor)
     FCFuncElement("FMod", COMSingle::FMod)
     FCFuncElement("FusedMultiplyAdd", COMSingle::FusedMultiplyAdd)
-    FCFuncElement("IlogB", COMSingle::IlogB)
+    FCFuncElement("ILogB", COMSingle::ILogB)
     FCFuncElement("Log", COMSingle::Log)
     FCFuncElement("Log2", COMSingle::Log2)
     FCIntrinsic("Log10", COMSingle::Log10, CORINFO_INTRINSIC_Log10)
index b784fbd..4520001 100644 (file)
                     "name": "System.Tests.ConvertToSingleTests.FromString",
                     "reason": "https://github.com/dotnet/coreclr/pull/20707"
                 },
+                {
+                    "name": "System.Tests.MathTests.Max_Double",
+                    "reason": "https://github.com/dotnet/coreclr/pull/20912"
+                },
+                {
+                    "name": "System.Tests.MathTests.Max_Single",
+                    "reason": "https://github.com/dotnet/coreclr/pull/20912"
+                },
+                {
+                    "name": "System.Tests.MathTests.Min_Double",
+                    "reason": "https://github.com/dotnet/coreclr/pull/20912"
+                },
+                {
+                    "name": "System.Tests.MathTests.Min_Single",
+                    "reason": "https://github.com/dotnet/coreclr/pull/20912"
+                },
+                {
+                    "name": "System.Tests.MathFTests.Max",
+                    "reason": "https://github.com/dotnet/coreclr/pull/20912"
+                },
+                {
+                    "name": "System.Tests.MathFTests.Min",
+                    "reason": "https://github.com/dotnet/coreclr/pull/20912"
+                },
             ]
         }
     },