[Bug target/82034] SMMLAR pattern not detected on ARMv7-M
oscar.molin at sigicom dot com
gcc-bugzilla@gcc.gnu.org
Wed Aug 30 16:44:00 GMT 2017
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82034
--- Comment #2 from Oscar Molin <oscar.molin at sigicom dot com> ---
(In reply to Richard Biener from comment #1)
> Can you please quote the typedefs for q31_t and q63_t, specify the GCC
> version you tested and provide a full testcase that can be compiled?
I made a program recreating this in GCC 7.1 (Arch repo, arm-none-eabi-gcc).
See that three variants included, I wasnt sure which useage of __SMMLAR was
right. I used the second one in my application, but I don't know if it's
required to have a return value to get the same result.
Compilation options:
arm-none-eabi-gcc -O3 smmlar.c -o test.elf -mcpu=cortex-m4 -mthumb
-mfpu=fpv4-sp-d16 --std=c11 --specs=nosys.specs
Dump assembly:
arm-none-eabi-objdump -D test.elf > test.dump
Code (smmlar.c):
#include <stdint.h>
typedef int32_t q31_t;
typedef int64_t q63_t;
#define __STATIC_INLINE static inline
#define __ASM __asm
#define multAcc_32x32_keep32_R(a, x, y) \
a = (q31_t) (((((q63_t) a) << 32) + ((q63_t) x * y) + 0x80000000LL ) >> 32)
__attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __SMMLAR (int32_t
op1, int32_t op2, int32_t op3)
{
int32_t result;
__ASM volatile ("smmlar %0, %1, %2, %3" : "=r" (result): "r" (op1), "r"
(op2), "r" (op3) );
return(result);
}
int main()
{
volatile int a = 1, b = 2, c = 3;
q31_t acc0 = a;
q31_t x0 = b;
q31_t c0 = c;
//Original call used in CMSIS-DSP
//multAcc_32x32_keep32_R(acc0, x0, c0);
//
__SMMLAR(x0, c0, acc0);
// Alternative form?
//acc0 = __SMMLAR(x0, c0, acc0);
return acc0;
}
More information about the Gcc-bugs
mailing list