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]

RFA: patch to solve PR39522


The following patch solves PR39522. The details of the problem can be found on

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

This patch actually a small corrections of my patch for PR37514. It should behave the same way as the previous patch in all situations when gcc with the previous patch is not aborting on gcc_assert. So I believe the patch is safe.

Successfully bootstrapped and tested on x86_64 and ia64 (a target with heavy usages of INC/DEC addressing).

Ok to commit?

2009-03-25 Vladimir Makarov <vmakarov@redhat.com>

   PR rtl-optimization/39522
   * reload1.c (reload_as_needed): Invalidate reg_last_reload_reg too
   when reg_reloaded_valid is set.

Index: reload1.c
===================================================================
--- reload1.c	(revision 145015)
+++ reload1.c	(working copy)
@@ -4367,29 +4367,39 @@ reload_as_needed (int live_known)
 		      SET_REGNO_REG_SET (&reg_has_output_reload,
 					 REGNO (XEXP (in_reg, 0)));
 		    }
-		  else if ((code == PRE_INC || code == PRE_DEC
-			    || code == POST_INC || code == POST_DEC))
+		  else if (code == PRE_INC || code == PRE_DEC
+			   || code == POST_INC || code == POST_DEC)
 		    {
-		      int in_hard_regno;
 		      int in_regno = REGNO (XEXP (in_reg, 0));
 
 		      if (reg_last_reload_reg[in_regno] != NULL_RTX)
 			{
+			  int in_hard_regno;
+			  bool forget_p = true;
+
 			  in_hard_regno = REGNO (reg_last_reload_reg[in_regno]);
-			  gcc_assert (TEST_HARD_REG_BIT (reg_reloaded_valid,
-							 in_hard_regno));
-			  for (x = old_prev ? NEXT_INSN (old_prev) : insn;
-			       x != old_next;
-			       x = NEXT_INSN (x))
-			    if (x == reg_reloaded_insn[in_hard_regno])
-			      break;
+			  if (TEST_HARD_REG_BIT (reg_reloaded_valid,
+						 in_hard_regno))
+			    {
+			      for (x = old_prev ? NEXT_INSN (old_prev) : insn;
+				   x != old_next;
+				   x = NEXT_INSN (x))
+				if (x == reg_reloaded_insn[in_hard_regno])
+				  {
+				    forget_p = false;
+				    break;
+				  }
+			    }
 			  /* If for some reasons, we didn't set up
 			     reg_last_reload_reg in this insn,
 			     invalidate inheritance from previous
 			     insns for the incremented/decremented
 			     register.  Such registers will be not in
-			     reg_has_output_reload.  */
-			  if (x == old_next)
+			     reg_has_output_reload.  Invalidate it
+			     also if the corresponding element in
+			     reg_reloaded_insn is also
+			     invalidated.  */
+			  if (forget_p)
 			    forget_old_reloads_1 (XEXP (in_reg, 0),
 						  NULL_RTX, NULL);
 			}

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