https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114603
Bug ID: 114603 Summary: aarch64: Invalid SVE cnot optimisation Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: wrong-code Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: rsandifo at gcc dot gnu.org Target Milestone: --- Target: aarch64*-*-* An overly lax condition on the cnot combine pattern means that we optimise: #include <arm_sve.h> svint32_t foo(svbool_t pg, svint32_t y) { return svsel(svcmpeq(pg, y, 0), svdup_s32(1), svdup_s32(0)); } to a single cnot: foo: cnot z0.s, p0/m, z0.s ret The result must be 0 for inactive elements of pg, whereas the above would leave the elements unchanged instead. This seems to have been around since the SVE ACLE was first added.