public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Vladimir Makarov <vmakarov@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: Re: patch to fix PR70703
Date: Wed, 05 Apr 2017 16:07:00 -0000	[thread overview]
Message-ID: <36aee908-ddad-4524-c7c6-d52c2567847a@redhat.com> (raw)
In-Reply-To: <20170405152500.GT17461@tucnak>



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.

  reply	other threads:[~2017-04-05 16:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-04-05 15:11 Vladimir Makarov
2017-04-05 15:25 ` Jakub Jelinek
2017-04-05 16:07   ` Vladimir Makarov [this message]
2017-04-05 16:18     ` Vladimir Makarov
2017-04-06 10:24       ` Richard Biener
2017-04-07 16:07         ` Vladimir Makarov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=36aee908-ddad-4524-c7c6-d52c2567847a@redhat.com \
    --to=vmakarov@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).