From 659755560b00f21ab38cae853cf9a11e534b4799 Mon Sep 17 00:00:00 2001 From: Marc Glisse Date: Thu, 27 Dec 2018 19:29:23 +0100 Subject: [PATCH] SSE for Interval / double --- Number_types/include/CGAL/Interval_nt.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Number_types/include/CGAL/Interval_nt.h b/Number_types/include/CGAL/Interval_nt.h index 6dadbf107ee..8ef0275fb80 100644 --- a/Number_types/include/CGAL/Interval_nt.h +++ b/Number_types/include/CGAL/Interval_nt.h @@ -924,9 +924,21 @@ operator/ (double a, const Interval_nt & b) template inline Interval_nt -operator/ (const Interval_nt & a, double b) +operator/ (Interval_nt a, double b) { - return a/Interval_nt(b); + if(b<0){ a = -a; b = -b; } + else if(b==0) return Interval_nt::largest(); + // Now b > 0 + typename Interval_nt::Internal_protector P; +#ifdef __GNUC__ + // Paradoxically, constants should be safe, and this lets the compiler optimize x/2 to x*.5 + if (!__builtin_constant_p(b)) +#endif + b = IA_opacify(b); + __m128d bb = _mm_set1_pd(b); + __m128d aa = IA_opacify128(a.simd()); + __m128d r = _mm_div_pd(aa, bb); + return Interval_nt(IA_opacify128(r)); } // TODO: What about these two guys? Where do they belong to?