public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] tree-optimization/112618 - unused .MASK_CALL
@ 2023-11-20 13:59 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2023-11-20 13:59 UTC (permalink / raw)
  To: gcc-patches

We have to make sure to remove unused .MASK_CALL internal function
calls after vectorization.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

	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.
---
 gcc/testsuite/gcc.dg/pr112618.c | 26 ++++++++++++++++++++++++++
 gcc/tree-vect-loop.cc           | 11 ++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/pr112618.c

diff --git a/gcc/testsuite/gcc.dg/pr112618.c b/gcc/testsuite/gcc.dg/pr112618.c
new file mode 100644
index 00000000000..897e6a8ed2e
--- /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 92d2e0ef9be..5c2c1d8b971 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -10520,7 +10520,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))
     {
-- 
2.35.3

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-11-20 13:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-20 13:59 [PATCH] tree-optimization/112618 - unused .MASK_CALL Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).