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 3 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. If not, see http://www.gnu.org/licenses/.
20 include(`../config.m4')
31 C void mpn_divexact_by3 (mp_ptr dst, mp_srcptr src, mp_size_t size);
33 C We avoid the slow subfe instruction and instead rely on an extremely unlikely
36 C The mullw has the inverse in the first operand, since 0xAA..AB won't allow
37 C any early-out. The src[] data normally won't either, but there's at least
38 C a chance, whereas 0xAA..AB never will. If, for instance, src[] is all
39 C zeros (not a sensible input of course) we run at 7.0 c/l on ppc750.
41 C The mulhwu has the "3" multiplier in the second operand, which lets 750 and
42 C 7400 use an early-out.
51 PROLOGUE(mpn_divexact_by3c)
65 L(top): lwzu r9, 4(up)
67 bgt- cr7, L(adj) C very unlikely branch
68 L(bko): cmplw cr7, r7, r9
74 L(one): mulhwu r3, r0, r10
79 L(adj): addi r7, r7, 1