[Bug target/82445] ARM target generates unaligned STRD instruction

rearnsha at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Oct 19 13:15:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82445

--- Comment #7 from Richard Earnshaw <rearnsha at gcc dot gnu.org> ---
Author: rearnsha
Date: Thu Oct 19 13:14:55 2017
New Revision: 253891

URL: https://gcc.gnu.org/viewcvs?rev=253891&root=gcc&view=rev
Log:
[ARM] PR 82445 - suppress 32-bit aligned ldrd/strd peepholing with
-mno-unaligned-access

Peephole patterns exist in the arm backend to spot load/store
operations to adjacent memory operations in order to convert them into
ldrd/strd instructions.  However, when we have strict alignment
enforced, then we can only do this if the accesses are known to be
64-bit aligned; this is unlikely to be the case for most loads.  The
patch adds some alignment checking to the code that validates the
addresses for use in the peephole patterns.  This should also fix
incorrect generation of ldrd/strd with unaligned accesses that could
previously have occurred on ARMv5e where all such operations must be
64-bit aligned.

I've added some new tests as well.  In doing so I discovered that the
ldrd/strd peephole tests could never fail since they would match the
source file name in the scanned assembly as well as any instructions
of the intended type.  I've fixed those by tightening the scan results
slightly.

gcc:

* config/arm/arm.c (align_ok_ldrd_strd): New function.
(mem_ok_for_ldrd_strd): New parameter align.  Extract the alignment of the
mem into it.
(gen_operands_ldrd_strd): Validate the alignment of the accesses.

testsuite:

* gcc.target/arm/peep-ldrd-1.c: Tighten test scan pattern.
* gcc.target/arm/peep-strd-1.c: Likewise.
* gcc.target/arm/peep-ldrd-2.c: New test.
* gcc.target/arm/peep-strd-2.c: New test.


Added:
    branches/gcc-7-branch/gcc/testsuite/gcc.target/arm/peep-ldrd-2.c
    branches/gcc-7-branch/gcc/testsuite/gcc.target/arm/peep-strd-2.c
Modified:
    branches/gcc-7-branch/gcc/ChangeLog
    branches/gcc-7-branch/gcc/config/arm/arm.c
    branches/gcc-7-branch/gcc/testsuite/ChangeLog
    branches/gcc-7-branch/gcc/testsuite/gcc.target/arm/peep-ldrd-1.c
    branches/gcc-7-branch/gcc/testsuite/gcc.target/arm/peep-strd-1.c


More information about the Gcc-bugs mailing list