On Tue, 7 Jan 2020, Christophe Lyon wrote:

I've received a support request where GCC generates strd/ldrd which
require aligned memory addresses, while the user code actually
provides sub-aligned pointers.

The sample code is derived from CMSIS:
#define __SIMD32_TYPE int
#define __SIMD32(addr) (*(__SIMD32_TYPE **) & (addr))

void foo(short *pDst, int in1, int in2) {
  *__SIMD32(pDst)++ = in1;
  *__SIMD32(pDst)++ = in2;
}

compiled with arm-none-eabi-gcc -mcpu=cortex-m7 CMSIS.c -S -O2
generates:
foo:
       strd    r1, r2, [r0]
       bx      lr

Using -mno-unaligned-access of course makes no change, since the code
is lying to the compiler by casting short* to int*.

If the issue is as well isolated as this, can't they just edit the code?

typedef int __SIMD32_TYPE __attribute__((aligned(1)));

gets

        str     r1, [r0]        @ unaligned
        str     r2, [r0, #4]    @ unaligned

instead of

        strd    r1, r2, [r0]

--
Marc Glisse

Reply via email to