With the hybrid stmt detection no longer working as a gate-keeper to detect unhandled stmts we have to, and can, detect those earlier. The appropriate place is vect_mark_stmts_to_be_vectorized where for trivially relevant PHIs we can stop analyzing when the PHI wasn't classified as a known def during vect_analyze_scalar_cycles.
Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. PR tree-optimization/121509 * tree-vect-stmts.cc (vect_mark_stmts_to_be_vectorized): Fail early when we detect a relevant but not handled PHI. * gcc.dg/vect/pr121509.c: New testcase. --- gcc/testsuite/gcc.dg/vect/pr121509.c | 42 ++++++++++++++++++++++++++++ gcc/tree-vect-stmts.cc | 7 ++++- 2 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/vect/pr121509.c diff --git a/gcc/testsuite/gcc.dg/vect/pr121509.c b/gcc/testsuite/gcc.dg/vect/pr121509.c new file mode 100644 index 00000000000..3a69ad3cfdf --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/pr121509.c @@ -0,0 +1,42 @@ +/* { dg-additional-options "-fgimple" } */ + +#include "tree-vect.h" + +long g_73[2] = {6L,6L}; +int __GIMPLE (ssa,startwith("loop")) __attribute__((noipa)) +foo () +{ + signed char g; + int l; + int _1; + unsigned char _3; + unsigned char _4; + + __BB(2): + goto __BB3; + + __BB(3,loop_header(1)): + l_5 = __PHI (__BB2: _Literal (int) -511973466, __BB3: 1); + g_6 = __PHI (__BB2: _Literal (signed char) 0, __BB3: g_12); + _1 = (int) g_6; + g_73[_1] = 0l; + _3 = (unsigned char) g_6; + _4 = _3 + _Literal (unsigned char) 1; + g_12 = (signed char) _4; + if (g_12 > _Literal (signed char) 1) + goto __BB4; + else + goto __BB3; + + __BB(4): + l_14 = __PHI (__BB3: l_5); + return l_14; +} + +int main() +{ + check_vect (); + if (foo () != 1) + abort (); + return 0; +} diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index f3159df3725..2d999da3f4b 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -722,7 +722,12 @@ vect_mark_stmts_to_be_vectorized (loop_vec_info loop_vinfo, bool *fatal) phi_info->stmt); if (vect_stmt_relevant_p (phi_info, loop_vinfo, &relevant, &live_p)) - vect_mark_relevant (&worklist, phi_info, relevant, live_p); + { + if (STMT_VINFO_DEF_TYPE (phi_info) == vect_unknown_def_type) + return opt_result::failure_at + (*si, "not vectorized: unhandled relevant PHI: %G", *si); + vect_mark_relevant (&worklist, phi_info, relevant, live_p); + } } for (si = gsi_after_labels (bb); !gsi_end_p (si); gsi_next (&si)) { -- 2.43.0