diff mbox

patch to fix PR58348

Message ID 5239F01A.4050705@redhat.com
State New
Headers show

Commit Message

Vladimir Makarov Sept. 18, 2013, 6:25 p.m. UTC
The following patch fixes

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58438

The patch was successfully bootstrapped and tested on x86/x86-64.

Committed as rev. 202714.

2013-09-18  Vladimir Makarov  <vmakarov@redhat.com>

        PR rtl-optimization/58438
        * lra.c (lra): Clear lra_optional_reload_pseudos in upper loop.
        * lra-constraints.c (undo_optional_reloads): Keep optional reloads
        from previous subpasses.

2013-09-18  Vladimir Makarov  <vmakarov@redhat.com>

        PR rtl-optimization/58438
        * g++.dg/pr58438.C: New test.
diff mbox

Patch

Index: lra.c
===================================================================
--- lra.c	(revision 202626)
+++ lra.c	(working copy)
@@ -2315,7 +2315,6 @@  lra (FILE *f)
     {
       for (;;)
 	{
-	  bitmap_clear (&lra_optional_reload_pseudos);
 	  /* We should try to assign hard registers to scratches even
 	     if there were no RTL transformations in
 	     lra_constraints.  */
@@ -2367,6 +2366,9 @@  lra (FILE *f)
 		lra_clear_live_ranges ();
 	    }
 	}
+      /* Don't clear optional reloads bitmap until all constraints are
+	 satisfied as we need to differ them from regular reloads.  */
+      bitmap_clear (&lra_optional_reload_pseudos);
       bitmap_clear (&lra_subreg_reload_pseudos);
       bitmap_clear (&lra_inheritance_pseudos);
       bitmap_clear (&lra_split_regs);
Index: lra-constraints.c
===================================================================
--- lra-constraints.c	(revision 202630)
+++ lra-constraints.c	(working copy)
@@ -5456,10 +5456,12 @@  undo_optional_reloads (void)
   EXECUTE_IF_SET_IN_BITMAP (&lra_optional_reload_pseudos, 0, regno, bi)
     {
       keep_p = false;
-      if (reg_renumber[lra_reg_info[regno].restore_regno] >= 0)
-	/* If the original pseudo changed its allocation, just
-	   removing the optional pseudo is dangerous as the original
-	   pseudo will have longer live range.  */
+      /* Keep optional reloads from previous subpasses.  */
+      if (lra_reg_info[regno].restore_regno < 0
+	  /* If the original pseudo changed its allocation, just
+	     removing the optional pseudo is dangerous as the original
+	     pseudo will have longer live range.  */
+	  || reg_renumber[lra_reg_info[regno].restore_regno] >= 0)
 	keep_p = true;
       else if (reg_renumber[regno] >= 0)
 	EXECUTE_IF_SET_IN_BITMAP (&lra_reg_info[regno].insn_bitmap, 0, uid, bi2)