Hi.

This is partial fix for the PR, where I calculate 2 offsets in offset_int type.

Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

Ready to be installed?
Martin

gcc/ChangeLog:

2017-09-20  Martin Liska  <mli...@suse.cz>

        PR tree-optimization/82042
        * alias.c (memrefs_conflict_p): Calculate offset in offset_int
        type.
        * cse.c (use_related_value): Likewise.
---
 gcc/alias.c | 10 ++++++++--
 gcc/cse.c   | 14 ++++++++++----
 2 files changed, 18 insertions(+), 6 deletions(-)


diff --git a/gcc/alias.c b/gcc/alias.c
index e4865729a9b..6121e61e1bc 100644
--- a/gcc/alias.c
+++ b/gcc/alias.c
@@ -2580,8 +2580,14 @@ memrefs_conflict_p (int xsize, rtx x, int ysize, rtx y, HOST_WIDE_INT c)
     {
       if (CONST_INT_P (x) && CONST_INT_P (y))
 	{
-	  c += (INTVAL (y) - INTVAL (x));
-	  return offset_overlap_p (c, xsize, ysize);
+	  offset_int offset = (offset_int (INTVAL (y)) - INTVAL (x));
+	  if (wi::fits_shwi_p (offset))
+	  {
+	    c += offset.to_shwi ();
+	    return offset_overlap_p (c, xsize, ysize);
+	  }
+	  else
+	    return -1;
 	}
 
       if (GET_CODE (x) == CONST)
diff --git a/gcc/cse.c b/gcc/cse.c
index 672fd2eaea9..0b331983c20 100644
--- a/gcc/cse.c
+++ b/gcc/cse.c
@@ -2135,7 +2135,7 @@ use_related_value (rtx x, struct table_elt *elt)
 {
   struct table_elt *relt = 0;
   struct table_elt *p, *q;
-  HOST_WIDE_INT offset;
+  offset_int offset;
 
   /* First, is there anything related known?
      If we have a table element, we can tell from that.
@@ -2192,9 +2192,15 @@ use_related_value (rtx x, struct table_elt *elt)
   if (q == 0)
     return 0;
 
-  offset = (get_integer_term (x) - get_integer_term (p->exp));
-  /* Note: OFFSET may be 0 if P->xexp and X are related by commutativity.  */
-  return plus_constant (q->mode, q->exp, offset);
+  offset = (offset_int (get_integer_term (x)) - get_integer_term (p->exp));
+  if (wi::fits_shwi_p (offset))
+    {
+      /* Note: OFFSET may be 0 if P->xexp and X are related
+	 by commutativity.  */
+      return plus_constant (q->mode, q->exp, offset.to_shwi ());
+    }
+  else
+    return 0;
 }
 
 

Reply via email to