ce426f
Consolidated two commits:
ce426f
ce426f
From 51c33bd233d00d77f268ec28565506a6cd1e7d10 Mon Sep 17 00:00:00 2001
ce426f
From: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
ce426f
Date: Mon, 25 Mar 2013 16:10:06 -0500
ce426f
Subject: [PATCH 25/42] PowerPC: modf optimization
ce426f
ce426f
This patch implements modf/modff optimization for POWER by focus
ce426f
on FP operations instead of relying in integer ones.
ce426f
(backported from commit 3c0265394d9ffedff2b0de508602dc52e077ce5c)
ce426f
ce426f
This backport does not include the benchmark tests from the original
ce426f
commit.
ce426f
ce426f
From 599fefcc3e7fbf65d9c441bf1b336b272c39f262 Mon Sep 17 00:00:00 2001
ce426f
From: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
ce426f
Date: Fri, 26 Apr 2013 13:00:56 -0500
ce426f
Subject: [PATCH 26/42] PowerPC: modf optimization fix
ce426f
ce426f
This patch fix the 3c0265394d9ffedff2b0de508602dc52e077ce5c commits
ce426f
by correctly setting minimum architecture for modf PPC optimization
ce426f
to power5+ instead of power5 (since only on power5+ round/ceil will
ce426f
be inline to inline assembly).
ce426f
(cherry picked from commit aa630f590c9c7d070a7cdf3a2a88069ad6b63de9)
ce426f
ce426f
diff -pruN glibc-2.17-c758a686/sysdeps/powerpc/power5+/fpu/s_modf.c glibc-2.17-c758a686/sysdeps/powerpc/power5+/fpu/s_modf.c
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/power5+/fpu/s_modf.c	1970-01-01 05:30:00.000000000 +0530
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/power5+/fpu/s_modf.c	2013-08-06 17:48:57.609526556 +0530
ce426f
@@ -0,0 +1,58 @@
ce426f
+/* Copyright (C) 2013 Free Software Foundation, Inc.
ce426f
+   This file is part of the GNU C Library
ce426f
+
ce426f
+   The GNU C Library is free software; you can redistribute it and/or
ce426f
+   modify it under the terms of the GNU Library General Public License as
ce426f
+   published by the Free Software Foundation; either version 2 of the
ce426f
+   License, or (at your option) any later version.
ce426f
+
ce426f
+   The GNU C Library is distributed in the hope that it will be useful,
ce426f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
ce426f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ce426f
+   Library General Public License for more details.
ce426f
+
ce426f
+   You should have received a copy of the GNU Library General Public
ce426f
+   License along with the GNU C Library; see the file COPYING.LIB.  If
ce426f
+   not, see <http://www.gnu.org/licenses/>.  */
ce426f
+
ce426f
+#include <math.h>
ce426f
+#include <math_private.h>
ce426f
+#include <math_ldbl_opt.h>
ce426f
+
ce426f
+double
ce426f
+__modf (double x, double *iptr)
ce426f
+{
ce426f
+  if (__builtin_isinf (x))
ce426f
+    {
ce426f
+      *iptr = x;
ce426f
+      return __copysign (0.0, x);
ce426f
+    }
ce426f
+  else if (__builtin_isnan (x))
ce426f
+    {
ce426f
+      *iptr = NAN;
ce426f
+      return NAN;
ce426f
+    }
ce426f
+
ce426f
+  if (x >= 0.0)
ce426f
+    {
ce426f
+      *iptr = __floor (x);
ce426f
+      return (x - *iptr);
ce426f
+    }
ce426f
+  else
ce426f
+    {
ce426f
+      *iptr = __ceil (x);
ce426f
+      return (x - *iptr);
ce426f
+    }
ce426f
+}
ce426f
+weak_alias (__modf, modf)
ce426f
+#ifdef NO_LONG_DOUBLE
ce426f
+strong_alias (__modf, __modfl)
ce426f
+weak_alias (__modf, modfl)
ce426f
+#endif
ce426f
+#ifdef IS_IN_libm
ce426f
+# if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)
ce426f
+compat_symbol (libm, __modf, modfl, GLIBC_2_0);
ce426f
+# endif
ce426f
+#elif LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
ce426f
+compat_symbol (libc, __modf, modfl, GLIBC_2_0);
ce426f
+#endif
ce426f
diff -pruN glibc-2.17-c758a686/sysdeps/powerpc/power5+/fpu/s_modff.c glibc-2.17-c758a686/sysdeps/powerpc/power5+/fpu/s_modff.c
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/power5+/fpu/s_modff.c	1970-01-01 05:30:00.000000000 +0530
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/power5+/fpu/s_modff.c	2013-08-06 17:48:57.609526556 +0530
ce426f
@@ -0,0 +1,46 @@
ce426f
+/* Copyright (C) 2013 Free Software Foundation, Inc.
ce426f
+   This file is part of the GNU C Library
ce426f
+
ce426f
+   The GNU C Library is free software; you can redistribute it and/or
ce426f
+   modify it under the terms of the GNU Library General Public License as
ce426f
+   published by the Free Software Foundation; either version 2 of the
ce426f
+   License, or (at your option) any later version.
ce426f
+
ce426f
+   The GNU C Library is distributed in the hope that it will be useful,
ce426f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
ce426f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ce426f
+   Library General Public License for more details.
ce426f
+
ce426f
+   You should have received a copy of the GNU Library General Public
ce426f
+   License along with the GNU C Library; see the file COPYING.LIB.  If
ce426f
+   not, see <http://www.gnu.org/licenses/>.  */
ce426f
+
ce426f
+#include <math.h>
ce426f
+#include <math_private.h>
ce426f
+
ce426f
+float
ce426f
+__modff (float x, float *iptr)
ce426f
+{
ce426f
+  if (__builtin_isinff (x))
ce426f
+    {
ce426f
+      *iptr = x;
ce426f
+      return __copysignf (0.0, x);
ce426f
+    }
ce426f
+  else if (__builtin_isnanf (x))
ce426f
+    {
ce426f
+      *iptr = NAN;
ce426f
+      return NAN;
ce426f
+    }
ce426f
+
ce426f
+  if (x >= 0.0)
ce426f
+    {
ce426f
+      *iptr = __floorf (x);
ce426f
+      return (x - *iptr);
ce426f
+    }
ce426f
+  else
ce426f
+    {
ce426f
+      *iptr = __ceilf (x);
ce426f
+      return (x - *iptr);
ce426f
+    }
ce426f
+}
ce426f
+weak_alias (__modff, modff)
ce426f
diff -pruN glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power5/Implies glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power5/Implies
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power5/Implies	2012-12-25 08:32:13.000000000 +0530
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power5/Implies	2013-08-06 17:48:54.266526703 +0530
ce426f
@@ -1,2 +1,4 @@
ce426f
+powerpc/power5/fpu
ce426f
+powerpc/power5
ce426f
 powerpc/powerpc32/power4/fpu
ce426f
 powerpc/powerpc32/power4
ce426f
diff -pruN glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power5+/Implies glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power5+/Implies
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power5+/Implies	2012-12-25 08:32:13.000000000 +0530
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc32/power5+/Implies	2013-08-06 17:48:57.609526556 +0530
ce426f
@@ -1,2 +1,4 @@
ce426f
+powerpc/power5+/fpu
ce426f
+powerpc/power5+
ce426f
 powerpc/powerpc32/power5/fpu
ce426f
 powerpc/powerpc32/power5
ce426f
diff -pruN glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power5/Implies glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power5/Implies
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power5/Implies	2012-12-25 08:32:13.000000000 +0530
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power5/Implies	2013-08-06 17:48:54.266526703 +0530
ce426f
@@ -1,2 +1,4 @@
ce426f
+powerpc/power5/fpu
ce426f
+powerpc/power5
ce426f
 powerpc/powerpc64/power4/fpu
ce426f
 powerpc/powerpc64/power4
ce426f
diff -pruN glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power5+/Implies glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power5+/Implies
ce426f
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power5+/Implies	2012-12-25 08:32:13.000000000 +0530
ce426f
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/power5+/Implies	2013-08-06 17:48:57.610526556 +0530
ce426f
@@ -1,2 +1,4 @@
ce426f
+powerpc/power5+/fpu
ce426f
+powerpc/power5+
ce426f
 powerpc/powerpc64/power5/fpu
ce426f
 powerpc/powerpc64/power5