This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch AArch64] Fix extended register width
- From: Marcus Shawcroft <marcus dot shawcroft at gmail dot com>
- To: Carrot Wei <carrot at google dot com>
- Cc: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 30 Sep 2014 13:57:55 +0100
- Subject: Re: [Patch AArch64] Fix extended register width
- Authentication-results: sourceware.org; auth=none
- References: <CAEe8uECt6oU8EMGZDfDPyPn3tOt+eFQs=DfQmbU0pqmr1uL_ag at mail dot gmail dot com>
On 22 September 2014 19:41, Carrot Wei <carrot@google.com> wrote:
> Hi
>
> The extended register width in add/adds/sub/subs/cmp instructions is
> not always the same as target register, it depends on both target
> register width and extension type. But in current implementation the
> extended register width is always the same as target register. We have
> noticed it can generate following wrong assembler code when compiled
> an internal application,
>
> add x2, x20, x0, sxtw 3
>
> The correct assembler should be
>
> add x2, x20, w0, sxtw 3
Hi,
The assembler deliberately accepts the first form as a programmer
convenience. Given the above example:
AARCH64 GAS x.s page 1
1 0000 82CE20AB adds x2, x20, x0, sxtw 3
2 0004 82CE20AB adds x2, x20, w0, sxtw 3
Note both forms are correctly assembled. The GAS implementation
contains code at (or near) tc-aarch64.c:5461 that specifically catches
the former.
... therefore I see no need to change the behaviour of gcc.
Cheers
/Marcus