poly_int: compute_data_ref_alignment
authorRichard Sandiford <richard.sandiford@linaro.org>
Thu, 21 Dec 2017 07:02:53 +0000 (07:02 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Thu, 21 Dec 2017 07:02:53 +0000 (07:02 +0000)
This patch makes vect_compute_data_ref_alignment treat DR_INIT as a
poly_int and handles cases in which the calculated misalignment might
not be constant.

2017-12-21  Richard Sandiford  <richard.sandiford@linaro.org>
    Alan Hayward  <alan.hayward@arm.com>
    David Sherwood  <david.sherwood@arm.com>

gcc/
* tree-vect-data-refs.c (vect_compute_data_ref_alignment):
Treat drb->init as a poly_int.  Fail if its misalignment wrt
vector_alignment isn't known.

Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>
From-SVN: r255935

gcc/ChangeLog
gcc/tree-vect-data-refs.c

index 2a69053477cd363d45c5c410e50a5e86187e8aff..6d924992054a5fbe426d1e350d1c556f29a64ad1 100644 (file)
@@ -1,3 +1,11 @@
+2017-12-21  Richard Sandiford  <richard.sandiford@linaro.org>
+           Alan Hayward  <alan.hayward@arm.com>
+           David Sherwood  <david.sherwood@arm.com>
+
+       * tree-vect-data-refs.c (vect_compute_data_ref_alignment):
+       Treat drb->init as a poly_int.  Fail if its misalignment wrt
+       vector_alignment isn't known.
+
 2017-12-21  Richard Sandiford  <richard.sandiford@linaro.org>
            Alan Hayward  <alan.hayward@arm.com>
            David Sherwood  <david.sherwood@arm.com>
index 7d039185446915557b574fe90437f076db375b26..014862a5b1b588a095a1b824c91e6c028a76c377 100644 (file)
@@ -944,8 +944,8 @@ vect_compute_data_ref_alignment (struct data_reference *dr)
       DR_VECT_AUX (dr)->base_misaligned = true;
       base_misalignment = 0;
     }
-  unsigned int misalignment = (base_misalignment
-                              + TREE_INT_CST_LOW (drb->init));
+  poly_int64 misalignment
+    = base_misalignment + wi::to_poly_offset (drb->init).force_shwi ();
 
   /* If this is a backward running DR then first access in the larger
      vectype actually is N-1 elements before the address in the DR.
@@ -955,7 +955,21 @@ vect_compute_data_ref_alignment (struct data_reference *dr)
     misalignment += ((TYPE_VECTOR_SUBPARTS (vectype) - 1)
                     * TREE_INT_CST_LOW (drb->step));
 
-  SET_DR_MISALIGNMENT (dr, misalignment & (vector_alignment - 1));
+  unsigned int const_misalignment;
+  if (!known_misalignment (misalignment, vector_alignment,
+                          &const_misalignment))
+    {
+      if (dump_enabled_p ())
+       {
+         dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                          "Non-constant misalignment for access: ");
+         dump_generic_expr (MSG_MISSED_OPTIMIZATION, TDF_SLIM, ref);
+         dump_printf (MSG_MISSED_OPTIMIZATION, "\n");
+       }
+      return true;
+    }
+
+  SET_DR_MISALIGNMENT (dr, const_misalignment);
 
   if (dump_enabled_p ())
     {