This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/64365] [4.9 Regression] Predictive commoning after loop vectorization produces incorrect code.


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

--- Comment #13 from Brooks Moses <brooks at gcc dot gnu.org> ---
FWIW, if you haven't done the 4.9 backport yet, this is what I ended up with. 
I'm not sure it's optimal, but it seems to work.


Index: gcc/tree-data-ref.c
===================================================================
--- gcc/tree-data-ref.c (revision 220259)
+++ gcc/tree-data-ref.c (working copy)
@@ -973,6 +973,24 @@
                                fold_convert (ssizetype, memoff));
              memoff = build_int_cst (TREE_TYPE (memoff), 0);
            }
+         /* Adjust the offset so it is a multiple of the access type
+            size and thus we separate bases that can possibly be used
+            to produce partial overlaps (which the access_fn machinery
+            cannot handle).  */
+         double_int rem;
+         if (TYPE_SIZE_UNIT (TREE_TYPE (ref))
+             && TREE_CODE (TYPE_SIZE_UNIT (TREE_TYPE (ref))) == INTEGER_CST
+             && !integer_zerop (TYPE_SIZE_UNIT (TREE_TYPE (ref))))
+           rem = tree_to_double_int (off).mod
+                (tree_to_double_int (TYPE_SIZE_UNIT (TREE_TYPE (ref))), false,
+                 TRUNC_MOD_EXPR);
+         else
+           /* If we can't compute the remainder simply force the initial
+              condition to zero.  */
+           rem = tree_to_double_int (off);
+         off = double_int_to_tree (ssizetype, tree_to_double_int (off) - rem);
+         memoff = double_int_to_tree (TREE_TYPE (memoff), rem);
+         /* And finally replace the initial condition.  */
          access_fn = chrec_replace_initial_condition
              (access_fn, fold_convert (orig_type, off));
          /* ???  This is still not a suitable base object for


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]