https://gcc.gnu.org/g:b1e922d8fc9cc38945cb9cdb062c232ae0c57f9b

commit r17-5657-gb1e922d8fc9cc38945cb9cdb062c232ae0c57f9b
Author: Richard Biener <[email protected]>
Date:   Wed Oct 28 08:48:32 2026 +0100

    tree-optimization/128224 - ICE with vectorizer and dead .MASK_CALL
    
    With -fno-tree-dce -fno-tree-dse we can't really assert that only
    scalar .MASK_CALLs with side-effects prevail, so drop that.
    
            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.

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

diff --git a/gcc/testsuite/gcc.dg/torture/pr128224.c 
b/gcc/testsuite/gcc.dg/torture/pr128224.c
new file mode 100644
index 000000000000..b763aa4738f6
--- /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 8110eb943b95..e8cff98997cb 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);
            }
        }

Reply via email to