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]

PATCH generate PRE_MODIFY expressions


While adding the pre/post modify support for the ARM I noticed that the 
compiler never attempted to generate the PRE_MODIFY expressions.  This 
patch adds support for doing that, though it should be noted that because 
of the way we currently search for these we probably miss the most common 
case.  At present it is necessary to have code that looks something like

struct a{
  char b;
  char c;
};

int foo(struct a *x)
{
  while (x->c)
    {
      x[1].b = x->b;
      x++;
    }
}

to generate them.  That is, the memory reference has to contain an offset 
and the increment has to follow the reference.  The obvious case of

	while (x->c)
	  (++x)->b = 5;

is currently missed.

Tested by bootstrapping on arm-netbsdelf.

2003-01-15  Richard Earnshaw  <rearnsha@arm.com>

	* flow.c (find_auto_inc): Also try to generate a PRE_MODIFY with
	constant offset.


Index: flow.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/flow.c,v
retrieving revision 1.543
diff -p -r1.543 flow.c
*** flow.c	20 Dec 2002 01:18:41 -0000	1.543
--- flow.c	15 Jan 2003 15:55:57 -0000
*************** find_auto_inc (pbi, x, insn)
*** 3521,3526 ****
--- 3521,3532 ----
  			  incr, addr);
        else if (HAVE_POST_MODIFY_DISP && offset == 0)
  	attempt_auto_inc (pbi, gen_rtx_POST_MODIFY (Pmode, addr,
+ 						    gen_rtx_PLUS (Pmode,
+ 								  addr,
+ 								  inc_val)),
+ 			  insn, x, incr, addr);
+       else if (HAVE_PRE_MODIFY_DISP && offset == INTVAL (inc_val))
+ 	attempt_auto_inc (pbi, gen_rtx_PRE_MODIFY (Pmode, addr,
  						    gen_rtx_PLUS (Pmode,
  								  addr,
  								  inc_val)),

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