From: Richard Biener <richard.guenther@gmail.com>
To: Kugan <kugan.vivekanandarajah@linaro.org>
Cc: Jakub Jelinek <jakub@redhat.com>,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH 2/2] Enable elimination of zext/sext
Date: Thu, 07 Aug 2014 08:09:00 -0000 [thread overview]
Message-ID: <CAFiYyc14PxCBtkZs_focfFj7sqYc+BxFnMKgkhuvqBxS1d1eHA@mail.gmail.com> (raw)
In-Reply-To: <53E30D9C.50701@linaro.org>
On Thu, Aug 7, 2014 at 7:24 AM, Kugan <kugan.vivekanandarajah@linaro.org> wrote:
> On 06/08/14 23:29, Richard Biener wrote:
>> On Wed, Aug 6, 2014 at 3:21 PM, Kugan <kugan.vivekanandarajah@linaro.org> wrote:
>>> On 06/08/14 22:09, Richard Biener wrote:
>>>> On Tue, Aug 5, 2014 at 4:21 PM, Jakub Jelinek <jakub@redhat.com> wrote:
>>>>> On Tue, Aug 05, 2014 at 04:17:41PM +0200, Richard Biener wrote:
>>>>>> what's the semantic of setting SRP_SIGNED_AND_UNSIGNED
>>>>>> on the subreg? That is, for the created (subreg:lhs_mode
>>>>>> (reg:<PROMOTE_MODE of ssa> N))?
>>>>>
>>>>> SRP_SIGNED_AND_UNSIGNED on a subreg should mean that
>>>>> the subreg is both zero and sign extended, which means
>>>>> that the topmost bit of the narrower mode is known to be zero,
>>>>> and all bits above it in the wider mode are known to be zero too.
>>>>> SRP_SIGNED means that the topmost bit of the narrower mode is
>>>>> either 0 or 1 and depending on that the above wider mode bits
>>>>> are either all 0 or all 1.
>>>>> SRP_UNSIGNED means that regardless of the topmost bit value,
>>>>> all above wider mode bits are 0.
>>>>
>>>> Ok, then from the context of the patch we already know that
>>>> either SRP_UNSIGNED or SRP_SIGNED is true which means
>>>> that the value is sign- or zero-extended.
>>>>
>>>> I suppose inside promoted_for_type_p
>>>> TYPE_MODE (TREE_TYPE (ssa)) == lhs_mode, I'm not sure
>>>> why you pass !unsignedp as lhs_uns.
>>>
>>> In expand_expr_real_1, it is already known that it is promoted for
>>> unsigned_p and we are setting SUBREG_PROMOTED_SET (temp, unsignedp).
>>>
>>> If we can prove that it is also promoted for !unsignedp, we can set
>>> SUBREG_PROMOTED_SET (temp, SRP_SIGNED_AND_UNSIGNED).
>>>
>>> promoted_for_type_p should prove this based on the value range info.
>>>
>>>>
>>>> Now, from 'ssa' alone we can't tell anything about a larger mode
>>>> registers value if that is either zero- or sign-extended. But we
>>>> know that those bits are properly zero-extended if unsignedp
>>>> and properly sign-extended if !unsignedp?
>>>>
>>>> So what the predicate tries to prove is that sign- and zero-extending
>>>> results in the same larger-mode value. This is true if the
>>>> MSB of the smaller mode is not set.
>>>>
>>>> Let's assume that smaller mode is that of 'ssa' then the test
>>>> is just
>>>>
>>>> return (!tree_int_cst_sign_bit (min) && !tree_int_cst_sign_bit (max));
>>>>
>>>> no?
>>>
>>> hmm, is this because we will never have a call to promoted_for_type_p
>>> with same sign (ignoring PROMOTE_MODE) for 'ssa' and the larger mode.
>>> The case with larger mode signed and 'ssa' unsigned will not work.
>>> Therefore larger mode unsigned and 'ssa' signed will be the only case
>>> that we should consider.
>>>
>>> However, with PROMOTE_MODE, isnt that we will miss some cases with this.
>>
>> No, PROMOTE_MODE will still either sign- or zero-extend. If either
>> results in zeros in the upper bits then PROMOTE_MODE doesn't matter.
>>
>
> Thanks for the explanation. Please find the attached patch that
> implements this. I have updated the comments and predicate to match this.
>
> Bootstrap tested on x86_64-unknown-linux-gnu and regression tested on
> x86_64-unknown-linux-gnu and arm-none-linux-gnueabi with no new
> regressions. Is this OK?
Ok with changing
+ || (TYPE_PRECISION (TREE_TYPE (ssa)) > GET_MODE_PRECISION (mode)))
+ return false;
to check with != (does that even happen?)
Thanks,
Richard.
> Thanks,
> Kugan
>
> gcc/
> 2014-08-07 Kugan Vivekanandarajah <kuganv@linaro.org>
>
> * calls.c (precompute_arguments): Check
> promoted_for_signed_and_unsigned_p and set the promoted mode.
> (promoted_for_signed_and_unsigned_p): New function.
> (expand_expr_real_1): Check promoted_for_signed_and_unsigned_p
> and set the promoted mode.
> * expr.h (promoted_for_signed_and_unsigned_p): New function definition.
> * cfgexpand.c (expand_gimple_stmt_1): Call emit_move_insn if
> SUBREG is promoted with SRP_SIGNED_AND_UNSIGNED.
>
>
> gcc/testsuite
> 2014-08-07 Kugan Vivekanandarajah <kuganv@linaro.org>
>
> * gcc.dg/zero_sign_ext_test.c: New test.
>
>
next prev parent reply other threads:[~2014-08-07 8:09 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
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 [this message]
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=CAFiYyc14PxCBtkZs_focfFj7sqYc+BxFnMKgkhuvqBxS1d1eHA@mail.gmail.com \
--to=richard.guenther@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--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).