public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [trans-mem] avoid transforming already optimized memory variants
@ 2009-11-17 15:25 Aldy Hernandez
  2009-11-17 16:48 ` Richard Henderson
  0 siblings, 1 reply; 4+ messages in thread
From: Aldy Hernandez @ 2009-11-17 15:25 UTC (permalink / raw)
  To: gcc-patches, rth

This patch makes sure we don't do global memory optimizations on already
optimized variants.  This can happen on user coded read-after-write,
write-after-read, etc, variants.

OK for branch?

	* trans-mem.c (tm_memopt_transform_blocks): Check for simple loads
	and stores.
	(is_tm_simple_load): New.
	(is_tm_simple_store): New.

Index: trans-mem.c
===================================================================
--- trans-mem.c	(revision 154247)
+++ trans-mem.c	(working copy)
@@ -324,6 +324,32 @@ is_tm_load (gimple stmt)
 	  && BUILTIN_TM_LOAD_P (DECL_FUNCTION_CODE (fndecl)));
 }
 
+/* Same as above, but for simple TM loads, that is, not the
+   after-write, after-read, etc optimized variants.  */
+
+static bool
+is_tm_simple_load (gimple stmt)
+{
+  tree fndecl;
+
+  if (gimple_code (stmt) != GIMPLE_CALL)
+    return false;
+
+  fndecl = gimple_call_fndecl (stmt);
+  if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
+    {
+      enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
+      return (fcode == BUILT_IN_TM_LOAD_1
+	      || fcode == BUILT_IN_TM_LOAD_2
+	      || fcode == BUILT_IN_TM_LOAD_4
+	      || fcode == BUILT_IN_TM_LOAD_8
+	      || fcode == BUILT_IN_TM_LOAD_FLOAT
+	      || fcode == BUILT_IN_TM_LOAD_DOUBLE
+	      || fcode == BUILT_IN_TM_LOAD_LDOUBLE);
+    }
+  return false;
+}
+
 /* Return true if STMT is a TM store.  */
 
 static bool
@@ -339,6 +365,32 @@ is_tm_store (gimple stmt)
 	  && BUILTIN_TM_STORE_P (DECL_FUNCTION_CODE (fndecl)));
 }
 
+/* Same as above, but for simple TM stores, that is, not the
+   after-write, after-read, etc optimized variants.  */
+
+static bool
+is_tm_simple_store (gimple stmt)
+{
+  tree fndecl;
+
+  if (gimple_code (stmt) != GIMPLE_CALL)
+    return false;
+
+  fndecl = gimple_call_fndecl (stmt);
+  if (fndecl && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL)
+    {
+      enum built_in_function fcode = DECL_FUNCTION_CODE (fndecl);
+      return (fcode == BUILT_IN_TM_STORE_1
+	      || fcode == BUILT_IN_TM_STORE_2
+	      || fcode == BUILT_IN_TM_STORE_4
+	      || fcode == BUILT_IN_TM_STORE_8
+	      || fcode == BUILT_IN_TM_STORE_FLOAT
+	      || fcode == BUILT_IN_TM_STORE_DOUBLE
+	      || fcode == BUILT_IN_TM_STORE_LDOUBLE);
+    }
+  return false;
+}
+
 /* Return true if FNDECL is BUILT_IN_TM_ABORT.  */
 
 static bool
@@ -2652,11 +2704,7 @@ tm_memopt_transform_blocks (VEC (basic_b
 	  bitmap store_antic = STORE_ANTIC_OUT (bb);
 	  unsigned int loc;
 
-	  /* FIXME: Make sure we're not transforming something like a
-	     user-coded read-after-write, etc.  Check for simple
-	     loads, not the optimized variants.  Similarly for
-	     is_tm_store below.  */
-	  if (is_tm_load (stmt))
+	  if (is_tm_simple_load (stmt))
 	    {
 	      loc = tm_memopt_value_number (stmt, NO_INSERT);
 	      if (store_avail && bitmap_bit_p (store_avail, loc))
@@ -2671,7 +2719,7 @@ tm_memopt_transform_blocks (VEC (basic_b
 	      else
 		bitmap_set_bit (read_avail, loc);
 	    }
-	  else if (is_tm_store (stmt))
+	  else if (is_tm_simple_store (stmt))
 	    {
 	      loc = tm_memopt_value_number (stmt, NO_INSERT);
 	      if (store_avail && bitmap_bit_p (store_avail, loc))

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [trans-mem] avoid transforming already optimized memory variants
  2009-11-17 15:25 [trans-mem] avoid transforming already optimized memory variants Aldy Hernandez
@ 2009-11-17 16:48 ` Richard Henderson
  2009-11-18 12:53   ` Aldy Hernandez
  0 siblings, 1 reply; 4+ messages in thread
From: Richard Henderson @ 2009-11-17 16:48 UTC (permalink / raw)
  To: Aldy Hernandez; +Cc: gcc-patches

On 11/17/2009 07:22 AM, Aldy Hernandez wrote:
> 	* trans-mem.c (tm_memopt_transform_blocks): Check for simple loads
> 	and stores.
> 	(is_tm_simple_load): New.
> 	(is_tm_simple_store): New.

Ok.

If you're going to do this, are you going to incorporate this knowledge
into the optimization pass?  Or is the fact that we already have an
address instead of a memory too annoying?


r~

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [trans-mem] avoid transforming already optimized memory variants
  2009-11-17 16:48 ` Richard Henderson
@ 2009-11-18 12:53   ` Aldy Hernandez
  2009-11-18 16:24     ` Richard Henderson
  0 siblings, 1 reply; 4+ messages in thread
From: Aldy Hernandez @ 2009-11-18 12:53 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc-patches

> If you're going to do this, are you going to incorporate this knowledge
> into the optimization pass?  Or is the fact that we already have an
> address instead of a memory too annoying?

Do you mean not accumulating any optimized stores/loads variants if
we're not going to (re)optimize them (tm_memopt_accumulate_memops)?

I suppose we should get tm_memopt_accumulate_memops() to use
is_tm_simple* to avoid doing unecessary work.

Perhaps we should avoid global memory optimizations altogether for functions
that have hand-coded RaR, RfW, etc?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [trans-mem] avoid transforming already optimized memory variants
  2009-11-18 12:53   ` Aldy Hernandez
@ 2009-11-18 16:24     ` Richard Henderson
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2009-11-18 16:24 UTC (permalink / raw)
  To: Aldy Hernandez; +Cc: gcc-patches

On 11/18/2009 04:01 AM, Aldy Hernandez wrote:
> Do you mean not accumulating any optimized stores/loads variants if
> we're not going to (re)optimize them (tm_memopt_accumulate_memops)?

No, I mean incorporating the user's RfW (et al) information
into the global dataflow bitmaps.


r~

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-11-18 16:21 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-17 15:25 [trans-mem] avoid transforming already optimized memory variants Aldy Hernandez
2009-11-17 16:48 ` Richard Henderson
2009-11-18 12:53   ` Aldy Hernandez
2009-11-18 16:24     ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).