aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2023-11-20 11:12:43 +0100
committerRichard Biener <rguenther@suse.de>2023-11-20 14:58:10 +0100
commit57c028acbec4f7b594e6b024e02d6c799b51e03d (patch)
treea3eaf40a588eaf027b798e6e90ae573ebcbb86f6
parent3b34902417259031823bff7f853f615a60464bbd (diff)
downloadgcc-57c028acbec4f7b594e6b024e02d6c799b51e03d.zip
gcc-57c028acbec4f7b594e6b024e02d6c799b51e03d.tar.gz
gcc-57c028acbec4f7b594e6b024e02d6c799b51e03d.tar.bz2
tree-optimization/112618 - unused .MASK_CALL
We have to make sure to remove unused .MASK_CALL internal function calls after vectorization. PR tree-optimization/112618 * tree-vect-loop.cc (vect_transform_loop_stmt): For not relevant and unused .MASK_CALL make sure we remove the scalar stmt. * gcc.dg/pr112618.c: New testcase.
-rw-r--r--gcc/testsuite/gcc.dg/pr112618.c26
-rw-r--r--gcc/tree-vect-loop.cc11
2 files changed, 36 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.dg/pr112618.c b/gcc/testsuite/gcc.dg/pr112618.c
new file mode 100644
index 0000000..897e6a8
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr112618.c
@@ -0,0 +1,26 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int m, *p;
+
+__attribute__ ((simd)) int
+bar (int x)
+{
+ if (x)
+ {
+ if (m < 1)
+ for (m = 0; m < 1; ++m)
+ ++x;
+ p = &x;
+ for (;;)
+ ++m;
+ }
+ return 0;
+}
+
+__attribute__ ((simd)) int
+foo (int x)
+{
+ bar (x);
+ return 0;
+}
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index b7675d8..58679e91 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -11361,7 +11361,16 @@ vect_transform_loop_stmt (loop_vec_info loop_vinfo, stmt_vec_info stmt_info,
if (!STMT_VINFO_RELEVANT_P (stmt_info)
&& !STMT_VINFO_LIVE_P (stmt_info))
- return false;
+ {
+ if (is_gimple_call (stmt_info->stmt)
+ && gimple_call_internal_p (stmt_info->stmt, IFN_MASK_CALL))
+ {
+ gcc_assert (!gimple_call_lhs (stmt_info->stmt));
+ *seen_store = stmt_info;
+ return false;
+ }
+ return false;
+ }
if (STMT_VINFO_VECTYPE (stmt_info))
{