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 ICE on OpenMP reduction with _Complex int var (PR middle-end/42029)


Hi!

It is unclear whether we should allow this or not (the standard talks about
scalars in C/C++ reduction description), but as we don't reject it ATM, we
shouldn't ICE on it.

Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk,
will commit to 4.4 momentarily.

2009-11-13  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/42029
	* gimplify.c (gimplify_omp_atomic): Set DECL_GIMPLE_REG_P on
	tmp_load if needed.

	* libgomp.c/pr42029.c: New test.

--- gcc/gimplify.c.jj	2009-11-09 13:30:01.000000000 +0100
+++ gcc/gimplify.c	2009-11-13 15:39:45.000000000 +0100
@@ -6231,6 +6231,8 @@ gimplify_omp_atomic (tree *expr_p, gimpl
   tree tmp_load;
 
    tmp_load = create_tmp_var (type, NULL);
+   if (TREE_CODE (type) == COMPLEX_TYPE || TREE_CODE (type) == VECTOR_TYPE)
+     DECL_GIMPLE_REG_P (tmp_load) = 1;
    if (goa_stabilize_expr (&rhs, pre_p, addr, tmp_load) < 0)
      return GS_ERROR;
 
--- libgomp/testsuite/libgomp.c/pr42029.c.jj	2009-11-13 15:51:37.000000000 +0100
+++ libgomp/testsuite/libgomp.c/pr42029.c	2009-11-13 15:51:12.000000000 +0100
@@ -0,0 +1,19 @@
+/* PR middle-end/42029 */
+/* { dg-do run } */
+
+extern void abort (void);
+
+int
+main ()
+{
+  int i;
+  _Complex int c = 0;
+
+#pragma omp parallel for private(i) reduction(+:c)
+  for (i = 0; i < 8; ++i)
+    c += 1;
+
+  if (c != 8)
+    abort ();
+  return 0;
+}

	Jakub


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