https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109008

--- Comment #37 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I've additionally ran
#include <math.h>

#include "pr109008-4.c"

struct S { float (*fn) (float); float lb, ub; };
struct S arr[] = {
#include "pr109008-4.h"
};

int
main ()
{
  float plus_inf = __builtin_inf ();
  float minus_inf = -plus_inf;
  for (int i = 0; i < sizeof (arr) / sizeof (arr[0]); ++i)
    {
      int n1, n2;
      float lb = nextafterf (arr[i].lb, minus_inf);
      float ub = nextafterf (arr[i].ub, plus_inf);
      if (!__builtin_isnan (arr[i].fn (lb)) || !__builtin_isnan (arr[i].fn
(ub)))
        __builtin_printf ("%p err\n", arr[i].fn);
      lb = arr[i].lb;
      ub = arr[i].ub;
      for (n1 = 0; n1 < 50; n1++)
        if (!__builtin_isnan (arr[i].fn (lb)))
          break;
        else if (lb > ub)
          {
            n1 = -1;
            n2 = -1;
            break;
          }
        else
          lb = nextafterf (lb, plus_inf);
      if (n1 != -1)
        for (n2 = 0; n2 < 50; n2++)
          if (!__builtin_isnan (arr[i].fn (ub)))
            break;
          else
            ub = nextafterf (ub, minus_inf);
      __builtin_printf ("%d %d\n", n1, n2);
    }
}
on the header from the #c32+#c33 patches, and
./pr109008-4-main 2>&1 | sort | uniq -c | sort -n
      1 1 11
      1 11 1
      1 1 17
      1 1 25
      1 1 28
      1 1 3
      1 1 4
      1 19 1
      1 2 13
      1 2 16
      1 2 17
      1 2 36
      1 2 40
      1 3 2
      1 39 1
      1 5 1
      1 5 2
      2 1 32
      2 1 7
      2 3 1
      2 3 50
      3 4 1
     12 50 2
     16 2 50
     27 50 1
     39 1 50
     48 32 32
     53 33 33
     57 17 17
     73 16 16
     77 8 8
     78 9 9
    114 4 4
    124 5 5
    170 3 3
   8533 2 2
  15203 1 1
  24287 50 50
  59288 2 1
  59613 1 2
 130096 -1 -1

The -1 -1 case means that in reality the range is empty (UNDEFINED), there are
no values of eps for which the function returns it, as the difference in
exponents is too large for such a number to exist.  50 means actually 50 or
more ulps.

Reply via email to