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]

Re: bug fix for expr.c:expand_block_move


>   > 	* expr.c (emit_block_move): A mode of BITS_PER_WORD may not
>   > 	be sufficient to hold a size.
> This is much more descriptive.  Though it seems to me we should be testing
> that the mode is as big as the size of the target's size_t.  Right?
> 
> And the code needs a comment indicating why it was changed.  It also seems

If I use TYPE_PRECISION (sizetype), wouldn't a comment become an
annoying tautology?  Unnecessary comments just bloat the code,
actually making it hardert to read:

          if (code != CODE_FOR_nothing
              /* We don't need MODE to be narrower than BITS_PER_HOST_WIDE_INT
                 here because if SIZE is less than the mode mask, as it is
                 returned by the macro, it will definitely be less than the
                 actual mode mask.  */
              && ((GET_CODE (size) == CONST_INT
                   && ((unsigned HOST_WIDE_INT) INTVAL (size)
                       <= (GET_MODE_MASK (mode) >> 1)))
                  /* Don't use BITS_PER_WORD here to check if the mode is
                     wide enough to accomodate a size because a size can be
		     larger than BITS_PER_WORD.  */
                  || GET_MODE_BITSIZE (mode) >= TYPE_PRECISION (sizetype))
              && ((pred = insn_data[(int) code].operand[0].predicate) == 0
                  || (*pred) (x, BLKmode))
              && ((pred = insn_data[(int) code].operand[1].predicate) == 0
                  || (*pred) (y, BLKmode))
              && ((pred = insn_data[(int) code].operand[3].predicate) == 0
                  || (*pred) (opalign, VOIDmode)))

If someone considered changing TYPE_PRECISION (sizetype) back to
BITS_PER_WORD, wouldn't the first question they ask themselves be:
are these two really equivalent?

> to me other places might have this problem (clear_storage and 
> emit_push_insn in particular).

Yes, they have.
Thu Mar  1 01:17:52 2001  J"orn Rennecke <amylaar@redhat.com>

	* expr.c (emit_block_move): A mode of BITS_PER_WORD may not
	be sufficient to hold a size.
	(clear_storage, emit_push_insn): Likewise.

Index: expr.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/expr.c,v
retrieving revision 1.436
diff -p -r1.436 expr.c
*** expr.c	2000/12/24 21:20:04	1.436
--- expr.c	2001/03/01 01:18:29
*************** emit_block_move (x, y, size, align)
*** 1671,1677 ****
  	      && ((GET_CODE (size) == CONST_INT
  		   && ((unsigned HOST_WIDE_INT) INTVAL (size)
  		       <= (GET_MODE_MASK (mode) >> 1)))
! 		  || GET_MODE_BITSIZE (mode) >= BITS_PER_WORD)
  	      && ((pred = insn_data[(int) code].operand[0].predicate) == 0
  		  || (*pred) (x, BLKmode))
  	      && ((pred = insn_data[(int) code].operand[1].predicate) == 0
--- 1671,1677 ----
  	      && ((GET_CODE (size) == CONST_INT
  		   && ((unsigned HOST_WIDE_INT) INTVAL (size)
  		       <= (GET_MODE_MASK (mode) >> 1)))
! 		  || GET_MODE_BITSIZE (mode) >= TYPE_PRECISION (sizetype))
  	      && ((pred = insn_data[(int) code].operand[0].predicate) == 0
  		  || (*pred) (x, BLKmode))
  	      && ((pred = insn_data[(int) code].operand[1].predicate) == 0
*************** clear_storage (object, size, align)
*** 2571,2577 ****
  		  && ((GET_CODE (size) == CONST_INT
  		       && ((unsigned HOST_WIDE_INT) INTVAL (size)
  			   <= (GET_MODE_MASK (mode) >> 1)))
! 		      || GET_MODE_BITSIZE (mode) >= BITS_PER_WORD)
  		  && ((pred = insn_data[(int) code].operand[0].predicate) == 0
  		      || (*pred) (object, BLKmode))
  		  && ((pred = insn_data[(int) code].operand[2].predicate) == 0
--- 2571,2577 ----
  		  && ((GET_CODE (size) == CONST_INT
  		       && ((unsigned HOST_WIDE_INT) INTVAL (size)
  			   <= (GET_MODE_MASK (mode) >> 1)))
! 		      || GET_MODE_BITSIZE (mode) >= TYPE_PRECISION (sizetype))
  		  && ((pred = insn_data[(int) code].operand[0].predicate) == 0
  		      || (*pred) (object, BLKmode))
  		  && ((pred = insn_data[(int) code].operand[2].predicate) == 0
*************** emit_push_insn (x, mode, type, size, ali
*** 3324,3330 ****
  		      && ((GET_CODE (size) == CONST_INT
  			   && ((unsigned HOST_WIDE_INT) INTVAL (size)
  			       <= (GET_MODE_MASK (mode) >> 1)))
! 			  || GET_MODE_BITSIZE (mode) >= BITS_PER_WORD)
  		      && (!(pred = insn_data[(int) code].operand[0].predicate)
  			  || ((*pred) (target, BLKmode)))
  		      && (!(pred = insn_data[(int) code].operand[1].predicate)
--- 3324,3331 ----
  		      && ((GET_CODE (size) == CONST_INT
  			   && ((unsigned HOST_WIDE_INT) INTVAL (size)
  			       <= (GET_MODE_MASK (mode) >> 1)))
! 			  || (GET_MODE_BITSIZE (mode)
! 			      >= TYPE_PRECISION (sizetype)))
  		      && (!(pred = insn_data[(int) code].operand[0].predicate)
  			  || ((*pred) (target, BLKmode)))
  		      && (!(pred = insn_data[(int) code].operand[1].predicate)


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