diff mbox series

Micro-optimize store-merging terminate-all-aliasing-chains

Message ID nycvar.YFH.7.76.2001101333510.5566@zhemvz.fhfr.qr
State New
Headers show
Series Micro-optimize store-merging terminate-all-aliasing-chains | expand

Commit Message

Richard Biener Jan. 10, 2020, 12:35 p.m. UTC
This caches alias info avoiding repeated (expensive) 
get_ref_base_and_extent.  It doesn't address the unlimited quadraticness
in this function the PR93199 testcase runs into.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2020-01-10  Richard Biener  <rguenther@suse.de>

	* gimple-ssa-store-merging
	(pass_store_merging::terminate_all_aliasing_chains): Cache alias info.
diff mbox series

Patch

Index: gcc/gimple-ssa-store-merging.c
===================================================================
--- gcc/gimple-ssa-store-merging.c	(revision 280096)
+++ gcc/gimple-ssa-store-merging.c	(working copy)
@@ -2219,6 +2219,8 @@  pass_store_merging::terminate_all_aliasi
     return false;
 
   tree store_lhs = gimple_store_p (stmt) ? gimple_get_lhs (stmt) : NULL_TREE;
+  ao_ref store_lhs_ref;
+  ao_ref_init (&store_lhs_ref, store_lhs);
   for (imm_store_chain_info *next = m_stores_head, *cur = next; cur; cur = next)
     {
       next = cur->next;
@@ -2233,9 +2235,12 @@  pass_store_merging::terminate_all_aliasi
       FOR_EACH_VEC_ELT (cur->m_store_info, i, info)
 	{
 	  tree lhs = gimple_assign_lhs (info->stmt);
-	  if (ref_maybe_used_by_stmt_p (stmt, lhs)
-	      || stmt_may_clobber_ref_p (stmt, lhs)
-	      || (store_lhs && refs_output_dependent_p (store_lhs, lhs)))
+	  ao_ref lhs_ref;
+	  ao_ref_init (&lhs_ref, lhs);
+	  if (ref_maybe_used_by_stmt_p (stmt, &lhs_ref)
+	      || stmt_may_clobber_ref_p_1 (stmt, &lhs_ref)
+	      || (store_lhs && refs_may_alias_p_1 (&store_lhs_ref,
+						   &lhs_ref, false)))
 	    {
 	      if (dump_file && (dump_flags & TDF_DETAILS))
 		{