aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2025-08-12 09:51:54 +0200
committerRichard Biener <rguenth@gcc.gnu.org>2025-08-12 11:05:35 +0200
commitc5dab6fb402c93a92f6aa808c43956dfb9328190 (patch)
tree36dc2336342f2fd316b76ea45bac37514c62ff22 /gcc
parenta440b382e43203857de9195eb526c4a16f21ceb1 (diff)
downloadgcc-c5dab6fb402c93a92f6aa808c43956dfb9328190.zip
gcc-c5dab6fb402c93a92f6aa808c43956dfb9328190.tar.gz
gcc-c5dab6fb402c93a92f6aa808c43956dfb9328190.tar.bz2
tree-optimization/121509 - failure to detect unvectorizable loop
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. 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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr121509.c42
-rw-r--r--gcc/tree-vect-stmts.cc7
2 files changed, 48 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.dg/vect/pr121509.c b/gcc/testsuite/gcc.dg/vect/pr121509.c
new file mode 100644
index 0000000..3a69ad3
--- /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 b14680e..22397dc 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))
{