diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-05-07 07:28:14 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-05-07 07:28:14 +0000 |
commit | 790368c5a04247b0ce30c17a79c1c2215f8e16de (patch) | |
tree | 8a49369b064d64c16fa89af2d0a836f7966d2e98 /libgomp/testsuite | |
parent | c08d707de91dbeead6851997fd809d70b4715b06 (diff) | |
download | ppe42-gcc-790368c5a04247b0ce30c17a79c1c2215f8e16de.tar.gz ppe42-gcc-790368c5a04247b0ce30c17a79c1c2215f8e16de.zip |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@135027 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgomp/testsuite')
-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 |
3 files changed, 120 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.c/atomic-5.c b/libgomp/testsuite/libgomp.c/atomic-5.c new file mode 100644 index 00000000000..3b4b0f11d64 --- /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 00000000000..949fc3d73da --- /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 00000000000..e56549b4845 --- /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; +} |