https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105062
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |53947 Ever confirmed|0 |1 Last reconfirmed| |2022-03-28 Status|UNCONFIRMED |NEW --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- As the cited PR notices: "... the first loop is detected as reduction path while the second one as reduction chain." so what's missing is some "magic" during reduction detection to re-associate a reduction path to a reduction chain. The vectorizer relies on the reassoc pass to do this since re-associating during reduction analysis is a bit complicated. But since not all of the std::max are recognized as MAX_EXPR but some only after loop if-conversion that's too late for reassoc to happen. So the task here is maybe at vect_analyze_slp time try to discover some reduction paths as reduction chains or to be more forgiving during reduction discovery (but there it's more difficult because we rely on the REDUX_IDX chain to be valid even for reduction chains(?)). Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53947 [Bug 53947] [meta-bug] vectorizer missed-optimizations