From: Richard Biener Date: Tue, 26 Mar 2019 13:18:23 +0000 (+0000) Subject: backport: [multiple changes] X-Git-Tag: releases/gcc-7.5.0~515 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c300b1333030597725efedcf3020c41e833635aa;p=thirdparty%2Fgcc.git backport: [multiple changes] 2019-02-26 Richard Biener Backport from mainline 2019-02-12 Richard Biener PR tree-optimization/89253 * tree-ssa-loop-split.c (tree_ssa_split_loops): Check we can duplicate the loop. * gfortran.dg/pr89253.f: New testcase. 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. 2019-01-28 Richard Biener PR tree-optimization/88739 * tree-ssa-sccvn.c (vn_reference_lookup_3): Avoid generating BIT_FIELD_REFs of non-mode-precision integral operands. * gcc.c-torture/execute/pr88739.c: New test. From-SVN: r269942 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 58cd084a47d9..b81f2fd027a2 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,26 @@ +2019-02-26 Richard Biener + + Backport from mainline + 2019-02-12 Richard Biener + + PR tree-optimization/89253 + * tree-ssa-loop-split.c (tree_ssa_split_loops): Check we can + duplicate the loop. + + 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-01-28 Richard Biener + + PR tree-optimization/88739 + * tree-ssa-sccvn.c (vn_reference_lookup_3): Avoid generating + BIT_FIELD_REFs of non-mode-precision integral operands. + 2019-03-26 Richard Biener Backport from mainline diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 242c721bc982..cdcb617ca6a6 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,21 @@ +2019-02-26 Richard Biener + + Backport from mainline + 2019-02-12 Richard Biener + + PR tree-optimization/89253 + * gfortran.dg/pr89253.f: New testcase. + + 2019-02-08 Richard Biener + + PR middle-end/89223 + * gcc.dg/torture/pr89223.c: New testcase. + + 2019-01-28 Richard Biener + + PR tree-optimization/88739 + * gcc.c-torture/execute/pr88739.c: New test. + 2019-03-26 Richard Biener Backport from mainline diff --git a/gcc/testsuite/gcc.c-torture/execute/pr88739.c b/gcc/testsuite/gcc.c-torture/execute/pr88739.c new file mode 100644 index 000000000000..d4b32fbfc2d3 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr88739.c @@ -0,0 +1,59 @@ +/* PR tree-optimization/88739 */ +#if __SIZEOF_SHORT__ == 2 && __SIZEOF_INT__ == 4 && __CHAR_BIT__ == 8 +struct A +{ + unsigned int a, b, c; + unsigned int d : 30; + unsigned int e : 2; +}; + +union U +{ + struct A f; + unsigned int g[4]; + unsigned short h[8]; + unsigned char i[16]; +}; +volatile union U v = { .f.d = 0x4089 }; + +__attribute__((noipa)) void +bar (int x) +{ + static int i; + switch (i++) + { + case 0: if (x != v.f.d) __builtin_abort (); break; + case 1: if (x != v.f.e) __builtin_abort (); break; + case 2: if (x != v.g[3]) __builtin_abort (); break; + case 3: if (x != v.h[6]) __builtin_abort (); break; + case 4: if (x != v.h[7]) __builtin_abort (); break; + default: __builtin_abort (); break; + } +} + +void +foo (unsigned int x) +{ + union U u; + u.f.d = x >> 2; + u.f.e = 0; + bar (u.f.d); + bar (u.f.e); + bar (u.g[3]); + bar (u.h[6]); + bar (u.h[7]); +} + +int +main () +{ + foo (0x10224); + return 0; +} +#else +int +main () +{ + return 0; +} +#endif diff --git a/gcc/testsuite/gcc.dg/torture/pr89223.c b/gcc/testsuite/gcc.dg/torture/pr89223.c new file mode 100644 index 000000000000..1e828118ecb0 --- /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/testsuite/gfortran.dg/pr89253.f b/gcc/testsuite/gfortran.dg/pr89253.f new file mode 100644 index 000000000000..6dc9df138fd5 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/pr89253.f @@ -0,0 +1,19 @@ +! { dg-do compile } +! { dg-additional-options "-fsplit-loops -fno-tree-dominator-opts -std=legacy -w" } + program jr + integer :: w5, pg, zh + w5 = 0 + write (w5) + assign 0002 to w5 + do pg = 1, 3 + if (pg .eq. 1) then + do zh = 1, pg + end do + else + goto w5 + 0001 zh = 0 + 0002 zh = 0 + assign 0001 to w5 + endif + end do + end diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index 2480f4e55617..a349e3ec5f12 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -2118,6 +2118,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); @@ -2499,7 +2501,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; @@ -2536,9 +2538,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, diff --git a/gcc/tree-ssa-loop-split.c b/gcc/tree-ssa-loop-split.c index fd9721377495..3992597e2411 100644 --- a/gcc/tree-ssa-loop-split.c +++ b/gcc/tree-ssa-loop-split.c @@ -649,7 +649,8 @@ tree_ssa_split_loops (void) false, true) && niter.cmp != ERROR_MARK /* We can't yet handle loops controlled by a != predicate. */ - && niter.cmp != NE_EXPR) + && niter.cmp != NE_EXPR + && can_duplicate_loop_p (loop)) { if (split_loop (loop, &niter)) { diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index c93f1f261959..a2e3ce26dcbc 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -2029,6 +2029,7 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_, base2 = get_ref_base_and_extent (gimple_assign_lhs (def_stmt), &offset2, &size2, &maxsize2, &reverse); + tree def_rhs = gimple_assign_rhs1 (def_stmt); if (!reverse && maxsize2 != -1 && maxsize2 == size2 @@ -2041,11 +2042,14 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_, according to endianness. */ && (! INTEGRAL_TYPE_P (vr->type) || ref->size == TYPE_PRECISION (vr->type)) - && ref->size % BITS_PER_UNIT == 0) + && ref->size % BITS_PER_UNIT == 0 + && (! INTEGRAL_TYPE_P (TREE_TYPE (def_rhs)) + || (TYPE_PRECISION (TREE_TYPE (def_rhs)) + == GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (def_rhs)))))) { code_helper rcode = BIT_FIELD_REF; tree ops[3]; - ops[0] = SSA_VAL (gimple_assign_rhs1 (def_stmt)); + ops[0] = SSA_VAL (def_rhs); ops[1] = bitsize_int (ref->size); ops[2] = bitsize_int (offset - offset2); tree val = vn_nary_build_or_lookup (rcode, vr->type, ops);