diff mbox series

[036/nnn] poly_int: get_object_alignment_2

Message ID 87k1zlokge.fsf@linaro.org
State New
Headers show
Series [036/nnn] poly_int: get_object_alignment_2 | expand

Commit Message

Richard Sandiford Oct. 23, 2017, 5:14 p.m. UTC
This patch makes get_object_alignment_2 track polynomial offsets
and sizes.  The real work is done by get_inner_reference, but we
then need to handle the alignment correctly.


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

gcc/
	* builtins.c (get_object_alignment_2): Track polynomial offsets
	and sizes.  Update the alignment handling.

Comments

Jeff Law Nov. 28, 2017, 4:55 p.m. UTC | #1
On 10/23/2017 11:14 AM, Richard Sandiford wrote:
> This patch makes get_object_alignment_2 track polynomial offsets

> and sizes.  The real work is done by get_inner_reference, but we

> then need to handle the alignment correctly.

> 

> 

> 2017-10-23  Richard Sandiford  <richard.sandiford@linaro.org>

> 	    Alan Hayward  <alan.hayward@arm.com>

> 	    David Sherwood  <david.sherwood@arm.com>

> 

> gcc/

> 	* builtins.c (get_object_alignment_2): Track polynomial offsets

> 	and sizes.  Update the alignment handling.

OK.
jeff
diff mbox series

Patch

Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c	2017-10-23 17:11:39.984447382 +0100
+++ gcc/builtins.c	2017-10-23 17:18:42.394520412 +0100
@@ -252,7 +252,7 @@  called_as_built_in (tree node)
 get_object_alignment_2 (tree exp, unsigned int *alignp,
 			unsigned HOST_WIDE_INT *bitposp, bool addr_p)
 {
-  HOST_WIDE_INT bitsize, bitpos;
+  poly_int64 bitsize, bitpos;
   tree offset;
   machine_mode mode;
   int unsignedp, reversep, volatilep;
@@ -377,8 +377,17 @@  get_object_alignment_2 (tree exp, unsign
 	}
     }
 
+  /* Account for the alignment of runtime coefficients, so that the constant
+     bitpos is guaranteed to be accurate.  */
+  unsigned int alt_align = ::known_alignment (bitpos - bitpos.coeffs[0]);
+  if (alt_align != 0 && alt_align < align)
+    {
+      align = alt_align;
+      known_alignment = false;
+    }
+
   *alignp = align;
-  *bitposp = bitpos & (*alignp - 1);
+  *bitposp = bitpos.coeffs[0] & (align - 1);
   return known_alignment;
 }