From: Richard Guenther <richard.guenther@gmail.com>
To: Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
Cc: ebotcazou@adacore.com, gcc-patches@gcc.gnu.org, rguenther@suse.de
Subject: Re: [PATCH] Remove bogus TYPE_IS_SIZETYPE special-casing in extract_muldiv_1
Date: Sat, 03 Sep 2011 20:39:00 -0000 [thread overview]
Message-ID: <CAFiYyc3NLKJKYFmFM-K5tbYzNMB31+v=QYgUA5Ymk=5fG80yPg@mail.gmail.com> (raw)
In-Reply-To: <CAFiYyc3c0fT2KvM2JjaJFuvZV3nzGnKQU7rFV6v9f9D2c8_ufQ@mail.gmail.com>
On Sat, Sep 3, 2011 at 10:37 PM, Richard Guenther
<richard.guenther@gmail.com> wrote:
> On Sat, Sep 3, 2011 at 9:47 PM, Richard Kenner
> <kenner@vlsi1.ultra.nyu.edu> wrote:
>> Let me jump in on this a little bit, since much of the code in this area
>> was originally written by me.
>>
>>> Are all sizetype (sub-)expressions always of value in that range?
>>> What do we do about the fact that sizetype is unsigned, so -x always
>>> overflows for x != 0? Thus, do we need to disable all a - b -> a +
>>> -b kind of foldings for sizetypes? (we don't)
>>
>> The basic idea is that an overflow of sizetype is either:
>>
>> (1) Detected at a higher level (e.g., testing for maximum sizes of objects) or;
>> (2) Is an undetected error and hence the result of such overflow is undefined.
>>
>> What this means from a practical point of view (but indeed a bit hard
>> to define from a formal point of view) is that the normal addition and
>> subtraction operations (on a 2's complement machines, which all are
>> now) will "do the right thing" in all cases so we can perform all
>> those sorts of folding operations.
>
> So what's your opinion on the "bug" that triggered the patch in question?\
> Namely extract_muldiv_1 folding
>
> (((10240 - (sizetype) first) + 1) * 8) /[cl] 8
>
> to
>
> ((sizetype) first * 0x0fffffffffffffff8 + 81928) /[cl] 8
>
> to
>
> ((sizetype) first * 2305843009213693951 + 10241)
>
> thus, folding A - B to -B + A, which is valid for unsigned types only
> if overflow wraps. But the 2nd folding is only valid if overflow is undefined.
> Both foldings happen in extract_muldiv_1, the latter is especially
> enabled for TYPE_IS_SIZETYPE.
>
> The reasoning why both transforms are valid is bogus IMHO.
> Can you give a formal definition of sizetype behavior that can be
> used to prove that both transforms are valid?
And as you are here now, can you shed some light on the weird
decision to make sizetype TYPE_UNSIGNED but sign-extended
at the same time? ;)
Richard.
> Richard.
>
next prev parent reply other threads:[~2011-09-03 20:39 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-31 9:14 Richard Guenther
2011-09-02 8:37 ` Eric Botcazou
2011-09-02 9:05 ` Richard Guenther
2011-09-02 13:26 ` Eric Botcazou
2011-09-02 13:33 ` Richard Guenther
2011-09-03 9:23 ` Eric Botcazou
2011-09-03 11:57 ` Richard Guenther
2011-09-03 15:08 ` Eric Botcazou
2011-09-03 19:09 ` Richard Guenther
2011-09-03 19:47 ` Richard Kenner
2011-09-03 20:37 ` Richard Guenther
2011-09-03 20:39 ` Richard Guenther [this message]
2011-09-03 21:20 ` Richard Kenner
2011-09-03 21:20 ` Richard Kenner
2011-09-03 21:27 ` Richard Kenner
2011-09-05 7:33 ` Richard Guenther
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='CAFiYyc3NLKJKYFmFM-K5tbYzNMB31+v=QYgUA5Ymk=5fG80yPg@mail.gmail.com' \
--to=richard.guenther@gmail.com \
--cc=ebotcazou@adacore.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=kenner@vlsi1.ultra.nyu.edu \
--cc=rguenther@suse.de \
/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).