public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch, openacc] Fix ICE verifying gimple
@ 2019-11-22 11:18 Andrew Stubbs
  2020-01-16 14:44 ` Andrew Stubbs
  2020-01-29 12:42 ` [PR93488] [OpenACC] ICE in type-cast 'async', 'wait' clauses (was: [patch, openacc] Fix ICE verifying gimple) Thomas Schwinge
  0 siblings, 2 replies; 7+ messages in thread
From: Andrew Stubbs @ 2019-11-22 11:18 UTC (permalink / raw)
  To: gcc-patches

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

This test case causes an ICE (reformatted for email):

   void test(int k)
   {
     unsigned int x = 1;
   #pragma acc parallel loop async(x)
     for (int i = 0; i < k; i++) { }
   }

   t.c: In function 'test':
   t.c:4:9: error: invalid argument to gimple call
       4 | #pragma acc parallel loop async(x)
         |         ^~~
   (int) x
   __builtin_GOACC_parallel_keyed (-1, test._omp_fn.0, 1,
                                   &.omp_data_arr.3, &.omp_data_sizes.4,
                                   &.omp_data_kinds.5, 536936447,
                                  (int) x, 0);
   during GIMPLE pass: ompexp
   dump file: t.c.013t.ompexp
   t.c:4:9: internal compiler error: verify_gimple failed

The problem is that "x" needs to be cast to "int" (from "unsigned int") 
before calling the function, and that's not valid in a gimple call.

The attached patch assigns the "(int) x" to a temporary and passes that 
to the function instead.

OK to commit?

-- 
Andrew Stubbs
CodeSourcery / Mentor Graphics

[-- Attachment #2: 191122-fix-goacc-parallel-keyed.patch --]
[-- Type: text/x-patch, Size: 779 bytes --]

Normalize GOACC_parallel_keyed async parameter.

2019-11-22  Andrew Stubbs  <ams@codesourcery.com>

	gcc/
	* omp-expand.c (expand_omp_target): Pass sync parameter to
	GOACC_parallel_keyed via a temporary variable.

diff --git a/gcc/omp-expand.c b/gcc/omp-expand.c
index 6f945011cf5..08f95587e95 100644
--- a/gcc/omp-expand.c
+++ b/gcc/omp-expand.c
@@ -8418,7 +8418,12 @@ expand_omp_target (struct omp_region *region)
 					      i_async));
 	  }
 	if (t_async)
-	  args.safe_push (t_async);
+	  {
+	    tree tmp = create_tmp_var (TREE_TYPE (t_async));
+	    gimple *stmt = gimple_build_assign (tmp, t_async);
+	    gsi_insert_before (&gsi, stmt, GSI_SAME_STMT);
+	    args.safe_push (tmp);
+	  }
 
 	/* Save the argument index, and ... */
 	unsigned t_wait_idx = args.length ();

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

end of thread, other threads:[~2020-04-23 15:02 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-22 11:18 [patch, openacc] Fix ICE verifying gimple Andrew Stubbs
2020-01-16 14:44 ` Andrew Stubbs
2020-01-29 12:42 ` [PR93488] [OpenACC] ICE in type-cast 'async', 'wait' clauses (was: [patch, openacc] Fix ICE verifying gimple) Thomas Schwinge
2020-01-29 13:32   ` [PR93488] [OpenACC] ICE in type-cast 'async', 'wait' clauses Andrew Stubbs
2020-01-31  0:05   ` Andrew Stubbs
2020-04-21  9:54     ` Thomas Schwinge
2020-04-23 15:02       ` Andrew Stubbs

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