Patchwork PR middle-end/51472: set DECL_GIMPLE_REG_P on TM vector saves

login
register
mail settings
Submitter Aldy Hernandez
Date Dec. 21, 2011, 1:52 p.m.
Message ID <4EF1E490.2090609@redhat.com>
Download mbox | patch
Permalink /patch/132643/
State New
Headers show

Comments

Aldy Hernandez - Dec. 21, 2011, 1:52 p.m.
> You can't simply do
>
> +	  if (TREE_CODE (TREE_TYPE (var)) == COMPLEX_TYPE
> +	      || TREE_CODE (TREE_TYPE (var)) == VECTOR_TYPE)
> +	    DECL_GIMPLE_REG_P (var) = 1;
> +	  update_stmt (stmt);
>
> where is 'var' created?  At _that_ point you should do the above
> (or use create_tmp_reg instead of create_tmp_var).  Existing uses
> of var might prevent DECL_GIMPLE_REG_P from being set
> (which also means creating an SSA name of it is not allowed).

Oh neat... create_tmp_reg will do all this for me.

OK?
PR middle-end/51472
	* trans-mem.c (tm_log_emit_saves): Call update_stmt.
	(tm_log_add): Use create_tmp_var_reg.
Jakub Jelinek - Dec. 21, 2011, 2:07 p.m.
On Wed, Dec 21, 2011 at 07:52:16AM -0600, Aldy Hernandez wrote:
> Oh neat... create_tmp_reg will do all this for me.

I don't think that update_stmt is needed there.
The stmt is freshly allocated a few lines above it:
	stmt = gimple_build_assign (lp->save_var, unshare_expr (lp->addr));
so the modified flag is still set and thus when you gsi_insert_before
it afterwards, it will update_stmt_if_modified, which is the same as
update_stmt when the modified flag is set.

The first hunk looks okay.

> --- trans-mem.c	(revision 182542)
> +++ trans-mem.c	(working copy)
> @@ -1003,7 +1003,7 @@ tm_log_add (basic_block entry_block, tre
>  	     special constructors and the like.  */
>  	  && !TREE_ADDRESSABLE (type))
>  	{
> -	  lp->save_var = create_tmp_var (TREE_TYPE (lp->addr), "tm_save");
> +	  lp->save_var = create_tmp_reg (TREE_TYPE (lp->addr), "tm_save");
>  	  add_referenced_var (lp->save_var);
>  	  lp->stmts = NULL;
>  	  lp->entry_block = entry_block;
> @@ -1188,6 +1188,7 @@ tm_log_emit_saves (basic_block entry_blo
>  	{
>  	  lp->save_var = make_ssa_name (lp->save_var, stmt);
>  	  gimple_assign_set_lhs (stmt, lp->save_var);
> +	  update_stmt (stmt);
>  	}
>  
>        gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);


	Jakub

Patch

Index: testsuite/gcc.dg/tm/pr51472.c
===================================================================
--- testsuite/gcc.dg/tm/pr51472.c	(revision 0)
+++ testsuite/gcc.dg/tm/pr51472.c	(revision 0)
@@ -0,0 +1,17 @@ 
+/* { dg-do compile } */
+/* { dg-options "-fgnu-tm -O  --param tm-max-aggregate-size=32" } */
+
+typedef int __attribute__ ((vector_size (16))) vectype;
+vectype v;
+
+void
+foo (int c)
+{
+  vectype *p = __builtin_malloc (sizeof (vectype));
+  __transaction_atomic
+  {
+    *p = v;
+    if (c)
+      __transaction_cancel;
+  }
+}
Index: trans-mem.c
===================================================================
--- trans-mem.c	(revision 182542)
+++ trans-mem.c	(working copy)
@@ -1003,7 +1003,7 @@  tm_log_add (basic_block entry_block, tre
 	     special constructors and the like.  */
 	  && !TREE_ADDRESSABLE (type))
 	{
-	  lp->save_var = create_tmp_var (TREE_TYPE (lp->addr), "tm_save");
+	  lp->save_var = create_tmp_reg (TREE_TYPE (lp->addr), "tm_save");
 	  add_referenced_var (lp->save_var);
 	  lp->stmts = NULL;
 	  lp->entry_block = entry_block;
@@ -1188,6 +1188,7 @@  tm_log_emit_saves (basic_block entry_blo
 	{
 	  lp->save_var = make_ssa_name (lp->save_var, stmt);
 	  gimple_assign_set_lhs (stmt, lp->save_var);
+	  update_stmt (stmt);
 	}
 
       gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);