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

https://gcc.gnu.org/g:57c028acbec4f7b594e6b024e02d6c799b51e03d

commit r14-5627-g57c028acbec4f7b594e6b024e02d6c799b51e03d
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Nov 20 11:12:43 2023 +0100

    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.

Diff:
---
 gcc/testsuite/gcc.dg/pr112618.c | 26 ++++++++++++++++++++++++++
 gcc/tree-vect-loop.cc           | 11 ++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)

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 b7675d81712..58679e91c0a 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))
     {

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

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

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-20 14:01 [gcc r14-5627] 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).