diff mbox

ira: Respect HARD_REGNO_CALL_PART_CLOBBERED

Message ID 4CD96AF8.3010500@redhat.com
State New
Headers show

Commit Message

Vladimir Makarov Nov. 9, 2010, 3:38 p.m. UTC
On 11/08/2010 11:08 AM, Andreas Krebbel wrote:
> Hi Vladimir,
>
> here are updated versions of the patches.
>
> I've verified that the 4.5 as well as the mainline version still fixes
> the testcase for me.
>
> Ok for 4.5 and mainline?
>
> Bye,
>
> -Andreas-
>
>
> 2010-11-08  Andreas Krebbel<Andreas.Krebbel@de.ibm.com>
>
> 	PR rtl-optimization/46237
> 	* ira-conflicts.c (ira_build_conflicts): Record conflicts for call
> 	saved hard regs if they might get partially clobbered.
>
>
> For GCC mainline:
>
> Index: gcc/ira-conflicts.c
> ===================================================================
> *** gcc/ira-conflicts.c.orig
> --- gcc/ira-conflicts.c
> *************** ira_build_conflicts (void)
> *** 882,887 ****
> --- 882,888 ----
>    	  ira_object_t obj = ALLOCNO_OBJECT (a, i);
>    	  reg_attrs *attrs = REG_ATTRS (regno_reg_rtx [ALLOCNO_REGNO (a)]);
>    	  tree decl;
> + 	  int regno;
>
>    	  if ((! flag_caller_saves&&  ALLOCNO_CALLS_CROSSED_NUM (a) != 0)
>    	      /* For debugging purposes don't put user defined variables in
> *************** ira_build_conflicts (void)
> *** 896,901 ****
> --- 897,912 ----
>    				call_used_reg_set);
>    	      IOR_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj),
>    				call_used_reg_set);
> +
> + 	      /* Allocnos bigger than the saved part of call saved
> + 		 regs must conflict with them.  */
> + 	      for (regno = 0; regno<  FIRST_PSEUDO_REGISTER; regno++)
> + 		if (!TEST_HARD_REG_BIT (call_used_reg_set, regno)
> + 		&&   HARD_REGNO_CALL_PART_CLOBBERED (regno, obj->allocno->mode))
> + 		  {
> + 		    SET_HARD_REG_BIT (OBJECT_CONFLICT_HARD_REGS (obj), regno);
> + 		    SET_HARD_REG_BIT (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj), regno);
> + 		  }
>    	    }
>    	  else if (ALLOCNO_CALLS_CROSSED_NUM (a) != 0)
>    	    {
>
It is close but the code should work independently from -fcaller-saves.  
So it should look like the patch in the attachment.

And gcc4.5 patch change should be analogous.

With this change, the patch is ok for trunk and gcc4.5.

Thanks for working on the PR.
diff mbox

Patch

Index: ira-conflicts.c
===================================================================
--- ira-conflicts.c	(revision 165518)
+++ ira-conflicts.c	(working copy)
@@ -877,6 +884,8 @@  ira_build_conflicts (void)
   FOR_EACH_ALLOCNO (a, ai)
     {
       int i, n = ALLOCNO_NUM_OBJECTS (a);
+      int regno;
+
       for (i = 0; i < n; i++)
 	{
 	  ira_object_t obj = ALLOCNO_OBJECT (a, i);
@@ -907,6 +916,21 @@  ira_build_conflicts (void)
 				no_caller_save_reg_set);
 	      IOR_HARD_REG_SET (OBJECT_CONFLICT_HARD_REGS (obj),
 				temp_hard_reg_set);
+
+	    }
+	  if (ALLOCNO_CALLS_CROSSED_NUM (a) != 0)
+	    {
+	      /* Allocnos bigger than the saved part of call saved
+		 regs must conflict with them.  */
+	      for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
+		if (!TEST_HARD_REG_BIT (call_used_reg_set, regno)
+		    && HARD_REGNO_CALL_PART_CLOBBERED (regno,
+						       obj->allocno->mode))
+		  {
+		    SET_HARD_REG_BIT (OBJECT_CONFLICT_HARD_REGS (obj), regno);
+		    SET_HARD_REG_BIT (OBJECT_TOTAL_CONFLICT_HARD_REGS (obj),
+				      regno);
+		  }
 	    }
 	}
     }