diff mbox series

[032/nnn] poly_int: symbolic_number

Message ID 871sltpz3a.fsf@linaro.org
State New
Headers show
Series [032/nnn] poly_int: symbolic_number | expand

Commit Message

Richard Sandiford Oct. 23, 2017, 5:12 p.m. UTC
This patch changes symbol_number::bytepos from a HOST_WIDE_INT
to a poly_int64.  perform_symbolic_merge can cope with symbolic
offsets as long as the difference between the two offsets is
constant.  (This could happen for a constant-sized field that
occurs at a variable offset, for example.)


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

gcc/
	* tree-ssa-math-opts.c (symbolic_number::bytepos): Change from
	HOST_WIDE_INT to poly_int64.
	(perform_symbolic_merge): Update accordingly.

Comments

Jeff Law Nov. 28, 2017, 5:43 p.m. UTC | #1
On 10/23/2017 11:12 AM, Richard Sandiford wrote:
> This patch changes symbol_number::bytepos from a HOST_WIDE_INT

> to a poly_int64.  perform_symbolic_merge can cope with symbolic

> offsets as long as the difference between the two offsets is

> constant.  (This could happen for a constant-sized field that

> occurs at a variable offset, for example.)

> 

> 

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

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

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

> 

> gcc/

> 	* tree-ssa-math-opts.c (symbolic_number::bytepos): Change from

> 	HOST_WIDE_INT to poly_int64.

> 	(perform_symbolic_merge): Update accordingly.

OK.
jeff
diff mbox series

Patch

Index: gcc/tree-ssa-math-opts.c
===================================================================
--- gcc/tree-ssa-math-opts.c	2017-10-23 17:11:39.997472274 +0100
+++ gcc/tree-ssa-math-opts.c	2017-10-23 17:17:04.541614564 +0100
@@ -1967,7 +1967,7 @@  struct symbolic_number {
   tree type;
   tree base_addr;
   tree offset;
-  HOST_WIDE_INT bytepos;
+  poly_int64 bytepos;
   tree src;
   tree alias_set;
   tree vuse;
@@ -2198,7 +2198,7 @@  perform_symbolic_merge (gimple *source_s
   if (rhs1 != rhs2)
     {
       uint64_t inc;
-      HOST_WIDE_INT start_sub, end_sub, end1, end2, end;
+      HOST_WIDE_INT start1, start2, start_sub, end_sub, end1, end2, end;
       struct symbolic_number *toinc_n_ptr, *n_end;
       basic_block bb1, bb2;
 
@@ -2210,15 +2210,19 @@  perform_symbolic_merge (gimple *source_s
 	  || (n1->offset && !operand_equal_p (n1->offset, n2->offset, 0)))
 	return NULL;
 
-      if (n1->bytepos < n2->bytepos)
+      start1 = 0;
+      if (!(n2->bytepos - n1->bytepos).is_constant (&start2))
+	return NULL;
+
+      if (start1 < start2)
 	{
 	  n_start = n1;
-	  start_sub = n2->bytepos - n1->bytepos;
+	  start_sub = start2 - start1;
 	}
       else
 	{
 	  n_start = n2;
-	  start_sub = n1->bytepos - n2->bytepos;
+	  start_sub = start1 - start2;
 	}
 
       bb1 = gimple_bb (source_stmt1);
@@ -2230,8 +2234,8 @@  perform_symbolic_merge (gimple *source_s
 
       /* Find the highest address at which a load is performed and
 	 compute related info.  */
-      end1 = n1->bytepos + (n1->range - 1);
-      end2 = n2->bytepos + (n2->range - 1);
+      end1 = start1 + (n1->range - 1);
+      end2 = start2 + (n2->range - 1);
       if (end1 < end2)
 	{
 	  end = end2;
@@ -2250,7 +2254,7 @@  perform_symbolic_merge (gimple *source_s
       else
 	toinc_n_ptr = (n_start == n1) ? n2 : n1;
 
-      n->range = end - n_start->bytepos + 1;
+      n->range = end - MIN (start1, start2) + 1;
 
       /* Check that the range of memory covered can be represented by
 	 a symbolic number.  */