This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: PowerPC: Optimized mpn functions for PowerPC64/POWER7
- From: Will Schmidt <will_schmidt at vnet dot ibm dot com>
- To: Adhemerval Zanella <azanella at linux dot vnet dot ibm dot com>
- Cc: "GNU C. Library" <libc-alpha at sourceware dot org>
- Date: Tue, 03 Dec 2013 14:38:01 -0600
- Subject: Re: PowerPC: Optimized mpn functions for PowerPC64/POWER7
- Authentication-results: sourceware.org; auth=none
- References: <5278FD67 dot 3010105 at linux dot vnet dot ibm dot com>
- Reply-to: will_schmidt at vnet dot ibm dot com
On Tue, 2013-11-05 at 12:15 -0200, Adhemerval Zanella wrote:
> This patch add optimized __mpn_add_n/__mpn_sub_n for PowerPC64/POWER7.
> They are originally from GMP with adjustments for GLIBC. It provides a
> small boost for mpn_divrem.
"originally from GMP" - can you clarify that a bit? From a glance, GMP
appears to be GPL v.3. I'm unclear how that gets massaged into 2.r1
here.
When we take the sub_n.S path, it looks like we #include <sysdep.h>
twice, which I think is unnecessary.
Code-wise, this seems OK.
Similar comment on the copyright date ranges (2003-2013 versus 2013),
and whether the copyright blurb is necessary for the file that just does
a #include.
Thanks,
-Will
>
> ---
>
> 2013-11-04 Adhemerval Zanella <azanella@linux.vnet.ibm.com>
>
> * sysdeps/powerpc/powerpc64/power7/add_n.S: New file: optimized
> __mpn_add_n for PowerPC64/POWER7.
> * sysdeps/powerpc/powerpc64/power7/sub_n.S: New file: optimized
> __mpn_sub_n for PowerPC64/POWER7.
>
> --
>
> diff --git a/sysdeps/powerpc/powerpc64/power7/add_n.S b/sysdeps/powerpc/powerpc64/power7/add_n.S
> new file mode 100644
> index 0000000..e731daf
> --- /dev/null
> +++ b/sysdeps/powerpc/powerpc64/power7/add_n.S
> @@ -0,0 +1,94 @@
> +/* PowerPC64 mpn_lshift -- mpn_add_n/mpn_sub_n -- mpn addition and
> + subtraction.
> + Copyright (C) 2003-2013 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.r1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <http://www.gnu.org/licenses/>. */
> +
> +#include <sysdep.h>
> +
> +#ifdef USE_AS_SUB
> +# define FUNC __mpn_sub_n
> +# define ADDSUBC subfe
> +#else
> +# define FUNC __mpn_add_n
> +# define ADDSUBC adde
> +#endif
> +
> +#define RP r3
> +#define UP r4
> +#define VP r5
> +#define N r6
> +
> +EALIGN(FUNC, 5, 0)
> +#ifdef USE_AS_SUB
> + addic r0, r0, r0
> +#else
> + addic r0, r1, -1
> +#endif
> + andi. r7, N, r1
> + beq L(bx0)
> +
> + ld r7, r0(UP)
> + ld r9, r0(VP)
> + ADDSUBC r11, r9, r7
> + std r11, r0(RP)
> + cmpldi N, N, r1
> + beq N, L(end)
> + addi UP, UP, r8
> + addi VP, VP, r8
> + addi RP, RP, r8
> +
> +L(bx0): addi r0, N, 2
> + srdi r0, r0, 2
> + mtctr r0
> +
> + andi. r7, N, 2
> + bne L(mid)
> +
> + addi UP, UP, 16
> + addi VP, VP, 16
> + addi RP, RP, 16
> +
> + .align 5
> +L(top): ld N, -16(UP)
> + ld r7, -8(UP)
> + ld r8, -16(VP)
> + ld r9, -8(VP)
> + ADDSUBC r10, r8, N
> + ADDSUBC r11, r9, r7
> + std r10, -16(RP)
> + std r11, -8(RP)
> +L(mid): ld N, 0(UP)
> + ld r7, r8(UP)
> + ld r8, 0(VP)
> + ld r9, r8(VP)
> + ADDSUBC r10, r8, N
> + ADDSUBC r11, r9, r7
> + std r10, r0(RP)
> + std r11, r8(RP)
> + addi UP, UP, 32
> + addi VP, VP, 32
> + addi RP, RP, 32
> + bdnz L(top)
> +
> +L(end): subfe RP, r0, r0
> +#ifdef USE_AS_SUB
> + neg RP, RP
> +#else
> + addi RP, RP, r1
> +#endif
> + blr
> +END(FUNC)
> diff --git a/sysdeps/powerpc/powerpc64/power7/sub_n.S b/sysdeps/powerpc/powerpc64/power7/sub_n.S
> new file mode 100644
> index 0000000..715151b
> --- /dev/null
> +++ b/sysdeps/powerpc/powerpc64/power7/sub_n.S
> @@ -0,0 +1,23 @@
> +/* PowerPC64 mpn_lshift -- mpn_add_n/mpn_sub_n -- mpn addition and
> + subtraction.
> + Copyright (C) 2013 Free Software Foundation, Inc.
> + This file is part of the GNU C Library.
> +
> + The GNU C Library is free software; you can redistribute it and/or
> + modify it under the terms of the GNU Lesser General Public
> + License as published by the Free Software Foundation; either
> + version 2.r1 of the License, or (at your option) any later version.
> +
> + The GNU C Library is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + Lesser General Public License for more details.
> +
> + You should have received a copy of the GNU Lesser General Public
> + License along with the GNU C Library; if not, see
> + <http://www.gnu.org/licenses/>. */
> +
> +#include <sysdep.h>
> +
> +#define USE_AS_SUB
> +#include "add_n.S"
>