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]

Patch and testcase regarding predecrement addressing modesandreload_cse_move2add


	This patch fixes a problem first noticed against the h8300 backend
by which reload_cse_move2add would wrongly optimize a block of insns if an
insn within it contained an incrementing or decrementing side-effect
because of an incrementing or decrementing addressing mode. The testcase
fails on an unpatched h8300 toolchain, though it has not yet been run
against other toolchains that also use pre-decrement addressing.

Wed Sep 13 00:08:30 2000  Joern Rennecke <amylaar@redhat.co.uk>

	* reload1.c (move2add_note_store): Check for simple
	auto-inc in destination.

2000-09-25  Matthew Hiller  <hiller@redhat.com>

	* testsuite/gcc.c-torture/execute/autodec-addressing.c: New
	testcase that will fail if reload_cse_move2add wrongly optimizes a
	block of code in which one of the insns has an
	incrementing/decrementing side effect but no REG_INC note.

Index: reload1.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/reload1.c,v
retrieving revision 1.229
diff -c -3 -p -r1.229 reload1.c
*** reload1.c	2000/09/18 17:00:07	1.229
--- reload1.c	2000/09/26 01:25:13
*************** move2add_note_store (dst, set, data)
*** 9019,9024 ****
--- 9019,9038 ----
        dst = SUBREG_REG (dst);
      }
  
+   /* Some targets do argument pushes without adding REG_INC notes.  */
+ 
+   if (GET_CODE (dst) == MEM)
+     {
+       dst = XEXP (dst, 0);
+       if (GET_CODE (dst) == PRE_INC || GET_CODE (dst) == POST_DEC
+ 	  || GET_CODE (dst) == PRE_DEC || GET_CODE (dst) == POST_DEC)
+ 	{
+ 	  regno = REGNO (XEXP (dst, 0));
+ 	  reg_set_luid[regno] = move2add_luid;
+ 	  reg_offset[regno] = dst;
+ 	}
+       return;
+     } 
    if (GET_CODE (dst) != REG)
      return;
  
Index: testsuite/gcc.c-torture/execute/autodec-addressing.c
===================================================================
diff -c3p /dev/null testsuite/gcc.c-torture/execute/autodec-addressing.c
*** /dev/null	Tue May  5 13:32:27 1998
--- testsuite/gcc.c-torture/execute/autodec-addressing.c	Mon Sep 25 18:08:31 2000
***************
*** 0 ****
--- 1,17 ----
+ void
+ fn_4parms (unsigned char a, long *b, long *c, unsigned int *d)
+ {
+   if (*b != 1 || *c != 2 || *d != 3)
+     abort ();
+ }
+ 
+ int
+ main ()
+ {
+   unsigned char a = 0;
+   unsigned long b = 1, c = 2;
+   unsigned int d = 3;
+ 
+   fn_4parms (a, &b, &c, &d);
+   return 0;
+ }


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