public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [gomp4] oacc xform tweak
@ 2015-08-18 17:57 Nathan Sidwell
  0 siblings, 0 replies; only message in thread
From: Nathan Sidwell @ 2015-08-18 17:57 UTC (permalink / raw)
  To: GCC Patches; +Cc: Cesar Philippidis

[-- Attachment #1: Type: text/plain, Size: 478 bytes --]

I've committed this to gomp4 branch.  It changes the oacc_xform_on_device and 
oacc_xform_dim_pos calls to lose the GSI parameter.  Thus they look similar to 
the interface we're implementing for the reduction transformations.  The 
iterator in the caller is advanced before the call, so it isn't left holding  a 
potentially deleted instruction.

I noticed a  missing break which would have caused us to fall into the fork/join 
handling from the lock/unlock handling.

nathan

[-- Attachment #2: gomp4-oacc-xform-dim.patch --]
[-- Type: text/x-patch, Size: 2920 bytes --]

2015-08-18  Nathan Sidwell  <nathan@codesourcery.com>

	* omp-low.c (oacc_xform_on_device): Lose GSI parameter & adjust.
	(oacc_xform_dim): Likewise.
	(execute_oacc_transform): Adjust calls to oacc_xform_on_device and
	oacc_xform_dim.  Insert breaks.

Index: omp-low.c
===================================================================
--- omp-low.c	(revision 226978)
+++ omp-low.c	(working copy)
@@ -14599,7 +14601,7 @@ make_pass_late_lower_omp (gcc::context *
    offloaded function we're never 'none'.  */
 
 static void
-oacc_xform_on_device (gimple_stmt_iterator *gsi, gimple stmt)
+oacc_xform_on_device (gimple stmt)
 {
   tree arg = gimple_call_arg (stmt, 0);
   unsigned val = GOMP_DEVICE_HOST;
@@ -14624,15 +14626,16 @@ oacc_xform_on_device (gimple_stmt_iterat
   push_gimplify_context (true);
   gimplify_assign (lhs, result, &replace);
   pop_gimplify_context (NULL);
-  gsi_replace_with_seq (gsi, replace, false);
+
+  gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
+  gsi_replace (&gsi, replace, false);
 }
 
 /* Transform oacc_dim_size and oacc_dim_pos internal function calls to
    constants, where possible.  */
 
 static void
-oacc_xform_dim (gimple_stmt_iterator *gsi, gimple stmt,
-		const int dims[], bool is_pos)
+oacc_xform_dim (gimple stmt, const int dims[], bool is_pos)
 {
   tree arg = gimple_call_arg (stmt, 0);
   unsigned axis = (unsigned)TREE_INT_CST_LOW (arg);
@@ -14654,7 +14657,9 @@ oacc_xform_dim (gimple_stmt_iterator *gs
   tree lhs = gimple_call_lhs (stmt);
   gimple g = gimple_build_assign
     (lhs, build_int_cst (integer_type_node, size));
-  gsi_replace (gsi, g, false);
+
+  gimple_stmt_iterator gsi = gsi_for_stmt (stmt);
+  gsi_replace (&gsi, g, false);
 }
 
 /* Main entry point for oacc transformations which run on the device
@@ -14733,7 +14738,11 @@ execute_oacc_transform ()
 	else if (gimple_call_builtin_p (stmt, BUILT_IN_ACC_ON_DEVICE))
 	  /* acc_on_device must be evaluated at compile time for
 	     constant arguments.  */
-	  oacc_xform_on_device (&gsi, stmt);
+	  {
+	    gsi_next (&gsi);
+	    oacc_xform_on_device (stmt);
+	    continue;
+	  }
 	else if (gimple_call_internal_p (stmt))
 	  {
 	    unsigned ifn_code = gimple_call_internal_fn (stmt);
@@ -14743,15 +14752,16 @@ execute_oacc_transform ()
 
 	      case IFN_GOACC_DIM_POS:
 	      case IFN_GOACC_DIM_SIZE:
-		oacc_xform_dim (&gsi, stmt, dims,
-				ifn_code == IFN_GOACC_DIM_POS);
-		break;
+		gsi_next (&gsi);
+		oacc_xform_dim (stmt, dims, ifn_code == IFN_GOACC_DIM_POS);
+		continue;
 
 	      case IFN_GOACC_LOCK:
 	      case IFN_GOACC_UNLOCK:
 		if (targetm.goacc.lock_unlock
 		    (stmt, dims, ifn_code == IFN_GOACC_LOCK))
 		  goto remove;
+		break;
 
 	      case IFN_GOACC_FORK:
 	      case IFN_GOACC_JOIN:
@@ -14765,6 +14775,7 @@ execute_oacc_transform ()
 		    /* Removal will have advanced the iterator.  */
 		    continue;
 		  }
+		break;
 	      }
 	  }
 	gsi_next (&gsi);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2015-08-18 17:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-18 17:57 [gomp4] oacc xform tweak Nathan Sidwell

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).