https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99259
Bug ID: 99259
Summary: aarch64 inline asm: miscompilation depending on
function parameters order
Product: gcc
Version: 10.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: inline-asm
Assignee: unassigned at gcc dot gnu.org
Reporter: jacob.benoit.1 at gmail dot com
Target Milestone: ---
compiler explorer link: https://godbolt.org/z/9oE5Ta
Note: Clang has the same bug: https://bugs.llvm.org/show_bug.cgi?id=49343
code:
#include <arm_neon.h>
// output:
// smlal v0.4s, v1.4h, v2.4h
int32x4_t good(int32x4_t acc, int16x4_t x, int16x4_t y) {
asm("smlal %[acc].4s, %[x].4h, %[y].4h"
: [acc]"=w"(acc)
: [x]"w"(x),
[y]"w"(y)
:);
return acc;
}
// output:
// smlal v0.4s, v0.4h, v1.4h
// bug: v0 is used for both x and y arguments!
int32x4_t bad(int16x4_t x, int16x4_t y, int32x4_t acc) {
asm("smlal %[acc].4s, %[x].4h, %[y].4h"
: [acc]"=w"(acc)
: [x]"w"(x),
[y]"w"(y)
:);
return acc;
}