diff mbox series

[061/nnn] poly_int: compute_data_ref_alignment

Message ID 87k1zlkc8u.fsf@linaro.org
State New
Headers show
Series [061/nnn] poly_int: compute_data_ref_alignment | expand

Commit Message

Richard Sandiford Oct. 23, 2017, 5:25 p.m. UTC
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-10-23  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.

Comments

Jeff Law Nov. 28, 2017, 4:48 p.m. UTC | #1
On 10/23/2017 11:25 AM, Richard Sandiford wrote:
> 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-10-23  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.

OK.
jeff
diff mbox series

Patch

Index: gcc/tree-vect-data-refs.c
===================================================================
--- gcc/tree-vect-data-refs.c	2017-10-23 17:22:18.234826257 +0100
+++ gcc/tree-vect-data-refs.c	2017-10-23 17:22:24.456074525 +0100
@@ -944,8 +944,8 @@  vect_compute_data_ref_alignment (struct
       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
     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 ())
     {