From: Richard Biener Date: Mon, 7 Nov 2016 12:26:00 +0000 (+0000) Subject: re PR tree-optimization/78218 (wrong code at -Os and above on x86_64-linux-gnu (in... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=20770eb80bf59f4fe1d71408b841669c70550e6c;p=gcc.git re PR tree-optimization/78218 (wrong code at -Os and above on x86_64-linux-gnu (in both 32-bit and 64-bit modes)) 2016-11-07 Richard Biener PR tree-optimization/78218 * gimple-ssa-store-merging.c (pass_store_merging::terminate_all_aliasing_chains): Drop unused argument, fix alias check to also consider uses. (pass_store_merging::execute): Adjust. * gcc.dg/torture/pr78218.c: New testcase. From-SVN: r241900 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 262f0068b48..5ccd3b4ca62 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2016-11-07 Richard Biener + + PR tree-optimization/78218 + * gimple-ssa-store-merging.c + (pass_store_merging::terminate_all_aliasing_chains): + Drop unused argument, fix alias check to also consider uses. + (pass_store_merging::execute): Adjust. + 2016-11-07 Richard Biener PR tree-optimization/78228 diff --git a/gcc/gimple-ssa-store-merging.c b/gcc/gimple-ssa-store-merging.c index 36bc833af91..57b855671db 100644 --- a/gcc/gimple-ssa-store-merging.c +++ b/gcc/gimple-ssa-store-merging.c @@ -726,7 +726,7 @@ private: hash_map m_stores; bool terminate_and_process_all_chains (); - bool terminate_all_aliasing_chains (tree, imm_store_chain_info **, + bool terminate_all_aliasing_chains (imm_store_chain_info **, bool, gimple *); bool terminate_and_release_chain (imm_store_chain_info *); }; // class pass_store_merging @@ -755,8 +755,7 @@ pass_store_merging::terminate_and_process_all_chains () If that is the case we have to terminate any chain anchored at BASE. */ bool -pass_store_merging::terminate_all_aliasing_chains (tree dest, - imm_store_chain_info +pass_store_merging::terminate_all_aliasing_chains (imm_store_chain_info **chain_info, bool var_offset_p, gimple *stmt) @@ -788,7 +787,10 @@ pass_store_merging::terminate_all_aliasing_chains (tree dest, unsigned int i; FOR_EACH_VEC_ELT ((*chain_info)->m_store_info, i, info) { - if (stmt_may_clobber_ref_p (info->stmt, dest)) + if (ref_maybe_used_by_stmt_p (stmt, + gimple_assign_lhs (info->stmt)) + || stmt_may_clobber_ref_p (stmt, + gimple_assign_lhs (info->stmt))) { if (dump_file && (dump_flags & TDF_DETAILS)) { @@ -1458,7 +1460,7 @@ pass_store_merging::execute (function *fun) } /* Store aliases any existing chain? */ - terminate_all_aliasing_chains (lhs, chain_info, false, stmt); + terminate_all_aliasing_chains (chain_info, false, stmt); /* Start a new chain. */ struct imm_store_chain_info *new_chain = new imm_store_chain_info (base_addr); @@ -1477,13 +1479,13 @@ pass_store_merging::execute (function *fun) } } else - terminate_all_aliasing_chains (lhs, chain_info, + terminate_all_aliasing_chains (chain_info, offset != NULL_TREE, stmt); continue; } - terminate_all_aliasing_chains (NULL_TREE, NULL, false, stmt); + terminate_all_aliasing_chains (NULL, false, stmt); } terminate_and_process_all_chains (); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0dff659bda4..242b51b3764 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-11-07 Richard Biener + + PR tree-optimization/78218 + * gcc.dg/torture/pr78218.c: New testcase. + 2016-11-07 Richard Biener PR tree-optimization/78228 diff --git a/gcc/testsuite/gcc.dg/torture/pr78218.c b/gcc/testsuite/gcc.dg/torture/pr78218.c new file mode 100644 index 00000000000..b3e2892429d --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr78218.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ + +struct +{ + int v; +} a[2]; + +int b; + +void __attribute__((noinline,noclone)) +check () +{ + if (a[0].v != 1) + __builtin_abort (); +} + +int main () +{ + a[1].v = 1; + a[0] = a[1]; + a[1].v = 0; + check (a); + return 0; +}