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]

expr.c bugfix


In some peculiar circumstacnes, clear_storage can be called with a size
that doesn't correspond to that of non-BLKmode object.  It used to do
the wrong thing in such cases (the test case is in Ada).

Fri Sep  1 10:59:47 2000  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* expr.c (clear_storage): Don't use emit_move_insn unless
	either BLKmode or proper size.
	(store_constructor): Don't call clear_storage if REG of wrong size.

*** expr.c	2000/08/30 02:00:55	1.256
--- expr.c	2000/09/01 14:29:08
*************** clear_storage (object, size, align)
*** 2393,2397 ****
    rtx retval = 0;
  
!   if (GET_MODE (object) == BLKmode)
      {
        object = protect_from_queue (object, 1);
--- 2393,2403 ----
    rtx retval = 0;
  
!   /* If OBJECT is not BLKmode and SIZE is the same size as its mode,
!      just move a zero.  Otherwise, do this a piece at a time.  */
!   if (GET_MODE (object) != BLKmode
!       && GET_CODE (size) == CONST_INT
!       && GET_MODE_SIZE (GET_MODE (object)) == INTVAL (size))
!     emit_move_insn (object, CONST0_RTX (GET_MODE (object)));
!   else
      {
        object = protect_from_queue (object, 1);
*************** clear_storage (object, size, align)
*** 2545,2550 ****
  	}
      }
-   else
-     emit_move_insn (object, CONST0_RTX (GET_MODE (object)));
  
    return retval;
--- 2551,2554 ----
*************** store_constructor (exp, target, align, c
*** 4264,4272 ****
        /* If the constructor has fewer fields than the structure
  	 or if we are initializing the structure to mostly zeros,
! 	 clear the whole structure first.  */
        else if (size > 0
  	       && ((list_length (CONSTRUCTOR_ELTS (exp))
  		    != fields_length (type))
! 		   || mostly_zeros_p (exp)))
  	{
  	  if (! cleared)
--- 4268,4280 ----
        /* If the constructor has fewer fields than the structure
  	 or if we are initializing the structure to mostly zeros,
! 	 clear the whole structure first.  Don't do this is TARGET is
! 	 register whose mode size isn't equal to SIZE since clear_storage
! 	 can't handle this case.  */
        else if (size > 0
  	       && ((list_length (CONSTRUCTOR_ELTS (exp))
  		    != fields_length (type))
! 		   || mostly_zeros_p (exp))
! 	       && (GET_CODE (target) != REG
! 		   || GET_MODE_SIZE (GET_MODE (target)) == size))
  	{
  	  if (! cleared)

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