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] SSA expand: Convert mode when copying between partition base vars


Hi Michael,

s390 currently doesn't bootstrap. It fails since emit_move_insn is
invoked with two rtxs having a different mode. The insert_* functions
call emit_move_insn to copy between two partition base variables.
This doesn't work out if the source or destination variable has been
promoted to a different type. The attached patch adds a call to
convert_to_mode when emitting the move.

With that patch the bootstrap gets significantly farther and dies due
to genautomata eating up all the memory :(

Ok?

Bye,

-Andreas-

2009-04-27  Andreas Krebbel  <krebbel1@de.ibm.com>

	* gcc/tree-outof-ssa.c (insert_partition_copy_on_edge,
	insert_rtx_to_part_on_edge, insert_part_to_rtx_on_edge): Convert
	the src rtx since src or dest might be promoted to a larger type.


Index: gcc/gcc/tree-outof-ssa.c
===================================================================
--- gcc.orig/gcc/tree-outof-ssa.c
+++ gcc/gcc/tree-outof-ssa.c
@@ -133,7 +133,8 @@ set_location_for_edge (edge e)
 static void
 insert_partition_copy_on_edge (edge e, int dest, int src)
 {
-  rtx seq;
+  rtx seq, x;
+  enum machine_mode mode;
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
       fprintf (dump_file,
@@ -149,10 +150,17 @@ insert_partition_copy_on_edge (edge e, i
 
   set_location_for_edge (e);
 
-  /* Partition copy between same base variables only, so it's the same mode,
-     hence we can use emit_move_insn.  */
+  /* Partition copy between same base variables only, but the src
+     might be a parameter promoted to a different type.  */
   start_sequence ();
-  emit_move_insn (SA.partition_to_pseudo[dest], SA.partition_to_pseudo[src]);
+  mode = GET_MODE (SA.partition_to_pseudo[dest]);
+  x = SA.partition_to_pseudo[src];
+  if (GET_MODE (x) != mode)
+    x = convert_to_mode (mode, x,
+			 TYPE_UNSIGNED (TREE_TYPE (
+			   partition_to_var (SA.map, src))));
+  if (x != SA.partition_to_pseudo[dest])
+    emit_move_insn (SA.partition_to_pseudo[dest], x);
   seq = get_insns ();
   end_sequence ();
 
@@ -200,7 +208,7 @@ insert_value_copy_on_edge (edge e, int d
 static void
 insert_rtx_to_part_on_edge (edge e, int dest, rtx src)
 {
-  rtx seq;
+  rtx seq, x;
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
       fprintf (dump_file,
@@ -215,8 +223,14 @@ insert_rtx_to_part_on_edge (edge e, int 
   set_location_for_edge (e);
 
   start_sequence ();
-  gcc_assert (GET_MODE (src) == GET_MODE (SA.partition_to_pseudo[dest]));
-  emit_move_insn (SA.partition_to_pseudo[dest], src);
+  x = SA.partition_to_pseudo[dest];
+  if (GET_MODE (src) != GET_MODE (x))
+    x = convert_to_mode (GET_MODE (x), src,
+			 TYPE_UNSIGNED (TREE_TYPE (
+			   partition_to_var (SA.map, dest))));
+
+  emit_move_insn (SA.partition_to_pseudo[dest], x);
+
   seq = get_insns ();
   end_sequence ();
 
@@ -229,7 +243,7 @@ insert_rtx_to_part_on_edge (edge e, int 
 static void
 insert_part_to_rtx_on_edge (edge e, rtx dest, int src)
 {
-  rtx seq;
+  rtx seq, x;
   if (dump_file && (dump_flags & TDF_DETAILS))
     {
       fprintf (dump_file,
@@ -244,8 +258,13 @@ insert_part_to_rtx_on_edge (edge e, rtx 
   set_location_for_edge (e);
 
   start_sequence ();
-  gcc_assert (GET_MODE (dest) == GET_MODE (SA.partition_to_pseudo[src]));
-  emit_move_insn (dest, SA.partition_to_pseudo[src]);
+  x = SA.partition_to_pseudo[src];
+  if (GET_MODE (dest) != GET_MODE (x))
+    x = convert_to_mode (GET_MODE (dest), x,
+			 TYPE_UNSIGNED (TREE_TYPE (
+			   partition_to_var (SA.map, src))));
+
+  emit_move_insn (dest, x);
   seq = get_insns ();
   end_sequence ();
 


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