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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Blocks|                            |53947

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Apart from some details in data-ref analysis we also fail to vectorize a loop
with invariant stores (reduction in memory).  If we fix that we run into the
issue that dependence checking doesn't seem to handle the invariant stores
either.

t.ii:1400:24: note: versioning for alias required: can't determine dependence
between *_293 and *_293
consider run-time aliasing test between *_293 and *_293
t.ii:1400:24: note: versioning for alias required: can't determine dependence
between *_293 and *_302
consider run-time aliasing test between *_293 and *_302
...
t.ii:1400:24: note: === vect_prune_runtime_alias_test_list ===
t.ii:1400:24: note: not vectorized: compilation time alias.

that is because while I "fixed" DR_BASE_ADDRESS (via split_constant_offset)
DR_BASE_OBJECT doesn't reflect that.

I suppose instead of fixing via split_constant_offset and friends we should
eventually analyze the DR with respect to the first loop it varies in?

vectorizer hack:

Index: gcc/tree-vect-data-refs.c
===================================================================
--- gcc/tree-vect-data-refs.c   (revision 255622)
+++ gcc/tree-vect-data-refs.c   (working copy)
@@ -2641,9 +2641,9 @@ vect_analyze_data_ref_access (struct dat
   /* Allow loads with zero step in inner-loop vectorization.  */
   if (loop_vinfo && integer_zerop (step))
     {
-      GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)) = NULL;
+      //GROUP_FIRST_ELEMENT (vinfo_for_stmt (stmt)) = NULL;
       if (!nested_in_vect_loop_p (loop, stmt))
-       return DR_IS_READ (dr);
+       return true;//DR_IS_READ (dr);
       /* Allow references with zero step for outer loops marked
         with pragma omp simd only - it guarantees absence of
         loop-carried dependencies between inner loop iterations.  */

split-constant-offset hack (I'm not sure it's valid this way given we
specify an evolution loop that we might end up "skipping").

Index: gcc/tree-data-ref.c
===================================================================
--- gcc/tree-data-ref.c (revision 255622)
+++ gcc/tree-data-ref.c (working copy)
@@ -709,6 +709,26 @@ split_constant_offset_1 (tree type, tree
            *var = fold_convert (type, var0);
            return true;
          }
+       if (TREE_CODE (op0) == SSA_NAME
+           && ! SSA_NAME_IS_DEFAULT_DEF (op0)
+           && INTEGRAL_TYPE_P (itype)
+           && TYPE_OVERFLOW_WRAPS (itype)
+           && TYPE_PRECISION (type) > TYPE_PRECISION (itype))
+         {
+           gimple *def = SSA_NAME_DEF_STMT (op0);
+           tree chrec = analyze_scalar_evolution (gimple_bb
(def)->loop_father,
+                                                  op0);
+           if (! chrec_contains_undetermined (chrec)
+               && TREE_CODE (chrec) == POLYNOMIAL_CHREC
+               && ! scev_probably_wraps_p (op0, CHREC_LEFT (chrec),
+                                           CHREC_RIGHT (chrec), def,
+                                           gimple_bb (def)->loop_father,
true))
+             {
+               split_constant_offset (op0, &var0, off);
+               *var = fold_convert (type, var0);
+               return true;
+             }
+         }
        return false;
       }


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53947
[Bug 53947] [meta-bug] vectorizer missed-optimizations

Reply via email to