1
dnl PowerPC-32 mpn_divexact_by3 -- mpn by 3 exact division
3
dnl Copyright 2002, 2003, 2005, 2006 Free Software Foundation, Inc.
5
dnl This file is part of the GNU MP Library.
7
dnl The GNU MP Library is free software; you can redistribute it and/or
8
dnl modify it under the terms of the GNU Lesser General Public License as
9
dnl published by the Free Software Foundation; either version 2.1 of the
10
dnl License, or (at your option) any later version.
12
dnl The GNU MP Library is distributed in the hope that it will be useful,
13
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
14
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
dnl Lesser General Public License for more details.
17
dnl You should have received a copy of the GNU Lesser General Public License
18
dnl along with the GNU MP Library; see the file COPYING.LIB. If not, write
19
dnl the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20
dnl Boston, MA 02110-1301, USA.
22
include(`../config.m4')
33
C void mpn_divexact_by3 (mp_ptr dst, mp_srcptr src, mp_size_t size);
35
C We avoid the slow subfe instruction and instead rely on an extremely unlikely
38
C The mullw has the inverse in the first operand, since 0xAA..AB won't allow
39
C any early-out. The src[] data normally won't either, but there's at least
40
C a chance, whereas 0xAA..AB never will. If, for instance, src[] is all
41
C zeros (not a sensible input of course) we run at 7.0 c/l on ppc750.
43
C The mulhwu has the "3" multiplier in the second operand, which lets 750 and
44
C 7400 use an early-out.
53
PROLOGUE(mpn_divexact_by3c)
67
L(top): lwzu r9, 4(up)
69
bgt- cr7, L(adj) C very unlikely branch
70
L(bko): cmplw cr7, r7, r9
76
L(one): mulhwu r3, r0, r10
81
L(adj): addi r7, r7, 1