From 89853488275b118f6f2ba7724eec30f4d37d67b9 Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Fri, 30 Oct 2015 10:53:52 -0400 Subject: Improve optimization barriers --- floatprops.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'floatprops.h') diff --git a/floatprops.h b/floatprops.h index c7a3b7f..e284c5f 100644 --- a/floatprops.h +++ b/floatprops.h @@ -283,6 +283,30 @@ V &set_elt(V &v, const int n, const E e) { return v; } +template real_t barrier(real_t x) { +#if defined __GNUC__ && !defined __clang__ && !defined __ICC +// GCC crashes when +X is used as constraint +#if defined __SSE2__ + __asm__("" : "+x"(x)); +#elif defined __PPC64__ // maybe also __PPC__ + __asm__("" : "+f"(x)); +#elif defined __arm__ + __asm__("" : "+w"(x)); +#else +#error "Floating point barrier undefined on this architecture" +#endif +#elif defined __clang__ + __asm__("" : "+x"(x)); +#elif defined __ICC + __asm__("" : "+x"(x)); +#elif defined __IBMCPP__ + __asm__("" : "+f"(x)); +#else +#error "Floating point barrier undefined on this architecture" +#endif + return x; +} + } // namespace vecmathlib #endif // #ifndef FLOATPROPS_H -- cgit v1.1