https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118743
Bug ID: 118743
Summary: Inefficient integer calling for little-endian aarch64
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: tkoenig at gcc dot gnu.org
Target Milestone: ---
Noticed this in a USENET discussion...
$ gcc --version
gcc (Debian 14.2.0-12) 14.2.0
[...]
$ cat call.c
void foo (int, int, int, int, int,
int, int, int, int, int);
void bar (long, long, long, long, long,
long, long, long, long, long);
void baz()
{
foo (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
bar (1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
}
$ gcc -mlittle-endian -O3 -S call.c
gives
baz:
.LFB0:
.cfi_startproc
sub sp, sp, #32
.cfi_def_cfa_offset 32
mov w0, 10
mov w1, 9
mov w7, 8
mov w6, 7
mov w5, 6
stp x29, x30, [sp, 16]
.cfi_offset 29, -16
.cfi_offset 30, -8
add x29, sp, 16
mov w4, 5
mov w3, 4
mov w2, 3
str w1, [sp]
mov w1, 2
str w0, [sp, 8]
mov w0, 1
bl foo
mov x1, 10
mov x0, 9
stp x0, x1, [sp]
mov x7, 8
mov x6, 7
mov x5, 6
mov x4, 5
mov x3, 4
mov x2, 3
mov x1, 2
mov x0, 1
bl bar
ldp x29, x30, [sp, 16]
add sp, sp, 32
.cfi_restore 29
.cfi_restore 30
.cfi_def_cfa_offset 0
ret
It would be possible to construct the argument list for foo
on little-endian ARM the same way it is for bar, by storing
two 64-bit values to adjacent stack positions using stp.