]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/112618 - unused .MASK_CALL
authorRichard Biener <rguenther@suse.de>
Mon, 20 Nov 2023 10:12:43 +0000 (11:12 +0100)
committerRichard Biener <rguenther@suse.de>
Mon, 20 Nov 2023 13:58:10 +0000 (14:58 +0100)
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.

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

diff --git a/gcc/testsuite/gcc.dg/pr112618.c b/gcc/testsuite/gcc.dg/pr112618.c
new file mode 100644 (file)
index 0000000..897e6a8
--- /dev/null
@@ -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;
+}
index b7675d8171231194fbafa118ac4355bf032d233a..58679e91c0aa153a38c2a2b6d7814a200e7ba3bf 100644 (file)
@@ -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))
     {