Patchwork [committed] Fix __float128 OpenMP atomics in 32-bit cc1 (PR middle-end/48591)

login
register
mail settings
Submitter Jakub Jelinek
Date April 13, 2011, 3:54 p.m.
Message ID <20110413155448.GN17079@tyan-ft48-01.lab.bos.redhat.com>
Download mbox | patch
Permalink /patch/91058/
State New
Headers show

Comments

Jakub Jelinek - April 13, 2011, 3:54 p.m.
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.


	Jakub

Patch

--- 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;
+}