re PR tree-optimization/89223 (internal compiler error: in int_cst_value, at tree...
authorRichard Biener <rguenther@suse.de>
Fri, 8 Feb 2019 08:18:09 +0000 (08:18 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Fri, 8 Feb 2019 08:18:09 +0000 (08:18 +0000)
2019-02-08  Richard Biener  <rguenther@suse.de>

PR middle-end/89223
* tree-data-ref.c (initialize_matrix_A): Fail if constant
doesn't fit in HWI.
(analyze_subscript_affine_affine): Handle failure from
initialize_matrix_A.

* gcc.dg/torture/pr89223.c: New testcase.

From-SVN: r268666

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr89223.c [new file with mode: 0644]
gcc/tree-data-ref.c

index f2652a422591bdb6d57700363956384299ea8f2e..4e78ab6500215c76a828e3fd94443d090a264303 100644 (file)
@@ -1,3 +1,11 @@
+2019-02-08  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/89223
+       * tree-data-ref.c (initialize_matrix_A): Fail if constant
+       doesn't fit in HWI.
+       (analyze_subscript_affine_affine): Handle failure from
+       initialize_matrix_A.
+
 2019-02-08  Jakub Jelinek  <jakub@redhat.com>
 
        * cfganal.c (pre_and_rev_post_order_compute_fn): Use fn instead of
index cb500f534890cfb8d4370d52e4fa698d854ddec4..9f4296b043857ca48254130a2a71c0e67222158a 100644 (file)
@@ -1,3 +1,8 @@
+2019-02-08  Richard Biener  <rguenther@suse.de>
+
+       PR middle-end/89223
+       * gcc.dg/torture/pr89223.c: New testcase.
+
 2019-02-07  David Malcolm  <dmalcolm@redhat.com>
 
        PR tree-optimization/86637
diff --git a/gcc/testsuite/gcc.dg/torture/pr89223.c b/gcc/testsuite/gcc.dg/torture/pr89223.c
new file mode 100644 (file)
index 0000000..1e82811
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do compile { target int128 } } */
+
+int a[5];
+unsigned __int128 b;
+void c()
+{
+  b = 4;
+  for (;; b--)
+    a[b] = ({ a[b + b]; });
+}
index 7d1f03c66af693360ef64d70293848e96ccff656..e536b463e9643f927af785662dff7a5e2886e78d 100644 (file)
@@ -3191,6 +3191,8 @@ 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)))
+       return chrec_dont_know;
       A[index][0] = mult * int_cst_value (CHREC_RIGHT (chrec));
       return initialize_matrix_A (A, CHREC_LEFT (chrec), index + 1, mult);
 
@@ -3574,7 +3576,7 @@ analyze_subscript_affine_affine (tree chrec_a,
                                 tree *last_conflicts)
 {
   unsigned nb_vars_a, nb_vars_b, dim;
-  HOST_WIDE_INT init_a, init_b, gamma, gcd_alpha_beta;
+  HOST_WIDE_INT gamma, gcd_alpha_beta;
   lambda_matrix A, U, S;
   struct obstack scratch_obstack;
 
@@ -3611,9 +3613,20 @@ analyze_subscript_affine_affine (tree chrec_a,
   A = lambda_matrix_new (dim, 1, &scratch_obstack);
   S = lambda_matrix_new (dim, 1, &scratch_obstack);
 
-  init_a = int_cst_value (initialize_matrix_A (A, chrec_a, 0, 1));
-  init_b = int_cst_value (initialize_matrix_A (A, chrec_b, nb_vars_a, -1));
-  gamma = init_b - init_a;
+  tree init_a = initialize_matrix_A (A, chrec_a, 0, 1);
+  tree init_b = initialize_matrix_A (A, chrec_b, nb_vars_a, -1);
+  if (init_a == chrec_dont_know
+      || init_b == chrec_dont_know)
+    {
+      if (dump_file && (dump_flags & TDF_DETAILS))
+       fprintf (dump_file, "affine-affine test failed: "
+                "representation issue.\n");
+      *overlaps_a = conflict_fn_not_known ();
+      *overlaps_b = conflict_fn_not_known ();
+      *last_conflicts = chrec_dont_know;
+      goto end_analyze_subs_aa;
+    }
+  gamma = int_cst_value (init_b) - int_cst_value (init_a);
 
   /* Don't do all the hard work of solving the Diophantine equation
      when we already know the solution: for example,