https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116129
Bug ID: 116129 Summary: Use SVE INDEX instruction to create constant vectors Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: aarch64-sve, missed-optimization Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: ktkachov at gcc dot gnu.org Target Milestone: --- Target: aarch64 The INDEX (immediates) instruction can be used to create vectors based on a base value and a step. We should make use of it even if generating fixed-length vector immediates as it allows base and step values in [-16, 15]. We can use it when TARGET_SVE is available. For example: #include <arm_sve.h> typedef char v16qi __attribute__((vector_size (16))); v16qi foo (void) { return (v16qi){0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15}; } svint8_t foo_sve (void) { return svindex_s8 (0, 1); } These two functions should just use: index z0.b, #0, #1 Currently function foo will emit an ADR and an LDR from a constant pool