With -fno-tree-dce -fno-tree-dse we can't really assert that only
scalar .MASK_CALLs with side-effects prevail, so drop that.

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

        PR tree-optimization/128224
        * tree-vect-loop.cc (vect_transform_loop): Drop assert that
        only .MASK_CALL with side-effects prevail.

        * gcc.dg/torture/pr128224.c: New testcase.
---
 gcc/testsuite/gcc.dg/torture/pr128224.c | 17 +++++++++++++++++
 gcc/tree-vect-loop.cc                   |  4 +++-
 2 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.dg/torture/pr128224.c

diff --git a/gcc/testsuite/gcc.dg/torture/pr128224.c 
b/gcc/testsuite/gcc.dg/torture/pr128224.c
new file mode 100644
index 00000000000..b763aa4738f
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr128224.c
@@ -0,0 +1,17 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fno-tree-dce -fno-tree-dse -fopenmp-simd" } */
+/* { dg-additional-options "-mavx2" { target { x86_64-*-* i?86-*-* } } } */
+
+#pragma omp declare simd simdlen(4) inbranch
+extern int f(int) __attribute__((const));
+
+void g(int *restrict d, int n)
+{
+#pragma omp simd
+  for (int i = 0; i < n; i++)
+    if (d[i] > 0)
+      {
+        int u = f(d[i]);
+        d[i]++;
+      }
+}
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 8110eb943b9..e8cff98997c 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -11652,7 +11652,9 @@ vect_transform_loop (loop_vec_info loop_vinfo, gimple 
*loop_vectorized_call)
                   && !STMT_VINFO_RELEVANT_P (stmt_info)
                   && !STMT_VINFO_LIVE_P (stmt_info))
            {
-             gcc_assert (!gimple_call_lhs (stmt_info->stmt));
+             /* With -fno-tree-{dce,dse} we can end up with dead
+                .MASK_CALL without side-effects and thus with a (dead)
+                LHS.  So we cannot assert there is no LHS.  */
              loop_vinfo->remove_stmt (stmt_info);
            }
        }

base-commit: 352a0b5fc55c71f637108c7e91e161f87f620744
-- 
2.51.0

Reply via email to