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: new real.c implementation


On Mon, Sep 16, 2002 at 06:08:12PM -0400, John David Anglin wrote:
> internal compiler error: in simplify_unary_operation, at simplify-rtx.c:607
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.

I had mis-read the documentation for FIX with a floating-point
destination mode.  This was compounded by the fact that we used
to also handle UNSIGNED_FIX here which _is_ undefined with a
floating-point destination mode.  So I had removed them all.

Fixed thus.


r~


        * real.c (do_fix_trunc): New.
        (real_arithmetic): Call it.
        * simplify-rtx.c (simplify_unary_operation): Handle FIX
        with a floating-point result mode.

Index: real.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/real.c,v
retrieving revision 1.83
diff -c -p -d -r1.83 real.c
*** real.c	17 Sep 2002 01:28:48 -0000	1.83
--- real.c	17 Sep 2002 01:57:38 -0000
*************** static void do_divide PARAMS ((struct re
*** 174,179 ****
--- 174,181 ----
  			       const struct real_value *));
  static int do_compare PARAMS ((const struct real_value *,
  			       const struct real_value *, int));
+ static void do_fix_trunc PARAMS ((struct real_value *,
+ 				  const struct real_value *));
  
  static const struct real_value * ten_to_ptwo PARAMS ((int));
  static const struct real_value * real_digit PARAMS ((int));
*************** do_compare (a, b, nan_result)
*** 1013,1018 ****
--- 1015,1048 ----
    return (a->sign ? -ret : ret);
  }
  
+ /* Return A truncated to an integral value toward zero.  */
+ 
+ void
+ do_fix_trunc (r, a)
+      struct real_value *r;
+      const struct real_value *a;
+ {
+   *r = *a;
+ 
+   switch (a->class)
+     {
+     case rvc_zero:
+     case rvc_inf:
+     case rvc_nan:
+       break;
+ 
+     case rvc_normal:
+       if (r->exp <= 0)
+ 	get_zero (r, r->sign);
+       else if (r->exp < SIGNIFICAND_BITS)
+ 	clear_significand_below (r, SIGNIFICAND_BITS - r->exp);
+       break;
+ 
+     default:
+       abort ();
+     }
+ }
+ 
  /* Perform the binary or unary operation described by CODE.
     For a unary operation, leave OP1 NULL.  */
  
*************** real_arithmetic (tr, icode, top0, top1)
*** 1071,1076 ****
--- 1101,1110 ----
      case ABS_EXPR:
        *r = *op0;
        r->sign = 0;
+       break;
+ 
+     case FIX_TRUNC_EXPR:
+       do_fix_trunc (r, op0);
        break;
  
      default:
Index: simplify-rtx.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/simplify-rtx.c,v
retrieving revision 1.120
diff -c -p -d -r1.120 simplify-rtx.c
*** simplify-rtx.c	16 Sep 2002 16:36:33 -0000	1.120
--- simplify-rtx.c	17 Sep 2002 01:57:38 -0000
*************** simplify_unary_operation (code, mode, op
*** 599,608 ****
  	  /* We don't attempt to optimize this.  */
  	  return 0;
  
! 	case ABS:	      d = REAL_VALUE_ABS (d);			break;
! 	case NEG:	      d = REAL_VALUE_NEGATE (d);		break;
! 	case FLOAT_TRUNCATE:  d = real_value_truncate (mode, d);	break;
! 	case FLOAT_EXTEND:    /* All this does is change the mode.  */  break;
  	default:
  	  abort ();
  	}
--- 599,620 ----
  	  /* We don't attempt to optimize this.  */
  	  return 0;
  
! 	case ABS:
! 	  d = REAL_VALUE_ABS (d);
! 	  break;
! 	case NEG:
! 	  d = REAL_VALUE_NEGATE (d);
! 	  break;
! 	case FLOAT_TRUNCATE:
! 	  d = real_value_truncate (mode, d);
! 	  break;
! 	case FLOAT_EXTEND:
! 	  /* All this does is change the mode.  */
! 	  break;
! 	case FIX:
! 	  real_arithmetic (&d, FIX_TRUNC_EXPR, &d, NULL);
! 	  break;
! 
  	default:
  	  abort ();
  	}


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