https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98773

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Hmm, can you see whether just the

diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c
index 9d07b415e9d..d19c5eb51e4 100644
--- a/gcc/tree-data-ref.c
+++ b/gcc/tree-data-ref.c
@@ -3924,9 +3924,25 @@ initialize_matrix_A (lambda_matrix A, tree chrec,
unsigned index, int mult)
   switch (TREE_CODE (chrec))
     {
     case POLYNOMIAL_CHREC:
-      if (!cst_and_fits_in_hwi (CHREC_RIGHT (chrec)))
+      /* CHREC_RIGHT and its negated value should fit in a lambda_int.
+        Pointer typed chrecs right are to be interpreted signed.  */
+      HOST_WIDE_INT chrec_right;
+      if (POINTER_TYPE_P (chrec_type (chrec)))
+       {
+         if (!cst_and_fits_in_hwi (CHREC_RIGHT (chrec)))
+           return chrec_dont_know;
+         chrec_right = int_cst_value (CHREC_RIGHT (chrec));
+       }
+      else
+       {
+         if (!tree_fits_shwi_p (CHREC_RIGHT (chrec)))
+           return chrec_dont_know;
+         chrec_right = tree_to_shwi (CHREC_RIGHT (chrec));
+       }
+      /* We want to be able to negate without overflow.  */
+      if (chrec_right == HOST_WIDE_INT_MIN)
        return chrec_dont_know;
-      A[index][0] = mult * int_cst_value (CHREC_RIGHT (chrec));
+      A[index][0] = mult * chrec_right;
       return initialize_matrix_A (A, CHREC_LEFT (chrec), index + 1, mult);

     case PLUS_EXPR:

part of the change is enough to trigger the failure?

Reply via email to