From: Igor Zamyatin Date: Mon, 9 Nov 2015 10:12:34 +0000 (+0000) Subject: re PR target/66326 (Floating point exception with -mfpmath=387 and -fcilkplus.) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a42062b176417a41d33e72710a80a3be707845ba;p=gcc.git re PR target/66326 (Floating point exception with -mfpmath=387 and -fcilkplus.) libcilkrts/ 2015-11-09 Igor Zamyatin PR target/66326 * runtime/config/x86/os-unix-sysdep.c (sysdep_save_fp_ctrl_state): Use fnstcw instead fnstsw. gcc/testsuite 2015-11-09 Igor Zamyatin PR target/66326 * g++.dg/cilk-plus/CK/pr66326.cc: New test. From-SVN: r230008 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c6fe2972e2d..bcca4791eeb 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2015-11-09 Igor Zamyatin + + PR target/66326 + * g++.dg/cilk-plus/CK/pr66326.cc: New test. + 2015-11-09 Richard Henderson * gcc.target/i386/addr-space-1.c: New test. diff --git a/gcc/testsuite/g++.dg/cilk-plus/CK/pr66326.cc b/gcc/testsuite/g++.dg/cilk-plus/CK/pr66326.cc new file mode 100644 index 00000000000..1114ebdda82 --- /dev/null +++ b/gcc/testsuite/g++.dg/cilk-plus/CK/pr66326.cc @@ -0,0 +1,33 @@ +/* { dg-options "-fcilkplus" } */ +/* { dg-do run { target i?86-*-* x86_64-*-* } } */ +/* { dg-options "-fcilkplus -lcilkrts" { target { i?86-*-* x86_64-*-* } } } */ + +#include +#include +#include + +template +void do_not_optimize_away(T&& x) { + asm volatile("" : "+r"(x)); +} + +const int N = 1'000'000; + +auto compute() { + std::vector v(N); + auto rng = std::mt19937{std::random_device{}()}; + std::uniform_real_distribution dist(0, 1); + for (int i = 0; i < N; ++i) v[i] = std::log(std::sqrt(dist(rng))); + return v; +} + +int main() { + std::vector v1, v2, v3; + cilk_spawn [&] { v1 = compute(); }(); + cilk_spawn [&] { v2 = compute(); }(); + v3 = compute(); + do_not_optimize_away(v1.data()); + do_not_optimize_away(v2.data()); + do_not_optimize_away(v3.data()); + return 0; +} diff --git a/libcilkrts/ChangeLog b/libcilkrts/ChangeLog index 903f7a5a618..ed26a3a1e1b 100644 --- a/libcilkrts/ChangeLog +++ b/libcilkrts/ChangeLog @@ -1,3 +1,9 @@ +2015-11-09 Igor Zamyatin + + PR target/66326 + * runtime/config/x86/os-unix-sysdep.c (sysdep_save_fp_ctrl_state): + Use fnstcw instead fnstsw. + 2015-05-13 Michael Haubenwallner * Makefile.in: Regenerated with automake-1.11.6. diff --git a/libcilkrts/runtime/config/x86/os-unix-sysdep.c b/libcilkrts/runtime/config/x86/os-unix-sysdep.c index b505ddfb96f..cbc77343215 100644 --- a/libcilkrts/runtime/config/x86/os-unix-sysdep.c +++ b/libcilkrts/runtime/config/x86/os-unix-sysdep.c @@ -135,7 +135,7 @@ void sysdep_save_fp_ctrl_state(__cilkrts_stack_frame *sf) { __asm__ ("stmxcsr %0" : "=m" (sf->mxcsr)); } - __asm__ ("fnstsw %0" : "=m" (sf->fpcsr)); + __asm__ ("fnstcw %0" : "=m" (sf->fpcsr)); } #endif }