diff options
author | Jakub Jelinek <jakub@gcc.gnu.org> | 2008-05-07 09:28:14 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2008-05-07 09:28:14 +0200 |
commit | c18c98c0ade56bc46ce65bbf5cdff26a2577c990 (patch) | |
tree | 8a49369b064d64c16fa89af2d0a836f7966d2e98 /libgomp | |
parent | 537d4fa684f272ea72c1c8db58e4f1dcd3b7cda4 (diff) | |
download | gcc-c18c98c0ade56bc46ce65bbf5cdff26a2577c990.zip gcc-c18c98c0ade56bc46ce65bbf5cdff26a2577c990.tar.gz gcc-c18c98c0ade56bc46ce65bbf5cdff26a2577c990.tar.bz2 |
re PR middle-end/36106 (#pragma omp atomic issues with floating point types)
PR middle-end/36106
* omp-low.c (expand_omp_atomic_pipeline): Load value using the
integral type rather than floating point, then VIEW_CONVERT_EXPR
to the floating point type.
* testsuite/libgomp.c/atomic-5.c: New test.
* testsuite/libgomp.c/atomic-6.c: New test.
* testsuite/libgomp.c/autopar-1.c: New test.
From-SVN: r135027
Diffstat (limited to 'libgomp')
-rw-r--r-- | libgomp/ChangeLog | 7 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.c/atomic-5.c | 40 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.c/atomic-6.c | 36 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.c/autopar-1.c | 44 |
4 files changed, 127 insertions, 0 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 7ad1189..3e98750 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,10 @@ +2008-05-07 Jakub Jelinek <jakub@redhat.com> + + PR middle-end/36106 + * testsuite/libgomp.c/atomic-5.c: New test. + * testsuite/libgomp.c/atomic-6.c: New test. + * testsuite/libgomp.c/autopar-1.c: New test. + 2008-04-21 Ralf Wildenhues <Ralf.Wildenhues@gmx.de> * acinclude.m4 (LIBGOMP_CHECK_SYNC_BUILTINS) diff --git a/libgomp/testsuite/libgomp.c/atomic-5.c b/libgomp/testsuite/libgomp.c/atomic-5.c new file mode 100644 index 0000000..3b4b0f1 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/atomic-5.c @@ -0,0 +1,40 @@ +/* PR middle-end/36106 */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -mcx16" { target { { i?86-*-* x86_64-*-* } && lp64 } } } */ + +#ifdef __x86_64__ +# include "../../../gcc/config/i386/cpuid.h" +#endif + +extern void abort (void); + +int __attribute__((noinline)) +do_test (void) +{ + long double d = .0L; + int i; + #pragma omp parallel for shared (d) + for (i = 0; i < 10; i++) + #pragma omp atomic + d += 1.0L; + if (d != 10.0L) + abort (); + return 0; +} + +int +main (void) +{ +#ifdef __x86_64__ + unsigned int eax, ebx, ecx, edx; + + if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) + return 0; + + if (ecx & bit_CMPXCHG16B) + do_test (); +#else + do_test (); +#endif + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/atomic-6.c b/libgomp/testsuite/libgomp.c/atomic-6.c new file mode 100644 index 0000000..949fc3d --- /dev/null +++ b/libgomp/testsuite/libgomp.c/atomic-6.c @@ -0,0 +1,36 @@ +/* PR middle-end/36106 */ +/* { dg-options "-O2" } */ +/* { dg-options "-O2 -march=i586" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ + +#ifdef __i386__ +# include "../../../gcc/config/i386/cpuid.h" +#endif + +extern void abort (void); + +union { unsigned long long l; double d; } u = { .l = 0x7ff0000000072301ULL }; + +int __attribute__((noinline)) +do_test (void) +{ +#pragma omp atomic + u.d += 1.0L; + return 0; +} + +int +main (void) +{ +#ifdef __i386__ + unsigned int eax, ebx, ecx, edx; + + if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx)) + return 0; + + if (edx & bit_CMPXCHG8B) + do_test (); +#else + do_test (); +#endif + return 0; +} diff --git a/libgomp/testsuite/libgomp.c/autopar-1.c b/libgomp/testsuite/libgomp.c/autopar-1.c new file mode 100644 index 0000000..e56549b --- /dev/null +++ b/libgomp/testsuite/libgomp.c/autopar-1.c @@ -0,0 +1,44 @@ +/* { dg-do run } */ +/* { dg-options "-ftree-parallelize-loops=4 -O2 -ffast-math" } */ + +extern void abort (void); + +double d[1024], e[1024]; +int f[1024], g[1024]; + +double __attribute__((noinline)) +foo (void) +{ + double s = 0.0; + int i; + for (i = 0; i < 1024; i++) + s += d[i] - e[i]; + return s; +} + +int __attribute__((noinline)) +bar (void) +{ + int s = 0, i; + for (i = 0; i < 1024; i++) + s += f[i] - g[i]; + return s; +} + +int +main (void) +{ + int i; + for (i = 0; i < 1024; i++) + { + d[i] = i * 2; + e[i] = i; + f[i] = i * 2; + g[i] = i; + } + if (foo () != 1023 * 1024 / 2) + abort (); + if (bar () != 1023 * 1024 / 2) + abort (); + return 0; +} |