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]

PR61919: Invalid rtx sharing in tree-outof-ssa.c


PR 61919 is another ripple from the patch to take advantage of rtx
sharing rules when instantiating virtual registers.  In this case
the invalid sharing is coming from tree-outof-ssa.c, where the same
MEM rtx is being used in several moves.  (Note that despite the name,
partition_to_pseudo maps to stack slot MEMs as well as pseudos.)

Tested on x86_64-linux-gnu.  Also tested by Andreas on ia64,
where the testsuite regression showed up.  OK to install?

Thanks,
Richard


gcc/
	PR middle-end/61919
	* tree-outof-ssa.c (insert_partition_copy_on_edge)
	(insert_value_copy_on_edge, insert_rtx_to_part_on_edge)
	(insert_part_to_rtx_on_edge): Copy partition_to_pseudo rtxes before
	inserting them in the insn stream.

Index: gcc/tree-outof-ssa.c
===================================================================
--- gcc/tree-outof-ssa.c	2014-07-26 21:14:51.074755469 +0100
+++ gcc/tree-outof-ssa.c	2014-07-26 21:14:51.590759910 +0100
@@ -260,8 +260,8 @@ insert_partition_copy_on_edge (edge e, i
     set_curr_insn_location (locus);
 
   var = partition_to_var (SA.map, src);
-  seq = emit_partition_copy (SA.partition_to_pseudo[dest],
-			     SA.partition_to_pseudo[src],
+  seq = emit_partition_copy (copy_rtx (SA.partition_to_pseudo[dest]),
+			     copy_rtx (SA.partition_to_pseudo[src]),
 			     TYPE_UNSIGNED (TREE_TYPE (var)),
 			     var);
 
@@ -274,7 +274,7 @@ insert_partition_copy_on_edge (edge e, i
 static void
 insert_value_copy_on_edge (edge e, int dest, tree src, source_location locus)
 {
-  rtx seq, x;
+  rtx dest_rtx, seq, x;
   enum machine_mode dest_mode, src_mode;
   int unsignedp;
   tree var;
@@ -289,7 +289,8 @@ insert_value_copy_on_edge (edge e, int d
       fprintf (dump_file, "\n");
     }
 
-  gcc_assert (SA.partition_to_pseudo[dest]);
+  dest_rtx = copy_rtx (SA.partition_to_pseudo[dest]);
+  gcc_assert (dest_rtx);
 
   set_location_for_edge (e);
   /* If a locus is provided, override the default.  */
@@ -300,9 +301,9 @@ insert_value_copy_on_edge (edge e, int d
 
   var = SSA_NAME_VAR (partition_to_var (SA.map, dest));
   src_mode = TYPE_MODE (TREE_TYPE (src));
-  dest_mode = GET_MODE (SA.partition_to_pseudo[dest]);
+  dest_mode = GET_MODE (dest_rtx);
   gcc_assert (src_mode == TYPE_MODE (TREE_TYPE (var)));
-  gcc_assert (!REG_P (SA.partition_to_pseudo[dest])
+  gcc_assert (!REG_P (dest_rtx)
 	      || dest_mode == promote_decl_mode (var, &unsignedp));
 
   if (src_mode != dest_mode)
@@ -312,15 +313,14 @@ insert_value_copy_on_edge (edge e, int d
     }
   else if (src_mode == BLKmode)
     {
-      x = SA.partition_to_pseudo[dest];
+      x = dest_rtx;
       store_expr (src, x, 0, false);
     }
   else
-    x = expand_expr (src, SA.partition_to_pseudo[dest],
-		     dest_mode, EXPAND_NORMAL);
+    x = expand_expr (src, dest_rtx, dest_mode, EXPAND_NORMAL);
 
-  if (x != SA.partition_to_pseudo[dest])
-    emit_move_insn (SA.partition_to_pseudo[dest], x);
+  if (x != dest_rtx)
+    emit_move_insn (dest_rtx, x);
   seq = get_insns ();
   end_sequence ();
 
@@ -356,7 +356,7 @@ insert_rtx_to_part_on_edge (edge e, int
      mems.  Usually we give the source.  As we result from SSA names
      the left and right size should be the same (and no WITH_SIZE_EXPR
      involved), so it doesn't matter.  */
-  seq = emit_partition_copy (SA.partition_to_pseudo[dest],
+  seq = emit_partition_copy (copy_rtx (SA.partition_to_pseudo[dest]),
 			     src, unsignedsrcp,
 			     partition_to_var (SA.map, dest));
 
@@ -390,7 +390,7 @@ insert_part_to_rtx_on_edge (edge e, rtx
 
   var = partition_to_var (SA.map, src);
   seq = emit_partition_copy (dest,
-			     SA.partition_to_pseudo[src],
+			     copy_rtx (SA.partition_to_pseudo[src]),
 			     TYPE_UNSIGNED (TREE_TYPE (var)),
 			     var);
 


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