From: Jakub Jelinek <jakub@redhat.com>
To: Kugan <kugan.vivekanandarajah@linaro.org>
Cc: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH 2/2] Enable elimination of zext/sext
Date: Wed, 25 Jun 2014 08:36:00 -0000 [thread overview]
Message-ID: <20140625083618.GZ31640@tucnak.redhat.com> (raw)
In-Reply-To: <53AA8501.809@linaro.org>
On Wed, Jun 25, 2014 at 06:14:57PM +1000, Kugan wrote:
> For these flags, value ranges generated are not usable for extension
> eliminations. Therefore, without this some of the test cases in
> regression fails. For example:
>
> short a;
> void
> foo (void)
> {
> for (a = 0; a >= 0; a++)
> ;
> }
> -Os -fno-strict-overflow produces the following range for the index
> increment and hence goes into infinite loop.
> _10: [1, 32768]
> _10 = _4 + 1;
For -fwrapv I don't see why you'd get into trouble ever, the VRP computation
should be well aware of the -fwrapv semantics and the value ranges should
reflect that.
For -fno-strict-overflow, I have no idea since it is very weirdly defined.
In any case, for your example above, the loop is always well defined,
because for char/short a++ is performed as:
a = (short) ((int) a + 1)
So, if the patch turns it into infinite loop, with -Os -fno-strict-overflow
or -Os, it is simply a problem with the patch. VR [1, 32768] looks correct,
a++ is performed only if a is >= 0, therefore before addition [0, 32767].
But from VR [1, 32768] you can't optimize away the sign extension, make sure
you don't have there off-by-one?
It would be nice if the patch contained some testcases, it is easy
to construct testcases where you have arbitrary VRs on some SSA_NAMEs,
you just need something to stick the VR on, so you can do something like:
type foo (type a)
{
if (a < VR_min + 1 || a > VR_max + 1) return; // If VR_min is type minimum or VR_max type maximum this needs to be adjusted of course.
a = a + 1;
// now you can try some cast that your optimization would try to optimize
return a;
}
Or void bar (type a) { a = (a & mask) + bias; (or similarly) }
Make sure to cover the boundary cases, where VR minimum or maximum still
allow optimizing away zero and/or sign extensions, and another case where
they are +- 1 and already don't allow it.
Jakub
next prev parent reply other threads:[~2014-06-25 8:36 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-24 11:48 [PATCH 0/2] Zext/sext elimination using value range Kugan
2014-06-24 11:51 ` [PATCH 1/2] Enable setting sign and unsigned promoted mode (SPR_SIGNED_AND_UNSIGNED) Kugan
2014-06-24 12:18 ` Jakub Jelinek
2014-06-25 7:21 ` Kugan
2014-06-25 7:50 ` Jakub Jelinek
2014-06-26 1:06 ` Kugan
2014-06-26 2:48 ` Kugan
2014-06-26 5:50 ` Jakub Jelinek
2014-06-26 9:41 ` Kugan
2014-06-26 10:12 ` Jakub Jelinek
2014-06-26 10:42 ` Jakub Jelinek
2014-07-01 8:21 ` Kugan
2014-07-07 6:52 ` Kugan
2014-07-07 8:06 ` Jakub Jelinek
2014-06-26 10:25 ` Andreas Schwab
2014-07-01 8:28 ` Kugan
2014-06-24 11:53 ` [PATCH 2/2] Enable elimination of zext/sext Kugan
2014-06-24 12:21 ` Jakub Jelinek
2014-06-25 8:15 ` Kugan
2014-06-25 8:36 ` Jakub Jelinek [this message]
2014-07-07 6:55 ` Kugan
2014-07-10 12:15 ` Richard Biener
2014-07-11 11:52 ` Kugan
2014-07-11 12:47 ` Richard Biener
2014-07-14 2:58 ` Kugan
2014-07-14 20:11 ` Bernhard Reutner-Fischer
2014-07-23 14:22 ` Richard Biener
2014-08-01 4:51 ` Kugan
2014-08-01 11:16 ` Richard Biener
2014-08-01 16:04 ` Kugan
2014-08-03 23:56 ` Kugan
2014-08-05 14:18 ` Richard Biener
2014-08-05 14:21 ` Jakub Jelinek
2014-08-06 12:09 ` Richard Biener
2014-08-06 13:22 ` Kugan
2014-08-06 13:29 ` Richard Biener
2014-08-07 5:25 ` Kugan
2014-08-07 8:09 ` Richard Biener
2014-08-27 10:01 Uros Bizjak
2014-08-27 10:07 ` Richard Biener
2014-08-27 10:32 ` Uros Bizjak
2014-08-27 10:32 ` Richard Biener
2014-09-01 8:48 ` Jakub Jelinek
2014-09-01 8:54 ` Uros Bizjak
2014-08-28 7:50 ` Kugan
2014-08-28 8:57 ` Richard Biener
2014-09-04 3:41 ` Kugan
2014-09-04 13:00 ` Richard Biener
2014-09-05 1:33 ` Kugan
2014-09-05 9:51 ` Richard Biener
2014-09-07 9:51 ` Kugan
2014-09-08 9:48 ` Richard Biener
2014-09-09 10:06 ` Kugan
2014-09-09 10:28 ` Richard Biener
2014-08-27 13:02 ` Kugan
2014-08-28 3:46 ` Kugan
2014-08-28 6:44 ` Marc Glisse
2014-08-28 7:29 ` Kugan
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=20140625083618.GZ31640@tucnak.redhat.com \
--to=jakub@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=kugan.vivekanandarajah@linaro.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).