From 2536d696a3fc101af0b731c10351777c4c0f0bc1 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Fri, 8 Feb 2019 08:18:09 +0000 Subject: [PATCH] re PR tree-optimization/89223 (internal compiler error: in int_cst_value, at tree.c:11226) 2019-02-08 Richard Biener 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 | 8 ++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.dg/torture/pr89223.c | 10 ++++++++++ gcc/tree-data-ref.c | 21 +++++++++++++++++---- 4 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr89223.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f2652a42259..4e78ab65002 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2019-02-08 Richard Biener + + 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 * cfganal.c (pre_and_rev_post_order_compute_fn): Use fn instead of diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cb500f53489..9f4296b0438 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-02-08 Richard Biener + + PR middle-end/89223 + * gcc.dg/torture/pr89223.c: New testcase. + 2019-02-07 David Malcolm 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 index 00000000000..1e828118ecb --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr89223.c @@ -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]; }); +} diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index 7d1f03c66af..e536b463e96 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -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, -- 2.30.2