Take the following code: #define vector __attribute__((vector_size(16))) float a; float b; vector float fb(void) { return (vector float){ 0,0,b,a};} --- CUT --- This produces: fb: adrp x1, b adrp x0, a ldr w1, [x1, #:lo12:b] fmov s0, wzr ldr w0, [x0, #:lo12:a] sub sp, sp, #16 stp s0, s0, [sp] str w1, [sp, 8] str w0, [sp, 12] ldr q0, [sp] add sp, sp, 16 ret This is really horrible and should be done as: fb: adrp x0, a adrp x1, b movi v0.4s, 0 ldr s1, [x0, #:lo12:a] ldr s2, [x1, #:lo12:b] ins v0.s[3], v1.s[0] ins v0.s[2], v2.s[0] ret
#define vector __attribute__((vector_size(16))) float a; float b; float c; float d; vector float fb(void) { return (vector float){ d,c,b,a};} Is just as bad. We need to ins more in the aarch64 back-end.
Confirmed. CC'ing Alan, he might find this of interest
Author: alalaw01 Date: Mon Apr 20 10:29:26 2015 New Revision: 222229 URL: https://gcc.gnu.org/viewcvs?rev=222229&root=gcc&view=rev Log: [AArch64] PR/64134: Make aarch64_expand_vector_init use 'ins' more often gcc/: PR target/64134 * config/aarch64/aarch64.c (aarch64_expand_vector_init): Load constant and overwrite variable parts if <= 1/2 the elements are variable. gcc/testsuite/: PR target/64134 * gcc.target/aarch64/vec_init_1.c: New test. Added: trunk/gcc/testsuite/gcc.target/aarch64/vec_init_1.c Modified: trunk/gcc/ChangeLog trunk/gcc/config/aarch64/aarch64.c trunk/gcc/testsuite/ChangeLog
Fixed by r222229.