https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115537
Bug ID: 115537 Summary: [15 Regression] vectorizable_reduction ICEs after g:d66b820f392aa9a7c34d3cddaf3d7c73bf23f82d Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: ice-on-valid-code Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: tnfchris at gcc dot gnu.org CC: rguenth at gcc dot gnu.org Target Milestone: --- testcase: --- char *a; int b; void c() { int d = 0, e = 0, f; for (; f; ++f) if (a[f] == 5) ; else if (a[f]) e = 1; else d = 1; if (d) if (e) b = 0; } --- compiled with -mcpu=neoverse-v1 -O3 produces the following ICE: during GIMPLE pass: vect pngrtran.i: In function 'c': pngrtran.i:3:6: internal compiler error: in vectorizable_reduction, at tree-vect-loop.cc:8335 3 | void c() { | ^ 0xff74ff vectorizable_reduction(_loop_vec_info*, _stmt_vec_info*, _slp_tree*, _slp_instance*, vec<stmt_info_for_cost, va_heap, vl_ptr>*) /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-vect-loop.cc:8335 0x1b598f7 vect_analyze_stmt(vec_info*, _stmt_vec_info*, bool*, _slp_tree*, _slp_instance*, vec<stmt_info_for_cost, va_heap, vl_ptr>*) /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-vect-stmts.cc:13353 0x10225df vect_slp_analyze_node_operations_1 /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-vect-slp.cc:6457 0x10225df vect_slp_analyze_node_operations /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-vect-slp.cc:6656 0x102253f vect_slp_analyze_node_operations /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-vect-slp.cc:6635 0x1023ec3 vect_slp_analyze_operations(vec_info*) /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-vect-slp.cc:7053 0xff816f vect_analyze_loop_2 /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-vect-loop.cc:2953 0xff9fb7 vect_analyze_loop_1 /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-vect-loop.cc:3484 0xffa6f7 vect_analyze_loop(loop*, vec_info_shared*) /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-vect-loop.cc:3642 0x1035547 try_vectorize_loop_1 /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-vectorizer.cc:1067 0x1035547 try_vectorize_loop /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-vectorizer.cc:1183 0x1035a5b execute /opt/buildAgent/work/5c94c4ced6ebfcd0/gcc/tree-vectorizer.cc:1299 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://gcc.gnu.org/bugs/> for instructions. after: commit d66b820f392aa9a7c34d3cddaf3d7c73bf23f82d Author: Richard Biener <rguent...@suse.de> Date: Thu Jun 13 14:42:25 2024 +0200 Support single def-use cycle optimization for SLP reduction vectorization We can at least mimic single def-use cycle optimization when doing single-lane SLP reductions and that's required to avoid regressing compared to non-SLP. * tree-vect-loop.cc (vectorizable_reduction): Allow single-def-use cycles with SLP. (vect_transform_reduction): Handle SLP single def-use cycles. (vect_transform_cycle_phi): Likewise. * gcc.dg/vect/slp-reduc-12.c: New testcase. gcc/testsuite/gcc.dg/vect/slp-reduc-12.c | 18 +++++++++++++ gcc/tree-vect-loop.cc | 45 +++++++++++++++++++------------- 2 files changed, 45 insertions(+), 18 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/vect/slp-reduc-12.c bisect run success looks like it's hitting the assert: gcc_assert (op.code != COND_EXPR);