diff mbox

Fix PR78218

Message ID alpine.LSU.2.11.1611071318550.5294@t29.fhfr.qr
State New
Headers show

Commit Message

Richard Biener Nov. 7, 2016, 12:19 p.m. UTC
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied.

Richard.

2016-11-07  Richard Biener  <rguenther@suse.de>

	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.

Comments

Thomas Schwinge Feb. 17, 2017, 8:06 a.m. UTC | #1
Hi Richard!

On Mon, 7 Nov 2016 13:19:21 +0100 (CET), Richard Biener <rguenther@suse.de> wrote:
> 	PR tree-optimization/78218

> --- gcc/testsuite/gcc.dg/torture/pr78218.c	(revision 0)
> +++ gcc/testsuite/gcc.dg/torture/pr78218.c	(working copy)
> @@ -0,0 +1,24 @@
> +/* { dg-do run } */
> +
> +struct 
> +{
> +  int v;
> +} a[2];
> +
> +int b; 
> +
> +void __attribute__((noinline,noclone))
> +check ()

Is it itentional that here, check doesn't specify any formal parameters,
but...

> +{
> +  if (a[0].v != 1)
> +    __builtin_abort ();
> +}
> +
> +int main ()
> +{
> +  a[1].v = 1;
> +  a[0] = a[1];
> +  a[1].v = 0;
> +  check (a);

... here it is called, passing in "a"?  (PTX doesn't like such
mismatches.)

> +  return 0;
> +}

OK to commit the obvious patch to change the call site?  (Not yet
tested.)

-  check (a);
+  check ();


Grüße
 Thomas
Richard Biener Feb. 17, 2017, 9:22 a.m. UTC | #2
On Fri, 17 Feb 2017, Thomas Schwinge wrote:

> Hi Richard!
> 
> On Mon, 7 Nov 2016 13:19:21 +0100 (CET), Richard Biener <rguenther@suse.de> wrote:
> > 	PR tree-optimization/78218
> 
> > --- gcc/testsuite/gcc.dg/torture/pr78218.c	(revision 0)
> > +++ gcc/testsuite/gcc.dg/torture/pr78218.c	(working copy)
> > @@ -0,0 +1,24 @@
> > +/* { dg-do run } */
> > +
> > +struct 
> > +{
> > +  int v;
> > +} a[2];
> > +
> > +int b; 
> > +
> > +void __attribute__((noinline,noclone))
> > +check ()
> 
> Is it itentional that here, check doesn't specify any formal parameters,
> but...
> 
> > +{
> > +  if (a[0].v != 1)
> > +    __builtin_abort ();
> > +}
> > +
> > +int main ()
> > +{
> > +  a[1].v = 1;
> > +  a[0] = a[1];
> > +  a[1].v = 0;
> > +  check (a);
> 
> ... here it is called, passing in "a"?  (PTX doesn't like such
> mismatches.)
> 
> > +  return 0;
> > +}
> 
> OK to commit the obvious patch to change the call site?  (Not yet
> tested.)
> 
> -  check (a);
> +  check ();

Yes.  Can you quickly check if the adjusted testcase still fails before
the patch?

Thanks,
Richard.
diff mbox

Patch

Index: gcc/gimple-ssa-store-merging.c
===================================================================
--- gcc/gimple-ssa-store-merging.c	(revision 241893)
+++ gcc/gimple-ssa-store-merging.c	(working copy)
@@ -726,7 +726,7 @@  private:
   hash_map<tree_operand_hash, struct imm_store_chain_info *> 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_proces
    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_aliasi
 	  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 *f
 		    }
 
 		  /* 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 *f
 		    }
 		}
 	      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 ();
     }
Index: gcc/testsuite/gcc.dg/torture/pr78218.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr78218.c	(revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr78218.c	(working copy)
@@ -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;
+}