https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123140
Bug ID: 123140
Summary: extracting element from a vec_duplicate SVE type
should be a no-op.
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Keywords: missed-optimization
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: tnfchris at gcc dot gnu.org
Target Milestone: ---
Target: aarch64*
The following example
#include <stdint.h>
#include <arm_sve.h>
uint32_t g;
svuint32_t foo(uint32_t *p) {
svuint32_t v = svdup_u32(*p);
g = v[0];
return v;
}
at -O3 -march=armv9-a generates
foo(unsigned int*):
adrp x1, .LANCHOR0
add x1, x1, :lo12:.LANCHOR0
ptrue p3.b, all
ld1rw z0.s, p3/z, [x0]
st1 {v0.s}[0], [x1]
ret
which is quite silly and it's due to in GIMPLE we don't see that
<bb 2> [local count: 1073741824]:
_1 = *p_5(D);
_2 = [vec_duplicate_expr] _1;
_3 = BIT_FIELD_REF <_2, 32, 0>;
g = _3;
return _2;
the BIT_FIELD_REF of the vec_duplicate_expr is a no-op.
This is likely due to the VLA type.