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 in reload_cse_move2add()


On Jan  1, 2001, Alexandre Oliva <aoliva@redhat.com> wrote:

> Ok to install?  Tested on i686-pc-linux-gnu.

Oops.  I've posted the wrong version of the patch.  This one would
crash should reg_base_offset[regno] be NULL_RTX.  Curiously, this was
indeed the version I had tested on i686-pc-linux-gnu, without any
regressions (yes, I've just double-checked that I did test the
outdated version on x86), but the fix was necessary on another port.
Here's the corrected patch.  Ok to install?

Index: gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* reload1.c (reg_base_offset): New array.
	(reload_cse_move2add): Take it into account.
	(move2add_note_store): Set it.

Index: gcc/reload1.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/reload1.c,v
retrieving revision 1.247
diff -u -p -r1.247 reload1.c
--- gcc/reload1.c 2000/12/19 16:10:19 1.247
+++ gcc/reload1.c 2001/01/01 13:24:39
@@ -8893,9 +8893,13 @@ static int reg_set_luid[FIRST_PSEUDO_REG
    has been set to reg_offset[n] in mode reg_mode[n] .
    If reg_offset[n] is a CONST_INT and reg_base_reg[n] is non-negative,
    register n has been set to the sum of reg_offset[n] and register
-   reg_base_reg[n], calculated in mode reg_mode[n] .  */
+   reg_base_reg[n], calculated in mode reg_mode[n] .
+   If reg_base_offset[n] is a copy of reg_offset[reg_base_reg[n]] at
+   reg_set_luid[reg_base_reg[n]] .  It is only valid when
+   reg_base_reg[n] is valid and non-negative.  */
 static rtx reg_offset[FIRST_PSEUDO_REGISTER];
 static int reg_base_reg[FIRST_PSEUDO_REGISTER];
+static rtx reg_base_offset[FIRST_PSEUDO_REGISTER];
 static enum machine_mode reg_mode[FIRST_PSEUDO_REGISTER];
 
 /* move2add_luid is linearily increased while scanning the instructions
@@ -9027,6 +9031,13 @@ reload_cse_move2add (first)
 		      rtx new_src
 			= gen_mode_int (GET_MODE (reg),
 					INTVAL (src3)
+					+ (reg_base_offset[regno]
+					   && (GET_CODE
+					       (reg_base_offset[regno])
+					       == CONST_INT)
+					   ? (INTVAL (reg_offset[REGNO (src)])
+					      - INTVAL (reg_base_offset[regno])
+					      ) : 0)
 					- INTVAL (reg_offset[regno]));
 		      int success = 0;
 
@@ -9053,6 +9064,7 @@ reload_cse_move2add (first)
 		      reg_set_luid[regno] = move2add_luid;
 		      reg_mode[regno] = GET_MODE (reg);
 		      reg_offset[regno] = src3;
+		      reg_base_offset[regno] = reg_offset[REGNO (src)];
 		      continue;
 		    }
 		}
@@ -9149,10 +9161,13 @@ move2add_note_store (dst, set, data)
 		    || reg_offset[regno] != const0_rtx)
 		  {
 		    reg_base_reg[regno] = REGNO (src0);
+		    reg_offset[regno] = XEXP (src, 1);
+		    reg_base_offset[regno] = reg_offset[REGNO (src0)];
 		    reg_set_luid[regno] = move2add_luid;
 		  }
+		else
+		  reg_offset[regno] = XEXP (src, 1);
 
-		reg_offset[regno] = XEXP (src, 1);
 		break;
 	      }
 
@@ -9162,8 +9177,9 @@ move2add_note_store (dst, set, data)
 	  }
 
 	case REG:
-	  reg_base_reg[regno] = REGNO (SET_SRC (set));
 	  reg_offset[regno] = const0_rtx;
+	  reg_base_reg[regno] = REGNO (SET_SRC (set));
+	  reg_base_offset[regno] = reg_offset[REGNO (SET_SRC (set))];
 	  reg_set_luid[regno] = move2add_luid;
 	  break;
 

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

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