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 __float128 OpenMP atomics in 32-bit cc1 (PR middle-end/48591)


Hi!

In 32-bit cc1 on i?86-linux the attached testcases ICE, because
built_in_decls[BUILT_IN_VAL_COMPARE_AND_SWAP_16] is NULL.
There is no such integer type, but __float128 has that size.

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

2011-04-13  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/48591
	* omp-low.c (expand_omp_atomic_fetch_op): Return false if decl is
	NULL.
	(expand_omp_atomic_pipeline): Return false if cmpxchg is NULL.

	* gcc.dg/gomp/pr48591.c: New test.

	* testsuite/libgomp.c/pr48591.c: New test.

--- gcc/omp-low.c.jj	2011-01-06 10:03:53.000000000 +0100
+++ gcc/omp-low.c	2011-04-13 14:36:55.000000000 +0200
@@ -5005,6 +5005,8 @@ expand_omp_atomic_fetch_op (basic_block 
     return false;
 
   decl = built_in_decls[base + index + 1];
+  if (decl == NULL_TREE)
+    return false;
   itype = TREE_TYPE (TREE_TYPE (decl));
 
   if (direct_optab_handler (optab, TYPE_MODE (itype)) == CODE_FOR_nothing)
@@ -5056,6 +5058,8 @@ expand_omp_atomic_pipeline (basic_block 
   edge e;
 
   cmpxchg = built_in_decls[BUILT_IN_VAL_COMPARE_AND_SWAP_N + index + 1];
+  if (cmpxchg == NULL_TREE)
+    return false;
   type = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (addr)));
   itype = TREE_TYPE (TREE_TYPE (cmpxchg));
 
--- gcc/testsuite/gcc.dg/gomp/pr48591.c.jj	2011-04-13 14:44:41.000000000 +0200
+++ gcc/testsuite/gcc.dg/gomp/pr48591.c	2011-04-13 14:46:46.000000000 +0200
@@ -0,0 +1,22 @@
+/* PR middle-end/48591 */
+/* { dg-do compile { target i?86-*-* x86_64-*-* ia64-*-* } } */
+/* { dg-options "-fopenmp" } */
+
+extern void abort (void);
+
+int
+main ()
+{
+  __float128 f = 0.0;
+  int i;
+  #pragma omp parallel for reduction(+:f)
+    for (i = 0; i < 128; i++)
+      f += 0.5Q;
+  if (f != 64.0Q)
+    abort ();
+  #pragma omp atomic
+    f += 8.5Q;
+  if (f != 72.5Q)
+    abort ();
+  return 0;
+}
--- libgomp/testsuite/libgomp.c/pr48591.c.jj	2011-04-13 14:51:00.000000000 +0200
+++ libgomp/testsuite/libgomp.c/pr48591.c	2011-04-13 14:51:14.000000000 +0200
@@ -0,0 +1,22 @@
+/* PR middle-end/48591 */
+/* { dg-do run { target i?86-*-linux* x86_64-*-linux* ia64-*-linux* } } */
+/* { dg-options "-fopenmp" } */
+
+extern void abort (void);
+
+int
+main ()
+{
+  __float128 f = 0.0;
+  int i;
+  #pragma omp parallel for reduction(+:f)
+    for (i = 0; i < 128; i++)
+      f += 0.5Q;
+  if (f != 64.0Q)
+    abort ();
+  #pragma omp atomic
+    f += 8.5Q;
+  if (f != 72.5Q)
+    abort ();
+  return 0;
+}

	Jakub


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