public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Vladimir Makarov <vmakarov@redhat.com>
To: Jakub Jelinek <jakub@redhat.com>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [PR103437] [committed] IRA: Process multiplication overflow in priority calculation for allocno assignments
Date: Thu, 2 Dec 2021 09:23:20 -0500	[thread overview]
Message-ID: <3bb6317f-b049-13f1-1bac-6ffd753e9685@redhat.com> (raw)
In-Reply-To: <20211202140021.GH2646553@tucnak>


On 2021-12-02 09:00, Jakub Jelinek wrote:
> On Thu, Dec 02, 2021 at 08:53:31AM -0500, Vladimir Makarov via Gcc-patches wrote:
>> The following patch fixes
>>
>> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103437
>>
>> The patch was successfully bootstrapped and tested on x86-64. There is no
>> test as the bug occurs on GCC built with sanitizing for an existing go test.
> I'm afraid we can't use __builtin_smul_overflow, not all system compilers
> will have that.
> But, as it is done in int and we kind of rely on int being 32-bit on host
> and rely on long long being 64-bit, I think you can do something like:
>        long long priorityll = (long long) mult * diff;
>        priority = priorityll;
>        if (priorityll != priority
> ...
>
>
My 1st version of the patch was based on long long but the standard does 
not guarantee that int size is smaller than long long size.  Although it 
is true for all targets supported by GCC.

Another solution would be to switching to int32_t instead of int for 
costs but it will require a lot of changes in RA code.

I see your point for usage system compiler different from GCC and LLVM.  
I guess I could change it to

#if __GNUC__ >= 5

current code

#else

long long code

#endif


What do you think?



  reply	other threads:[~2021-12-02 14:23 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-02 13:53 Vladimir Makarov
2021-12-02 14:00 ` Jakub Jelinek
2021-12-02 14:23   ` Vladimir Makarov [this message]
2021-12-02 14:29     ` Jakub Jelinek
2021-12-02 14:38       ` Vladimir Makarov
2021-12-02 15:52         ` Christophe Lyon
2021-12-02 16:03           ` Vladimir Makarov
2021-12-02 16:13             ` Jakub Jelinek
2021-12-02 17:06               ` Vladimir Makarov
2021-12-02 17:21                 ` Vladimir Makarov
2021-12-02 17:44                   ` 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=3bb6317f-b049-13f1-1bac-6ffd753e9685@redhat.com \
    --to=vmakarov@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    /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).