Blame SOURCES/gcc34-sw2438.patch

6fdc0f
2006-05-23  Alexandre Oliva  <aoliva@redhat.com>
6fdc0f
6fdc0f
	* simplify-rtx.c (simplify_subreg): Adjust REG_OFFSET for
6fdc0f
	big-endian paradoxical subregs.
6fdc0f
	* var-tracking.c (struct micro_operation_def): Document that,
6fdc0f
	for modify micro operations, insn is the subsequent instruction.
6fdc0f
	(var_reg_delete_and_set, var_mem_delete_and_set): Split into...
6fdc0f
	(var_reg_set, var_mem_set): ... new functions.
6fdc0f
	(add_stores): Record subsequent insn.
6fdc0f
	(compute_bb_dataflow): Use new functions for MO_USE.
6fdc0f
	(emit_notes_in_bb): Use new functions for MO_USE.  Emit use
6fdc0f
	notes after the insn, and modify notes before the insn known
6fdc0f
	to be the subsequent one.
6fdc0f
	(vt_initialize): Invert sorting of MO_CLOBBERs and MO_SETs.
6fdc0f
6fdc0f
--- gcc/simplify-rtx.c	2005-11-21 11:55:29.000000000 -0200
6fdc0f
+++ gcc/simplify-rtx.c	2006-05-16 01:47:01.000000000 -0300
6fdc0f
@@ -3473,7 +3473,22 @@ simplify_subreg (enum machine_mode outer
6fdc0f
       if (HARD_REGNO_MODE_OK (final_regno, outermode)
6fdc0f
 	  || ! HARD_REGNO_MODE_OK (REGNO (op), innermode))
6fdc0f
 	{
6fdc0f
-	  rtx x = gen_rtx_REG_offset (op, outermode, final_regno, byte);
6fdc0f
+	  rtx x;
6fdc0f
+	  int final_offset = byte;
6fdc0f
+
6fdc0f
+	  /* Adjust offset for paradoxical subregs.  */
6fdc0f
+	  if (byte == 0
6fdc0f
+	      && GET_MODE_SIZE (innermode) < GET_MODE_SIZE (outermode))
6fdc0f
+	    {
6fdc0f
+	      int difference = (GET_MODE_SIZE (innermode)
6fdc0f
+				- GET_MODE_SIZE (outermode));
6fdc0f
+	      if (WORDS_BIG_ENDIAN)
6fdc0f
+		final_offset += (difference / UNITS_PER_WORD) * UNITS_PER_WORD;
6fdc0f
+	      if (BYTES_BIG_ENDIAN)
6fdc0f
+		final_offset += difference % UNITS_PER_WORD;
6fdc0f
+	    }
6fdc0f
+
6fdc0f
+	  x = gen_rtx_REG_offset (op, outermode, final_regno, final_offset);
6fdc0f
 
6fdc0f
 	  /* Propagate original regno.  We don't have any way to specify
6fdc0f
 	     the offset inside original regno, so do so only for lowpart.
6fdc0f
--- gcc/var-tracking.c	2006-05-10 17:17:51.000000000 -0300
6fdc0f
+++ gcc/var-tracking.c	2006-05-16 03:25:32.000000000 -0300
6fdc0f
@@ -138,7 +138,11 @@ typedef struct micro_operation_def
6fdc0f
     HOST_WIDE_INT adjust;
6fdc0f
   } u;
6fdc0f
 
6fdc0f
-  /* The instruction which the micro operation is in.  */
6fdc0f
+  /* The instruction which the micro operation is in, for MO_USE,
6fdc0f
+     MO_USE_NO_VAR, MO_CALL and MO_ADJUST, or the subsequent
6fdc0f
+     instruction or note in the original flow (before any var-tracking
6fdc0f
+     notes are inserted, to simplify emission of notes), for MO_SET
6fdc0f
+     and MO_CLOBBER.  */
6fdc0f
   rtx insn;
6fdc0f
 } micro_operation;
6fdc0f
 
6fdc0f
@@ -289,9 +293,11 @@ static void vars_clear (htab_t);
6fdc0f
 static variable unshare_variable (dataflow_set *set, variable var);
6fdc0f
 static int vars_copy_1 (void **, void *);
6fdc0f
 static void vars_copy (htab_t, htab_t);
6fdc0f
+static void var_reg_set (dataflow_set *, rtx);
6fdc0f
 static void var_reg_delete_and_set (dataflow_set *, rtx);
6fdc0f
 static void var_reg_delete (dataflow_set *, rtx);
6fdc0f
 static void var_regno_delete (dataflow_set *, int);
6fdc0f
+static void var_mem_set (dataflow_set *, rtx);
6fdc0f
 static void var_mem_delete_and_set (dataflow_set *, rtx);
6fdc0f
 static void var_mem_delete (dataflow_set *, rtx);
6fdc0f
 
6fdc0f
@@ -788,6 +794,19 @@ vars_copy (htab_t dst, htab_t src)
6fdc0f
   htab_traverse (src, vars_copy_1, dst);
6fdc0f
 }
6fdc0f
 
6fdc0f
+/* Set the register to contain REG_EXPR (LOC), REG_OFFSET (LOC).  */
6fdc0f
+
6fdc0f
+static void
6fdc0f
+var_reg_set (dataflow_set *set, rtx loc)
6fdc0f
+{
6fdc0f
+  tree decl = REG_EXPR (loc);
6fdc0f
+  HOST_WIDE_INT offset = REG_OFFSET (loc);
6fdc0f
+
6fdc0f
+  if (set->regs[REGNO (loc)] == NULL)
6fdc0f
+    attrs_list_insert (&set->regs[REGNO (loc)], decl, offset, loc);
6fdc0f
+  set_variable_part (set, loc, decl, offset);
6fdc0f
+}
6fdc0f
+
6fdc0f
 /* Delete current content of register LOC in dataflow set SET
6fdc0f
    and set the register to contain REG_EXPR (LOC), REG_OFFSET (LOC).  */
6fdc0f
 
6fdc0f
@@ -815,9 +834,7 @@ var_reg_delete_and_set (dataflow_set *se
6fdc0f
 	  nextp = &node->next;
6fdc0f
 	}
6fdc0f
     }
6fdc0f
-  if (set->regs[REGNO (loc)] == NULL)
6fdc0f
-    attrs_list_insert (&set->regs[REGNO (loc)], decl, offset, loc);
6fdc0f
-  set_variable_part (set, loc, decl, offset);
6fdc0f
+  var_reg_set (set, loc);
6fdc0f
 }
6fdc0f
 
6fdc0f
 /* Delete current content of register LOC in dataflow set SET.  */
6fdc0f
@@ -854,12 +871,12 @@ var_regno_delete (dataflow_set *set, int
6fdc0f
   *reg = NULL;
6fdc0f
 }
6fdc0f
 
6fdc0f
-/* Delete and set the location part of variable MEM_EXPR (LOC)
6fdc0f
-   in dataflow set SET to LOC.
6fdc0f
+/* Set the location part of variable MEM_EXPR (LOC) in dataflow set
6fdc0f
+   SET to LOC.
6fdc0f
    Adjust the address first if it is stack pointer based.  */
6fdc0f
 
6fdc0f
 static void
6fdc0f
-var_mem_delete_and_set (dataflow_set *set, rtx loc)
6fdc0f
+var_mem_set (dataflow_set *set, rtx loc)
6fdc0f
 {
6fdc0f
   tree decl = MEM_EXPR (loc);
6fdc0f
   HOST_WIDE_INT offset = MEM_OFFSET (loc) ? INTVAL (MEM_OFFSET (loc)) : 0;
6fdc0f
@@ -867,6 +884,16 @@ var_mem_delete_and_set (dataflow_set *se
6fdc0f
   set_variable_part (set, loc, decl, offset);
6fdc0f
 }
6fdc0f
 
6fdc0f
+/* Delete and set the location part of variable MEM_EXPR (LOC)
6fdc0f
+   in dataflow set SET to LOC.
6fdc0f
+   Adjust the address first if it is stack pointer based.  */
6fdc0f
+
6fdc0f
+static void
6fdc0f
+var_mem_delete_and_set (dataflow_set *set, rtx loc)
6fdc0f
+{
6fdc0f
+  var_mem_set (set, loc);
6fdc0f
+}
6fdc0f
+
6fdc0f
 /* Delete the location part LOC from dataflow set SET.
6fdc0f
    Adjust the address first if it is stack pointer based.  */
6fdc0f
 
6fdc0f
@@ -1547,7 +1574,7 @@ add_stores (rtx loc, rtx expr, void *ins
6fdc0f
 		   && track_expr_p (REG_EXPR (loc)))
6fdc0f
 		  ? MO_SET : MO_CLOBBER);
6fdc0f
       mo->u.loc = loc;
6fdc0f
-      mo->insn = (rtx) insn;
6fdc0f
+      mo->insn = NEXT_INSN ((rtx) insn);
6fdc0f
     }
6fdc0f
   else if (GET_CODE (loc) == MEM
6fdc0f
 	   && MEM_EXPR (loc)
6fdc0f
@@ -1558,7 +1585,7 @@ add_stores (rtx loc, rtx expr, void *ins
6fdc0f
 
6fdc0f
       mo->type = GET_CODE (expr) == CLOBBER ? MO_CLOBBER : MO_SET;
6fdc0f
       mo->u.loc = loc;
6fdc0f
-      mo->insn = (rtx) insn;
6fdc0f
+      mo->insn = NEXT_INSN ((rtx) insn);
6fdc0f
     }
6fdc0f
 }
6fdc0f
 
6fdc0f
@@ -1589,6 +1616,16 @@ compute_bb_dataflow (basic_block bb)
6fdc0f
 	    break;
6fdc0f
 
6fdc0f
 	  case MO_USE:
6fdc0f
+	    {
6fdc0f
+	      rtx loc = VTI (bb)->mos[i].u.loc;
6fdc0f
+
6fdc0f
+	      if (GET_CODE (loc) == REG)
6fdc0f
+		var_reg_set (out, loc);
6fdc0f
+	      else if (GET_CODE (loc) == MEM)
6fdc0f
+		var_mem_set (out, loc);
6fdc0f
+	    }
6fdc0f
+	    break;
6fdc0f
+
6fdc0f
 	  case MO_SET:
6fdc0f
 	    {
6fdc0f
 	      rtx loc = VTI (bb)->mos[i].u.loc;
6fdc0f
@@ -2364,6 +2401,18 @@ emit_notes_in_bb (basic_block bb)
6fdc0f
 	    break;
6fdc0f
 
6fdc0f
 	  case MO_USE:
6fdc0f
+	    {
6fdc0f
+	      rtx loc = VTI (bb)->mos[i].u.loc;
6fdc0f
+
6fdc0f
+	      if (GET_CODE (loc) == REG)
6fdc0f
+		var_reg_set (&set, loc);
6fdc0f
+	      else
6fdc0f
+		var_mem_set (&set, loc);
6fdc0f
+
6fdc0f
+	      emit_notes_for_changes (insn, EMIT_NOTE_AFTER_INSN);
6fdc0f
+	    }
6fdc0f
+	    break;
6fdc0f
+
6fdc0f
 	  case MO_SET:
6fdc0f
 	    {
6fdc0f
 	      rtx loc = VTI (bb)->mos[i].u.loc;
6fdc0f
@@ -2373,10 +2422,7 @@ emit_notes_in_bb (basic_block bb)
6fdc0f
 	      else
6fdc0f
 		var_mem_delete_and_set (&set, loc);
6fdc0f
 
6fdc0f
-	      if (VTI (bb)->mos[i].type == MO_USE)
6fdc0f
-		emit_notes_for_changes (insn, EMIT_NOTE_BEFORE_INSN);
6fdc0f
-	      else
6fdc0f
-		emit_notes_for_changes (insn, EMIT_NOTE_AFTER_INSN);
6fdc0f
+	      emit_notes_for_changes (insn, EMIT_NOTE_BEFORE_INSN);
6fdc0f
 	    }
6fdc0f
 	    break;
6fdc0f
 
6fdc0f
@@ -2391,9 +2437,9 @@ emit_notes_in_bb (basic_block bb)
6fdc0f
 		var_mem_delete (&set, loc);
6fdc0f
 
6fdc0f
 	      if (VTI (bb)->mos[i].type == MO_USE_NO_VAR)
6fdc0f
-		emit_notes_for_changes (insn, EMIT_NOTE_BEFORE_INSN);
6fdc0f
-	      else
6fdc0f
 		emit_notes_for_changes (insn, EMIT_NOTE_AFTER_INSN);
6fdc0f
+	      else
6fdc0f
+		emit_notes_for_changes (insn, EMIT_NOTE_BEFORE_INSN);
6fdc0f
 	    }
6fdc0f
 	    break;
6fdc0f
 
6fdc0f
@@ -2616,15 +2662,18 @@ vt_initialize (void)
6fdc0f
 		}
6fdc0f
 
6fdc0f
 	      n1 = VTI (bb)->n_mos;
6fdc0f
+	      /* This will record NEXT_INSN (insn), such that we can
6fdc0f
+		 insert notes before it without worrying about any
6fdc0f
+		 notes that MO_USEs might emit after the insn.  */
6fdc0f
 	      note_stores (PATTERN (insn), add_stores, insn);
6fdc0f
 	      n2 = VTI (bb)->n_mos - 1;
6fdc0f
 
6fdc0f
-	      /* Order the MO_SETs to be before MO_CLOBBERs.  */
6fdc0f
+	      /* Order the MO_CLOBBERs to be before MO_SETs.  */
6fdc0f
 	      while (n1 < n2)
6fdc0f
 		{
6fdc0f
-		  while (n1 < n2 && VTI (bb)->mos[n1].type == MO_SET)
6fdc0f
+		  while (n1 < n2 && VTI (bb)->mos[n1].type == MO_CLOBBER)
6fdc0f
 		    n1++;
6fdc0f
-		  while (n1 < n2 && VTI (bb)->mos[n2].type == MO_CLOBBER)
6fdc0f
+		  while (n1 < n2 && VTI (bb)->mos[n2].type == MO_SET)
6fdc0f
 		    n2--;
6fdc0f
 		  if (n1 < n2)
6fdc0f
 		    {