public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ajit Kumar Agarwal <ajit.kumar.agarwal@xilinx.com>
To: Richard Sandiford <richard.sandiford@arm.com>
Cc: Jeff Law <law@redhat.com>,
	"gcc-patches@gcc.gnu.org"	<gcc-patches@gcc.gnu.org>
Subject: RE: [PATCH 0/5] Fix handling of word subregs of wide registers
Date: Mon, 22 Sep 2014 12:07:00 -0000	[thread overview]
Message-ID: <1ede66b2-8e73-43be-96a1-44a76829b279@BN1BFFO11FD017.protection.gbl> (raw)
In-Reply-To: <87vboflwv6.fsf@e105548-lin.cambridge.arm.com>



-----Original Message-----
From: Richard Sandiford [mailto:richard.sandiford@arm.com] 
Sent: Monday, September 22, 2014 4:56 PM
To: Ajit Kumar Agarwal
Cc: Jeff Law; gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 0/5] Fix handling of word subregs of wide registers

Ajit Kumar Agarwal <ajit.kumar.agarwal@xilinx.com> writes:
> Jeff Law <law@redhat.com> writes:
>> On 09/19/14 01:23, Richard Sandiford wrote:
>>> Jeff Law <law@redhat.com> writes:
>>>> On 09/18/14 04:07, Richard Sandiford wrote:
>>>>> This series is a cleaned-up version of:
>>>>>
>>>>>       https://gcc.gnu.org/ml/gcc/2014-03/msg00163.html
>>>>>
>>>>> The underlying problem is that the semantics of subregs depend on 
>>>>> the word size.  You can't have a subreg for byte 2 of a 4-byte 
>>>>> word, say, but you can have a subreg for word 2 of a 4-word value 
>>>>> (as well as lowpart subregs of that word, etc.).  This causes 
>>>>> problems when an architecture has wider-than-word registers, since 
>>>>> the addressability of a word can then depend on which register 
>>>>> class is used.
>>>>>
>>>>> The register allocators need to fix up cases where a subreg turns 
>>>>> out to be invalid for a particular class.  This is really an 
>>>>> extension of what we need to do for CANNOT_CHANGE_MODE_CLASS.
>>>>>
>>>>> Tested on x86_64-linux-gnu, powerpc64-linux-gnu and aarch64_be-elf.
>>>> I thought we fixed these problems long ago with the change to subreg_byte?!?
>>>
>>> No, that was fixing something else.  (I'm just about old enough to 
>>> remember that too!)  The problem here is that (say):
>>>
>>>      (subreg:SI (reg:DI X) 4)
>>>
>>> is independently addressable on little-endian AArch32 if X assigned 
>>> to a GPR, but not if X is assigned to a vector register.  We need to 
>>> allow these kinds of subreg on pseudos in order to decompose 
>>> multiword arithmetic.  It's then up to the RA to realise that a 
>>> reload would be needed if X were assigned to a vector register, 
>>> since the upper half of a vector register cannot be independently accessed.
>>>
>>> Note that you could write this example even with the old word-style 
>>> offsets and IIRC the effect would have been the same.
>> OK.  So I kept thinking in terms of the byte offset stuff.  But what 
>> you're tackling is related to the mess around the mode of the subreg 
>> having a different meaning if its smaller than a word vs word-sized 
>> or greater.
>>
>> Right?
>
>>>Yeah, that's right.  Addressability is based on words, which is  
>>>inconvenient when your registers are bigger than a word.
>
> If the architecture like Microblaze which doesn't support the 1 byte 
> or
> 2 byte registers. In this scenario what should be returned when 
> SUBREG_WORD is used.

>>I don't understand the question sorry.  Subreg offsets are still represented as bytes rather than words.  The patch doesn't change the way that subregs are >>represented or the rules about which subregs are valid.

>>Both before and after the patch, the semantics of subregs say that if you have 4-byte words, only one of:

    >>(subreg:QI (reg:SI X) 0)
    >>(subreg:QI (reg:SI X) 1)
    >>(subreg:QI (reg:SI X) 2)
    >>(subreg:QI (reg:SI X) 3)

>>is ever valid (0 for little-endian, 3 for big-endian).  Writing to that one valid subreg will change the whole of X, unless the subreg is wrapped in a >>strict_lowpart.  In other words, subregs are defined so that individual parts of a word are not independently addressable.

>>However, individual words of a multiword register _are_ addressable.  I.e.:

   (subreg:SI (reg:DI Y) 0)
   (subreg:SI (reg:DI Y) 4)

>>are both valid.  Writing to one does not change the other.

>>The problem the patch was trying to solve was that you can have targets with 4-byte words but some 8-byte registers.  In those cases, it's still possible to >>form both of the Y subregs above if Y is allocated to a word-sized register, but not if Y is allocated to a doubleword-sized register.

Thanks Richard for the explanation. 

Thanks,
Richard

  reply	other threads:[~2014-09-22 12:07 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-18 10:07 Richard Sandiford
2014-09-18 10:09 ` [PATCH 1/5] Allow *_HARD_REG_SET arguments to be const Richard Sandiford
2014-09-19  6:14   ` Jeff Law
2014-09-18 10:10 ` [PATCH 2/5] Tweak subreg_get_info documentation Richard Sandiford
2014-09-19  6:16   ` Jeff Law
2014-09-18 10:13 ` [PATCH 3/5] Use simplify_subreg_regno in combine.c:subst Richard Sandiford
2014-09-19  6:17   ` Jeff Law
2014-09-18 10:25 ` [PATCH 4/5] Generalise invalid_mode_change_p Richard Sandiford
2014-09-19 17:53   ` Jeff Law
2014-09-22  7:34     ` Richard Sandiford
2014-09-22 16:29       ` Jeff Law
2014-09-18 10:26 ` [PATCH 5/5] Remove CANNOT_CHANGE_MODE_CLASS workaround in i386.c Richard Sandiford
2014-09-19 17:54   ` Jeff Law
2014-09-19  6:14 ` [PATCH 0/5] Fix handling of word subregs of wide registers Jeff Law
2014-09-19  7:24   ` Richard Sandiford
2014-09-19 15:59     ` Jeff Law
2014-09-19 17:14     ` Jeff Law
2014-09-22  7:23       ` Richard Sandiford
2014-09-22 10:49         ` Ajit Kumar Agarwal
2014-09-22 11:26           ` Richard Sandiford
2014-09-22 12:07             ` Ajit Kumar Agarwal [this message]
2014-09-22  9:00 ` Andrew Pinski
2014-09-22 11:29   ` Richard Sandiford

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=1ede66b2-8e73-43be-96a1-44a76829b279@BN1BFFO11FD017.protection.gbl \
    --to=ajit.kumar.agarwal@xilinx.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    --cc=richard.sandiford@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).