public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jiong Wang <jiong.wang@foss.arm.com>
To: Richard Earnshaw <Richard.Earnshaw@foss.arm.com>,
	"Bin.Cheng" <amker.cheng@gmail.com>
Cc: James Greenhalgh <james.greenhalgh@arm.com>,
	Bin Cheng <bin.cheng@arm.com>,
	gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH AArch64]Handle REG+REG+CONST and REG+NON_REG+CONST in legitimize address
Date: Tue, 24 Nov 2015 14:39:00 -0000	[thread overview]
Message-ID: <565475F1.1000105@foss.arm.com> (raw)
In-Reply-To: <565464C4.7060704@foss.arm.com>



On 24/11/15 13:23, Richard Earnshaw wrote:
> On 24/11/15 13:06, Jiong Wang wrote:
>>
>> On 24/11/15 10:18, Richard Earnshaw wrote:
>>> I presume you are aware of the canonicalization rules for add?  That is,
>>> for a shift-and-add operation, the shift operand must appear first.  Ie.
>>>
>>> (plus (shift (op, op)), op)
>>>
>>> not
>>>
>>> (plus (op, (shift (op, op))
>>>
>>> R.
>> Looks to me it's not optimal to generate invalid mem addr, for example
>> (mem (plus reg, (mult reg, imm))) or even the simple (mem (plus (plus r,
>> r), imm),
>> in the first place. Those complex rtx inside is hidden by the permissive
>> memory_operand predication, and only exposed during reload by stricter
>> constraints, then reload need to extra work. If we expose those complex rtx
>> earlier then some earlier rtl pass may find more optimization
>> opportunities, for
>> example combine.
>>
>> The following simple modification fix the ICE and generates best
>> sequences to me:
>>
>> -                 return gen_rtx_fmt_ee (PLUS, addr_mode, base, op1);
>> +                 addr = gen_rtx_fmt_ee (PLUS, addr_mode, op1, base);
>> +                 emit_insn (gen_rtx_SET (base, addr));
>> +                 return base;
>>
> That wouldn't be right either if op1 could be a const_int.

Indeed, though it would be strange to me if op1 would be const_int here, 
given
those early if check, if it is, then the incoming address rtx would be 
something
like the following without two const_int folded.

          +
         / \
        /   \
       +    const_int
      / \
     /   \
    Reg const_int

or we could sync the rtx checked in the early 
aarch64_legitimate_address_hook_p,
it will return false if op1 be const_int.

-             rtx addr = gen_rtx_fmt_ee (PLUS, addr_mode, base, op1);
+             rtx addr = gen_rtx_fmt_ee (PLUS, addr_mode, op1, base);


>
> R.
>
>>    67         add     x1, x29, 48
>>    68         add     x1, x1, x0, sxtw 3
>>    69         stlr    x19, [x1]
>>
>> instead of
>>
>>    67         add     x1, x29, 64
>>    68         add     x0, x1, x0, sxtw 3
>>    69         sub     x0, x0, #16
>>    70         stlr    x19, [x0]
>>
>> or
>>
>>    67         sxtw    x0, w0
>>    68         add     x1, x29, 48
>>    69         add     x1, x1, x0, sxtw 3
>>    70         stlr    x19, [x1]
>>
>>
>>
>>
>>

  reply	other threads:[~2015-11-24 14:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-17  9:21 Bin Cheng
2015-11-17 10:08 ` James Greenhalgh
2015-11-19  2:32   ` Bin.Cheng
2015-11-20  8:31     ` Bin.Cheng
2015-11-20 17:39       ` Richard Earnshaw
2015-11-24  3:23         ` Bin.Cheng
2015-11-24  9:59           ` Richard Earnshaw
2015-11-24 10:21             ` Richard Earnshaw
2015-11-24 13:13               ` Jiong Wang
2015-11-24 13:29                 ` Richard Earnshaw
2015-11-24 14:39                   ` Jiong Wang [this message]
2015-11-24 14:55                     ` Richard Earnshaw
2015-12-01  3:19               ` Bin.Cheng
2015-12-01 10:25                 ` Richard Earnshaw
2015-12-03  5:26                   ` Bin.Cheng
2015-12-03 10:26                     ` Richard Earnshaw
2015-12-04  3:18                       ` Bin.Cheng
2015-11-25  4:53             ` Bin.Cheng

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=565475F1.1000105@foss.arm.com \
    --to=jiong.wang@foss.arm.com \
    --cc=Richard.Earnshaw@foss.arm.com \
    --cc=amker.cheng@gmail.com \
    --cc=bin.cheng@arm.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=james.greenhalgh@arm.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).