From 8153c366de6a37108197fb9e66d96cf01b52f74f Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 31 Jul 2019 15:40:36 +0000 Subject: [PATCH] Backport PRs 91126, 91131, 91145, 91162, 91200 2019-07-31 Richard Biener Backport from mainline 2019-07-19 Richard Biener PR tree-optimization/91200 * tree-ssa-phiopt.c (cond_store_replacement): Check we have no PHI nodes in middle-bb. * gcc.dg/torture/pr91200.c: New testcase. 2019-07-15 Richard Biener PR middle-end/91162 * tree-cfg.c (move_block_to_fn): When releasing a virtual PHI node make sure to replace all uses with something valid. * gcc.dg/autopar/pr91162.c: New testcase. 2019-07-12 Richard Biener PR tree-optimization/91145 * tree-vect-slp.c (vect_build_slp_tree_2): Fix reduction chain check. * gcc.dg/torture/pr91145.c: New testcase. 2019-07-11 Richard Biener PR middle-end/91131 * gimplify.c (gimplify_compound_literal_expr): Force a temporary when the object is volatile and we have not cleared it even though there are no nonzero elements. * gcc.target/i386/pr91131.c: New testcase. 2019-07-10 Richard Biener PR tree-optimization/91126 * tree-ssa-sccvn.c (n_walk_cb_data::push_partial_def): Adjust native encoding offset for BYTES_BIG_ENDIAN. (vn_reference_lookup_3): Likewise. * gcc.dg/torture/pr91126.c: New testcase. From-SVN: r273939 --- gcc/ChangeLog | 35 +++++++++++++++++++++++++ gcc/gimplify.c | 2 +- gcc/testsuite/ChangeLog | 28 ++++++++++++++++++++ gcc/testsuite/gcc.dg/autopar/pr91162.c | 25 ++++++++++++++++++ gcc/testsuite/gcc.dg/torture/pr91126.c | 28 ++++++++++++++++++++ gcc/testsuite/gcc.dg/torture/pr91145.c | 16 +++++++++++ gcc/testsuite/gcc.dg/torture/pr91200.c | 32 ++++++++++++++++++++++ gcc/testsuite/gcc.target/i386/pr91131.c | 19 ++++++++++++++ gcc/tree-cfg.c | 9 ++++++- gcc/tree-ssa-phiopt.c | 5 ++++ gcc/tree-ssa-sccvn.c | 15 +++++++++-- gcc/tree-vect-slp.c | 3 ++- 12 files changed, 212 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/autopar/pr91162.c create mode 100644 gcc/testsuite/gcc.dg/torture/pr91126.c create mode 100644 gcc/testsuite/gcc.dg/torture/pr91145.c create mode 100644 gcc/testsuite/gcc.dg/torture/pr91200.c create mode 100644 gcc/testsuite/gcc.target/i386/pr91131.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3bc840c518a3..bd8fc676fddd 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,38 @@ +2019-07-31 Richard Biener + + Backport from mainline + 2019-07-19 Richard Biener + + PR tree-optimization/91200 + * tree-ssa-phiopt.c (cond_store_replacement): Check we have + no PHI nodes in middle-bb. + + 2019-07-15 Richard Biener + + PR middle-end/91162 + * tree-cfg.c (move_block_to_fn): When releasing a virtual PHI + node make sure to replace all uses with something valid. + + 2019-07-12 Richard Biener + + PR tree-optimization/91145 + * tree-vect-slp.c (vect_build_slp_tree_2): Fix reduction + chain check. + + 2019-07-11 Richard Biener + + PR middle-end/91131 + * gimplify.c (gimplify_compound_literal_expr): Force a temporary + when the object is volatile and we have not cleared it even though + there are no nonzero elements. + + 2019-07-10 Richard Biener + + PR tree-optimization/91126 + * tree-ssa-sccvn.c (n_walk_cb_data::push_partial_def): Adjust + native encoding offset for BYTES_BIG_ENDIAN. + (vn_reference_lookup_3): Likewise. + 2019-07-30 Jan Hubicka Backport from mainline diff --git a/gcc/gimplify.c b/gcc/gimplify.c index f811221d33f7..a55242e90813 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -4962,7 +4962,7 @@ gimplify_init_constructor (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p, one field to assign, initialize the target from a temporary. */ if (TREE_THIS_VOLATILE (object) && !TREE_ADDRESSABLE (type) - && num_nonzero_elements > 0 + && (num_nonzero_elements > 0 || !cleared) && vec_safe_length (elts) > 1) { tree temp = create_tmp_var (TYPE_MAIN_VARIANT (type)); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8765c2c44226..5e125672312b 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,31 @@ +2019-07-31 Richard Biener + + Backport from mainline + 2019-07-19 Richard Biener + + PR tree-optimization/91200 + * gcc.dg/torture/pr91200.c: New testcase. + + 2019-07-15 Richard Biener + + PR middle-end/91162 + * gcc.dg/autopar/pr91162.c: New testcase. + + 2019-07-12 Richard Biener + + PR tree-optimization/91145 + * gcc.dg/torture/pr91145.c: New testcase. + + 2019-07-11 Richard Biener + + PR middle-end/91131 + * gcc.target/i386/pr91131.c: New testcase. + + 2019-07-10 Richard Biener + + PR tree-optimization/91126 + * gcc.dg/torture/pr91126.c: New testcase. + 2019-07-30 Steven G. Kargl PR fortran/91296 diff --git a/gcc/testsuite/gcc.dg/autopar/pr91162.c b/gcc/testsuite/gcc.dg/autopar/pr91162.c new file mode 100644 index 000000000000..ff243e4c1c0b --- /dev/null +++ b/gcc/testsuite/gcc.dg/autopar/pr91162.c @@ -0,0 +1,25 @@ +/* { dg-do compile { target int128 } } */ +/* { dg-options "-O -ftree-parallelize-loops=2 -fno-tree-dominator-opts --param parloops-min-per-thread=30" } */ + +void +zf (__int128 ct) +{ + __int128 *rk = &ct; + + if (0) + { + int jj; + +t9: + for (jj = 0; jj < 60; ++jj) + { + } + + __builtin_unreachable (); + } + + while (*rk < 1) + ++*rk; + + goto t9; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr91126.c b/gcc/testsuite/gcc.dg/torture/pr91126.c new file mode 100644 index 000000000000..8e34815b9a78 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr91126.c @@ -0,0 +1,28 @@ +/* { dg-do run } */ + +struct S +{ + __INT32_TYPE__ a : 24; + __INT32_TYPE__ b : 8; +} s; + +int +main() +{ + s.a = 0xfefefe; + s.b = 0xfe; + unsigned char c; + c = ((unsigned char *)&s)[0]; + if (c != 0xfe) + __builtin_abort (); + c = ((unsigned char *)&s)[1]; + if (c != 0xfe) + __builtin_abort (); + c = ((unsigned char *)&s)[2]; + if (c != 0xfe) + __builtin_abort (); + c = ((unsigned char *)&s)[3]; + if (c != 0xfe) + __builtin_abort (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/torture/pr91145.c b/gcc/testsuite/gcc.dg/torture/pr91145.c new file mode 100644 index 000000000000..7d62ad11fafa --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr91145.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-march=skylake-avx512" { target x86_64-*-* i?86-*-* } } */ + +int a, c; +unsigned b, e; +extern unsigned d[100]; + +void f() +{ + for (int g = 0; g < 70; g++) + { + + b += d[g] - c; + e -= g ^ a; + } +} diff --git a/gcc/testsuite/gcc.dg/torture/pr91200.c b/gcc/testsuite/gcc.dg/torture/pr91200.c new file mode 100644 index 000000000000..09db9e142c73 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr91200.c @@ -0,0 +1,32 @@ +/* { dg-do compile } */ + +int printf (const char *, ...); + +char a; +int b, c, **d; + +int main () +{ + int f = -128, *g, *h[2] = {0, 0}, i; + printf("0"); + if (a) + { + while (f > a) { + int *j = &i; + *j |= 0; + } + h[i] = &c; + } + if (h[1]) + { + int **k = &g; + *k = &f; + while (i) + { + int **l[] = {&g}; + } + int **m = &g; + *d = *m = &b; + } + return 0; +} diff --git a/gcc/testsuite/gcc.target/i386/pr91131.c b/gcc/testsuite/gcc.target/i386/pr91131.c new file mode 100644 index 000000000000..85008ff8a8bd --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr91131.c @@ -0,0 +1,19 @@ +/* { dg-do compile } */ +/* { dg-options "-O" } */ + +struct Reg_T { + unsigned int a : 3; + unsigned int b : 1; + unsigned int c : 4; +}; + +volatile struct Reg_T Reg_A; + +int +main () +{ + Reg_A = (struct Reg_T){ .a = 0, .b = 0, .c = 0 }; + return 0; +} + +/* { dg-final { scan-assembler-times "mov\[^\r\n\]*Reg_A" 1 } } */ diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 587408150fb0..32be59acfb06 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -7040,7 +7040,14 @@ move_block_to_fn (struct function *dest_cfun, basic_block bb, if (virtual_operand_p (op)) { /* Remove the phi nodes for virtual operands (alias analysis will be - run for the new function, anyway). */ + run for the new function, anyway). But replace all uses that + might be outside of the region we move. */ + use_operand_p use_p; + imm_use_iterator iter; + gimple *use_stmt; + FOR_EACH_IMM_USE_STMT (use_stmt, iter, op) + FOR_EACH_IMM_USE_ON_STMT (use_p, iter) + SET_USE (use_p, SSA_NAME_VAR (op)); remove_phi_node (&psi, true); continue; } diff --git a/gcc/tree-ssa-phiopt.c b/gcc/tree-ssa-phiopt.c index 90674a2f3c49..8bf09bdf2a0c 100644 --- a/gcc/tree-ssa-phiopt.c +++ b/gcc/tree-ssa-phiopt.c @@ -2198,6 +2198,11 @@ cond_store_replacement (basic_block middle_bb, basic_block join_bb, || gimple_has_volatile_ops (assign)) return false; + /* And no PHI nodes so all uses in the single stmt are also + available where we insert to. */ + if (!gimple_seq_empty_p (phi_nodes (middle_bb))) + return false; + locus = gimple_location (assign); lhs = gimple_assign_lhs (assign); rhs = gimple_assign_rhs1 (assign); diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index cd9448138295..8bc2a9da6c82 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -2238,9 +2238,20 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *vr_, tree rhs = gimple_assign_rhs1 (def_stmt); if (TREE_CODE (rhs) == SSA_NAME) rhs = SSA_VAL (rhs); - len = native_encode_expr (gimple_assign_rhs1 (def_stmt), + unsigned pad = 0; + if (BYTES_BIG_ENDIAN + && is_a (TYPE_MODE (TREE_TYPE (rhs)))) + { + /* On big-endian the padding is at the 'front' so + just skip the initial bytes. */ + fixed_size_mode mode + = as_a (TYPE_MODE (TREE_TYPE (rhs))); + pad = GET_MODE_SIZE (mode) - size2 / BITS_PER_UNIT; + } + len = native_encode_expr (rhs, buffer, sizeof (buffer), - (offseti - offset2) / BITS_PER_UNIT); + ((offseti - offset2) / BITS_PER_UNIT + + pad)); if (len > 0 && len * BITS_PER_UNIT >= maxsizei) { tree type = vr->type; diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index 40db1a208f11..c3137460fd14 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -1126,7 +1126,8 @@ vect_build_slp_tree_2 (vec_info *vinfo, FOR_EACH_VEC_ELT (stmts, i, other_info) { /* But for reduction chains only check on the first stmt. */ - if (REDUC_GROUP_FIRST_ELEMENT (other_info) + if (!STMT_VINFO_DATA_REF (other_info) + && REDUC_GROUP_FIRST_ELEMENT (other_info) && REDUC_GROUP_FIRST_ELEMENT (other_info) != stmt_info) continue; if (STMT_VINFO_DEF_TYPE (other_info) != def_type) -- 2.47.2