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]

Re: patch to fix PR70703




On 04/05/2017 11:25 AM, Jakub Jelinek wrote:
On Wed, Apr 05, 2017 at 11:11:54AM -0400, Vladimir Makarov wrote:
--- ira-color.c	(revision 246536)
+++ ira-color.c	(working copy)
@@ -1367,6 +1367,16 @@ update_costs_from_allocno (ira_allocno_t
  	      || ALLOCNO_ASSIGNED_P (another_allocno))
  	    continue;
+ if (GET_MODE_SIZE (ALLOCNO_MODE (cp->second)) < GET_MODE_SIZE (mode))
+	    /* If we have different modes use the smallest one.  It is
+	       a sub-register move.  It is hard to predict what LRA
+	       will reload (the pseudo or its sub-register) but LRA
+	       will try to minimize the data movement.  Also for some
+	       register classes bigger modes might be invalid,
+	       e.g. DImode for AREG on x86.  For such cases the
+	       register move cost will be maximal. */
+	    mode = ALLOCNO_MODE (cp->second);
+	
  	  cost = (cp->second == allocno
  		  ? ira_register_move_cost[mode][rclass][aclass]
  		  : ira_register_move_cost[mode][aclass][rclass]);
@@ -1512,7 +1522,7 @@ update_conflict_hard_regno_costs (int *c
  		index = ira_class_hard_reg_index[aclass][hard_regno];
  		if (index < 0)
  		  continue;
-		cost = (int) ((unsigned) conflict_costs [i] * mult) / div;
+		cost = (int) (((long) conflict_costs [i] * mult) / div);
If you want something wider than unsigned, wouldn't it be better to
use HOST_WIDE_INT then?  Otherwise it will work differently between
32-bit and 64-bit hosts.
Can any of those 3 values be negative?  If not, perhaps
unsigned HOST_WIDE_INT?

Thank you for finding this, Jakub. The overflow might happen only when 65K is used for ira_register_move_cost which means an impossible move in most cases. Still if it happens in rare cases, the behavior might be different for the native and a cross.

I'll correct the patch.


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