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] Possible fix for PR middle-end/6600?




Many thanks for the review.

> I'd write the STORE_MAX_PIECES comment differently.
Ok.

> There is the question of whether STORE_MAX_PIECES should be documented,
> but since this is a macro that shouldn't be defined in any tm.h file, I
> don't think it needs documentation.  I could be wrong here though.

STORE_MAX_PIECES is an internal macro to expr.c.  By defining it just
once in the file, we avoid a cryptic expression at several places and
it provides a convenient location to give a sizeable comment describing
why it is needed.  You'll notice that we don't check to see if
STORE_MAX_PIECES was previously defined, which we'd need to do if it
were a target macro.

> I think the patch is OK for gcc 3.2, with a more accurate
> STORE_MAX_PIECES comment.
>
> I noticed that can_store_by_pieces is missing an explanatory comment
> before the function.  If you wanted to add that in too, that would be
> even better.


Thanks.  Is the following the sort of thing you had in mind?  The only
changes from the previous version are to the text of the comments.

Is this revision ok for 3.2 and to close PR mid/6600?


2002-05-17  Roger Sayle  <roger@eyesopen.com>

	PR middle-end/6600
	* expr.c (STORE_MAX_PIECES): New macro to avoid immediate constants
	larger than INTEGER_CST.  (store_by_pieces_1): Use it here...
	(can_store_by_pieces): ... and here to limit the largest mode used.
	Add a comment to document this function.


Index: expr.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expr.c,v
retrieving revision 1.454
diff -c -3 -p -r1.454 expr.c
*** expr.c	13 May 2002 04:50:10 -0000	1.454
--- expr.c	18 May 2002 02:30:52 -0000
*************** convert_modes (mode, oldmode, x, unsigne
*** 1403,1408 ****
--- 1403,1415 ----
  #define MOVE_MAX_PIECES   MOVE_MAX
  #endif

+ /* STORE_MAX_PIECES is the number of bytes at a time that we can
+    store efficiently.  Due to internal GCC limitations, this is
+    MOVE_MAX_PIECES limited by the number of bytes GCC can represent
+    for an immediate constant.  */
+
+ #define STORE_MAX_PIECES  MIN (MOVE_MAX_PIECES, 2 * sizeof (HOST_WIDE_INT))
+
  /* Generate several move instructions to copy LEN bytes from block FROM to
     block TO.  (These are MEM rtx's with BLKmode).  The caller must pass FROM
     and TO through protect_from_queue before calling.
*************** use_group_regs (call_fusage, regs)
*** 2334,2339 ****
--- 2341,2352 ----
  }


+ /* Determine whether the LEN bytes generated by CONSTFUN can be
+    stored to memory using several move instructions.  CONSTFUNDATA is
+    a pointer which will be passed as argument in every CONSTFUN call.
+    ALIGN is maximum alignment we can assume.  Return nonzero if a
+    call to store_by_pieces should succeed.  */
+
  int
  can_store_by_pieces (len, constfun, constfundata, align)
       unsigned HOST_WIDE_INT len;
*************** can_store_by_pieces (len, constfun, cons
*** 2364,2370 ****
      {
        l = len;
        mode = VOIDmode;
!       max_size = MOVE_MAX_PIECES + 1;
        while (max_size > 1)
  	{
  	  for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT);
--- 2377,2383 ----
      {
        l = len;
        mode = VOIDmode;
!       max_size = STORE_MAX_PIECES + 1;
        while (max_size > 1)
  	{
  	  for (tmode = GET_CLASS_NARROWEST_MODE (MODE_INT);
*************** store_by_pieces_1 (data, align)
*** 2475,2481 ****
       unsigned int align;
  {
    rtx to_addr = XEXP (data->to, 0);
!   unsigned HOST_WIDE_INT max_size = MOVE_MAX_PIECES + 1;
    enum machine_mode mode = VOIDmode, tmode;
    enum insn_code icode;

--- 2488,2494 ----
       unsigned int align;
  {
    rtx to_addr = XEXP (data->to, 0);
!   unsigned HOST_WIDE_INT max_size = STORE_MAX_PIECES + 1;
    enum machine_mode mode = VOIDmode, tmode;
    enum insn_code icode;


Roger
--


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