https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81778

--- Comment #10 from Tom de Vries <vries at gcc dot gnu.org> ---
Tentative patch:
...
diff --git a/gcc/omp-expand.c b/gcc/omp-expand.c
index 99cb4f9dda4..034de497390 100644
--- a/gcc/omp-expand.c
+++ b/gcc/omp-expand.c
@@ -6333,6 +6333,8 @@ expand_omp_simd (struct omp_region *region, struct
omp_for_data *fd)
       /* Collapsed loops not handled for SIMT yet: limit to one lane only.  */
       if (fd->collapse > 1)
        simt_maxlane = build_one_cst (unsigned_type_node);
+      else if (TREE_CODE (fd->loops[0].step) != INTEGER_CST)
+       simt_maxlane = build_one_cst (unsigned_type_node);
       else if (safelen_int < omp_max_simt_vf ())
        simt_maxlane = build_int_cst (unsigned_type_node, safelen_int);
       tree vf
@@ -6636,6 +6638,10 @@ expand_omp_simd (struct omp_region *region, struct
omp_for_data *fd)
       else
        t = fold_build2 (PLUS_EXPR, type, fd->loop.v, step);
       expand_omp_build_assign (&gsi, fd->loop.v, t);
+      /* The alternative IV needs to to be updated as well, but isn't
+        currently.  Assert that we fall back to simt_maxlane == 1.  */
+      gcc_assert (altv == NULL_TREE
+                 || tree_int_cst_equal (simt_maxlane, integer_one_node));
     }

   /* Remove GIMPLE_OMP_RETURN.  */
...

Reply via email to