This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[committed] Fix #pragma omp target * device (...) expansion (PR middle-end/71758)


Hi!

As the following testcases show, if device clause argument doesn't have int
type (or some compatible one), then we ICE, because we don't emit valid
GIMPLE.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
committed to trunk and 6.2.

2016-07-11  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/71758
	* omp-low.c (expand_omp_target): Gimplify device.

	* c-c++-common/gomp/pr71758.c: New test.
	* gfortran.dg/gomp/pr71758.f90: New test.

--- gcc/omp-low.c.jj	2016-06-24 20:43:35.000000000 +0200
+++ gcc/omp-low.c	2016-07-11 17:27:16.006701262 +0200
@@ -13350,9 +13350,15 @@ expand_omp_target (struct omp_region *re
       make_edge (else_bb, new_bb, EDGE_FALLTHRU);
 
       device = tmp_var;
+      gsi = gsi_last_bb (new_bb);
+    }
+  else
+    {
+      gsi = gsi_last_bb (new_bb);
+      device = force_gimple_operand_gsi (&gsi, device, true, NULL_TREE,
+					 true, GSI_SAME_STMT);
     }
 
-  gsi = gsi_last_bb (new_bb);
   t = gimple_omp_target_data_arg (entry_stmt);
   if (t == NULL)
     {
--- gcc/testsuite/c-c++-common/gomp/pr71758.c.jj	2016-07-11 17:08:50.400590537 +0200
+++ gcc/testsuite/c-c++-common/gomp/pr71758.c	2016-07-11 17:27:47.000000000 +0200
@@ -0,0 +1,10 @@
+/* PR middle-end/71758 */
+
+void
+foo (int *p)
+{
+  long long i = 0;
+  #pragma omp target device (i)
+  ;
+  #pragma omp target update device (i) to (p[0])
+}
--- gcc/testsuite/gfortran.dg/gomp/pr71758.f90.jj	2016-07-11 17:09:25.347183941 +0200
+++ gcc/testsuite/gfortran.dg/gomp/pr71758.f90	2016-07-11 17:30:56.617127114 +0200
@@ -0,0 +1,10 @@
+! PR middle-end/71758
+
+subroutine pr71758 (p)
+  integer(8) :: i
+  integer :: p(20)
+  i = 0
+  !$omp target device(i)
+  !$omp end target
+  !$omp target update to(p(1:1)) device(i)
+end subroutine

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]