From: Richard Biener Date: Tue, 4 Jul 2023 07:51:05 +0000 (+0200) Subject: tree-optimization/110436 - bogus live/relevant for unused pattern X-Git-Tag: basepoints/gcc-15~7851 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=729aa4fa48d627c4344764676edad3b65d40a003;p=thirdparty%2Fgcc.git tree-optimization/110436 - bogus live/relevant for unused pattern When we compute liveness and relevantness we have to make sure to handle live but not relevant stmts in a way we can later vectorize them. When the stmt uses only operands that do not need vectorization we can just leave such stmts in place - but not in the case they are recognized as patterns. Since we don't have a way to cancel pattern recognition we have to force mark such stmts as relevant. PR tree-optimization/110436 * tree-vect-stmts.cc (vect_mark_relevant): Expand dumping, force live but not relevant pattern stmts relevant. * gcc.dg/pr110436.c: New testcase. --- diff --git a/gcc/testsuite/gcc.dg/pr110436.c b/gcc/testsuite/gcc.dg/pr110436.c new file mode 100644 index 000000000000..8e63ca04cbed --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr110436.c @@ -0,0 +1,4 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ + +#include "pr83089.c" diff --git a/gcc/tree-vect-stmts.cc b/gcc/tree-vect-stmts.cc index a0c39268bf0b..c3e6f2d34ed3 100644 --- a/gcc/tree-vect-stmts.cc +++ b/gcc/tree-vect-stmts.cc @@ -261,11 +261,26 @@ vect_mark_relevant (vec *worklist, stmt_vec_info stmt_info, dump_printf_loc (MSG_NOTE, vect_location, "last stmt in pattern. don't mark" " relevant/live.\n"); + stmt_vec_info old_stmt_info = stmt_info; stmt_info = STMT_VINFO_RELATED_STMT (stmt_info); gcc_assert (STMT_VINFO_RELATED_STMT (stmt_info) == old_stmt_info); save_relevant = STMT_VINFO_RELEVANT (stmt_info); save_live_p = STMT_VINFO_LIVE_P (stmt_info); + + if (live_p && relevant == vect_unused_in_scope) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_NOTE, vect_location, + "vec_stmt_relevant_p: forcing live patern stmt " + "relevant.\n"); + relevant = vect_used_only_live; + } + + if (dump_enabled_p ()) + dump_printf_loc (MSG_NOTE, vect_location, + "mark relevant %d, live %d: %G", relevant, live_p, + stmt_info->stmt); } STMT_VINFO_LIVE_P (stmt_info) |= live_p;