]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/110436 - bogus live/relevant for unused pattern
authorRichard Biener <rguenther@suse.de>
Tue, 4 Jul 2023 07:51:05 +0000 (09:51 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 4 Jul 2023 08:37:03 +0000 (10:37 +0200)
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.

gcc/testsuite/gcc.dg/pr110436.c [new file with mode: 0644]
gcc/tree-vect-stmts.cc

diff --git a/gcc/testsuite/gcc.dg/pr110436.c b/gcc/testsuite/gcc.dg/pr110436.c
new file mode 100644 (file)
index 0000000..8e63ca0
--- /dev/null
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-options "-O3" } */
+
+#include "pr83089.c"
index a0c39268bf0bf641c1ae03d51f75ac631b8a9fb6..c3e6f2d34ed308e600cc23ac01ab9e55c551610a 100644 (file)
@@ -261,11 +261,26 @@ vect_mark_relevant (vec<stmt_vec_info> *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;