From: "H.J. Lu" <hjl.tools@gmail.com>
To: Paolo Bonzini <bonzini@gnu.org>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>
Subject: Re: PING: PATCH [4/n]: Prepare x32: Permute the conversion and addition if one operand is a constant
Date: Mon, 11 Jul 2011 15:58:00 -0000 [thread overview]
Message-ID: <CAMe9rOp7=UvknX2z9k5O1Q8sJkXH8Z11=7TEjU0M5_EoAFC11g@mail.gmail.com> (raw)
In-Reply-To: <4E1AD86A.8000800@gnu.org>
On Mon, Jul 11, 2011 at 4:03 AM, Paolo Bonzini <bonzini@gnu.org> wrote:
> On 07/11/2011 02:04 AM, H.J. Lu wrote:
>>
>> With my original change, I got
>>
>> (const:DI (plus:DI (symbol_ref:DI ("iplane.1577") [flags 0x2]
>> <var_decl 0x7ffff0857960 iplane>)
>> (const_int -4 [0xfffffffffffffffc])))
>>
>> I think it is safe to permute the conversion and addition operation
>> if one operand is a constant and we are zero-extending. This is
>> how zero-extending works.
>
> Ok, I think I understand what you mean. The key is the
>
> XEXP (x, 1) == convert_memory_address_addr_space
> (to_mode, XEXP (x, 1), as)
>
> test. It ensures basically that the constant has 31-bit precision, because
> otherwise the constant would change from e.g. (const_int -0x7ffffffc) to
> (const_int 0x80000004) when zero-extending it from SImode to DImode.
>
> But I'm not sure it's safe. You have,
>
> (zero_extend:DI (plus:SI FOO:SI) (const_int Y))
>
> and you want to convert it to
>
> (plus:DI FOO:DI (zero_extend:DI (const_int Y)))
>
> (where the zero_extend is folded). Ignore that FOO is a SYMBOL_REF (this
> piece of code does not assume anything about its shape); if FOO ==
> 0xfffffffc and Y = 8, the result will be respectively 0x4 (valid) and
> 0x100000004 (invalid).
This example contradicts what you said above "It ensures basically that the
constant has 31-bit precision". For zero-extend, the issue is address-wrap.
As I understand, to support address-wrap, you need to use ptr_mode.
> If pointers extend as signed you also have a similar case. If FOO ==
> 0x7ffffffc and Y = 8, the result of
>
> (sign_extend:DI (plus:SI FOO:SI) (const_int Y))
>
> and
>
> (plus:DI FOO:DI (sign_extend:DI (const_int Y)))
>
> will be respectively 0xffffffff80000004 (valid) and 0x80000004 (invalid).
>
>
> What happens if you just return NULL instead of the assertion (good idea
> adding it!)?
>
> Of course then you need to:
>
> 1) check the return values of convert_memory_address_addr_space_1, and
> propagate NULL up to simplify_unary_operation;
>
> 2) check in simplify-rtx.c whether the return value of
> convert_memory_address_1 is NULL, and only return if the return value is not
> NULL. This is not yet necessary (convert_memory_address is the last
> transformation for both SIGN_EXTEND and ZERO_EXTEND) but it is better to
> keep code clean.
I will give it a try.
Thanks.
--
H.J.
next prev parent reply other threads:[~2011-07-11 15:54 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-05 14:30 H.J. Lu
2011-07-09 21:22 ` H.J. Lu
2011-07-09 21:23 ` Paolo Bonzini
2011-07-09 21:41 ` H.J. Lu
2011-07-10 17:04 ` Paolo Bonzini
2011-07-10 21:16 ` H.J. Lu
2011-07-11 0:48 ` H.J. Lu
2011-07-11 1:14 ` H.J. Lu
2011-07-11 6:49 ` H.J. Lu
2011-07-11 11:09 ` Paolo Bonzini
2011-07-11 15:58 ` H.J. Lu [this message]
2011-07-11 16:57 ` H.J. Lu
2011-07-11 17:26 ` H.J. Lu
2011-07-13 16:24 ` Paolo Bonzini
2011-07-13 16:52 ` H.J. Lu
2011-07-13 16:55 ` Paolo Bonzini
2011-07-13 16:58 ` Paolo Bonzini
2011-07-13 18:42 ` H.J. Lu
2011-07-25 10:34 ` Paolo Bonzini
2011-07-27 18:18 ` H.J. Lu
2011-07-27 22:41 ` Paolo Bonzini
2011-07-28 3:11 ` H.J. Lu
2011-07-28 7:59 ` Paolo Bonzini
2014-05-29 4:52 ` Andrew Pinski
2014-05-29 16:13 ` H.J. Lu
2014-05-29 16:23 ` pinskia
2014-05-29 17:09 ` H.J. Lu
2014-05-29 17:20 ` pinskia
2014-05-30 7:18 ` Paolo Bonzini
2011-07-28 10:24 Uros Bizjak
2011-07-28 10:27 ` Paolo Bonzini
2011-07-29 13:29 ` H.J. Lu
2011-07-28 18:23 ` Uros Bizjak
2011-07-29 9:32 ` Paolo Bonzini
2011-07-29 9:37 ` Paolo Bonzini
2011-07-30 0:47 ` H.J. Lu
2011-07-30 16:35 ` Paolo Bonzini
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='CAMe9rOp7=UvknX2z9k5O1Q8sJkXH8Z11=7TEjU0M5_EoAFC11g@mail.gmail.com' \
--to=hjl.tools@gmail.com \
--cc=bonzini@gnu.org \
--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).