https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120893
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed| |2025-06-30 Status|UNCONFIRMED |NEW Blocks| |53947 Ever confirmed|0 |1 Keywords| |missed-optimization --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- vect_build_slp_tree_1 handles references to existing vector elements and rejects combining from two such. vect_build_slp_tree_2 handles a single vector source as extern unpermuted vector + VEC_PERM. Extending this to exactly _two_ vector sources (re-use the two_operands flag maybe?) should be trivial given we already emit a VEC_PERM. Note this interacts with permuting operands upthread which might be able to permute the graph to a shape where all existing vectors appear on their own, like { a[0] + b[0], b[1] + a[1] } vs. { a[0] + b[0], a[1] + b[1] } where we obviously prefer to vectorize as a + b rather than perm (a, b, { 0, 2 }) + perm (a, b { 3, 1 }). While we have a permute optimization phase that does not have the power to "undo" such permute. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53947 [Bug 53947] [meta-bug] vectorizer missed-optimizations