https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111002
Bug ID: 111002 Summary: Code generation for vectorized -(a[i] != 0) with number of elements chang could be improved Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: pinskia at gcc dot gnu.org Reporter: pinskia at gcc dot gnu.org Target Milestone: --- Testcase: ``` void __attribute__ ((noipa)) f (int *__restrict r, int *__restrict a, short *__restrict pred) { for (int i = 0; i < 1024; ++i) r[i] = pred[i] != 0 ? -1 : 0; } ``` Kinda of patch: ``` /* Sink unary operations to branches, but only if we do fold both. */ (for op (negate bit_not abs absu) (simplify (op (view_convert? (vec_cond:s @0 @1 @2))) (if (element_precision (type) == element_precision (@1)) (vec_cond @0 (op! (view_convert @1)) (op! (view_convert @2)))))) ``` That is `Sink unary operations` one needs to add support for view_convert there ... I Noticed this while working on PR 110986 (but is not needed for that issue).