This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix real.c corner cases
- From: Brad Lucier <lucier at math dot purdue dot edu>
- To: gcc-patches at gcc dot gnu dot org
- Cc: lucier at math dot purdue dot edu (Brad Lucier)
- Date: Fri, 18 Oct 2002 10:25:37 -0500 (EST)
- Subject: [PATCH] Fix real.c corner cases
This patch fixes some corner cases in IEEE arithemetic. Bootstrap and
make check on sparc-sun-solaris2.8; a few new failures, but they are all
branch-probability failures and I believe they are caused by the naming
problems for the .da files that a recent patch proposes to fix.
* real.c (do_add): fix IEEE corner cases.
(do_divide): Same.
===================================================================
RCS file: RCS/real.c,v
retrieving revision 1.1
diff -cp -r1.1 real.c
*** real.c 2002/10/18 00:19:10 1.1
--- real.c 2002/10/18 00:57:34
*************** do_add (r, a, b, subtract_p)
*** 569,576 ****
switch (CLASS2 (a->class, b->class))
{
case CLASS2 (rvc_zero, rvc_zero):
! /* +-0 +/- +-0 = +0. */
! get_zero (r, 0);
return;
case CLASS2 (rvc_zero, rvc_normal):
--- 569,583 ----
switch (CLASS2 (a->class, b->class))
{
case CLASS2 (rvc_zero, rvc_zero):
! /* (0.) - (0.)= 0.
! (-0.) - (-0.)= 0.
! (0.) - (-0.)= 0.
! (-0.) - (0.)=-0
! (0.) + (0.)= 0.
! (-0.) + (-0.)=-0.
! (0.) + (-0.)= 0.
! (-0.) + (0.)= 0. */
! get_zero (r, a->sign & (b->sign ^ subtract_p));
return;
case CLASS2 (rvc_zero, rvc_normal):
*************** do_add (r, a, b, subtract_p)
*** 600,610 ****
return;
case CLASS2 (rvc_inf, rvc_inf):
! if (subtract_p)
! /* Inf - Inf = NaN. */
get_canonical_qnan (r, 0);
else
- /* Inf + Inf = Inf. */
*r = *a;
return;
--- 607,623 ----
return;
case CLASS2 (rvc_inf, rvc_inf):
! /* (Inf) - (Inf) = NaN.
! (-Inf) - (-Inf) = NaN.
! (Inf) - (-Inf) = Inf.
! (-Inf) - (Inf) = -Inf.
! (Inf) + (Inf) = Inf.
! (-Inf) + (-Inf) = -Inf.
! (Inf) + (-Inf) = NaN.
! (-Inf) + (Inf) = -NaN. */
! if (subtract_p ^ a->sign ^ b->sign)
get_canonical_qnan (r, 0);
else
*r = *a;
return;
*************** do_divide (r, a, b)
*** 829,836 ****
{
case CLASS2 (rvc_zero, rvc_zero):
/* 0 / 0 = NaN. */
- case CLASS2 (rvc_inf, rvc_zero):
- /* Inf / 0 = NaN. */
case CLASS2 (rvc_inf, rvc_inf):
/* Inf / Inf = NaN. */
get_canonical_qnan (r, sign);
--- 842,847 ----
*************** do_divide (r, a, b)
*** 847,852 ****
--- 858,865 ----
case CLASS2 (rvc_normal, rvc_zero):
/* R / 0 = Inf. */
+ case CLASS2 (rvc_inf, rvc_zero):
+ /* Inf / 0 = Inf. */
get_inf (r, sign);
return;