This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH libquadmath/PR68686]


On 11/3/18 10:09 PM, Jeff Law wrote:
On 10/23/18 7:45 PM, Ed Smith-Rowland wrote:
Greetings,

This is an almost trivial patch to get the correct sign for tgammaq.

I don't have a testcase as I don't know where to put one.

OK?

Ed Smith-Rowland



tgammaq.CL

2018-10-24  Edward Smith-Rowland  <3dw4rd@verizon.net>

	PR libquadmath/68686
	* math/tgammaq.c: Correct sign for negative argument.
I don't have the relevant background to evaluate this for correctness.
Can you refer back to any kind of documentation which indicates what the
sign of the return value ought to be?

Alternately, if you can point to the relevant code in glibc that handles
the resultant sign, that'd be useful too.

Note that Joseph's follow-up doesn't touch on the gamma problem AFAICT,
but instead touches on the larger issues around trying to keep the
quadmath implementations between glibc and gcc more in sync.

Jeff

I've looked at glibc lgamma, in particular signgam and I think those DTRT:


I'm pretty sure the lgamma that write to global signgam and the lgamma_r(x, int *signgam) DTRT.

The various __lgamma_neg* DTRT:

__lgamma_negX (REALTYPE x, int *signgamp)
{
  /* Determine the half-integer region X lies in, handle exact
     integers and determine the sign of the result.  */
  int i = __floorl (-2 * x);
  if ((i & 1) == 0 && i == -2 * x)
    return 1.0L / 0.0L;
  long double xn = ((i & 1) == 0 ? -i / 2 : (-i - 1) / 2);
  i -= 4;
  *signgamp = ((i & 2) == 0 ? -1 : 1);
...

I think the various e_lgammaX_r.c are good too:

  if (se & 0x8000)
    {
      if (x < -2.0L && x > -33.0L)
    return __lgamma_negl (x, signgamp);
      t = sin_pi (x);
      if (t == zero)
    return one / fabsl (t);    /* -integer */
      nadj = __ieee754_logl (pi / fabsl (t * x));
      if (t < zero)
    *signgamp = -1;
      x = -x;
    }

I *do* think a couple tests should be added to test-signgam-*.c to test alternation of signs:
      signgam = 123;                        \
      c = FUNC (b);                        \
      if (signgam == 1)                        \

    puts ("PASS: " #FUNC " (-1.5) setting signgam");    \

      else                            \
    {                            \
      puts ("FAIL: " #FUNC " (-1.5) setting signgam");    \
      result = 1;                        \
    }                            \

Add to test lgamma_negX code paths...
      signgam = 123;                        \
      c = FUNC (b);                        \
      if (signgam == -1)                    \
    puts ("PASS: " #FUNC " (-34.5) setting signgam");    \
      else                            \
    {                            \
      puts ("FAIL: " #FUNC " (-34.5) setting signgam"); \
      result = 1;                        \
    }                            \
      signgam = 123;                        \
      c = FUNC (b);                        \
      if (signgam == 1)                        \
    puts ("PASS: " #FUNC " (-35.5) setting signgam");    \
      else                            \
    {                            \
      puts ("FAIL: " #FUNC " (-35.5) setting signgam"); \
      result = 1;                        \
    }                            \


I've not dealt with glibc directly.  Do I need separate Copyright and all that?  Is it similar to gcc in terms of devel?



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]