1 /* Optimized version of the standard memset() function.
2 This file is part of the GNU C Library.
3 Copyright (C) 2000, 2001 Free Software Foundation, Inc.
4 Contributed by Dan Pop <Dan.Pop@cern.ch>.
6 The GNU C Library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
11 The GNU C Library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
28 The algorithm is fairly straightforward: set byte by byte until we
29 we get to a word aligned address, then set word by word as much as
30 possible; the remaining few bytes are set one by one. */
49 alloc save_pfs = ar.pfs, 3, 7, 0, 0
55 cmp.eq p6, p0 = cnt, r0
56 (p6) br.cond.spnt .restore_and_exit ;;
59 cmp.gt p6, p0 = 16, cnt
60 (p6) br.cond.spnt .set_few;;
61 cmp.eq p6, p0 = tmp, r0
62 (p6) br.cond.sptk .dest_aligned
63 sub cnt = cnt, loopcnt
64 adds loopcnt = -1, loopcnt;;
67 st1 [ptr1] = byteval, 1
71 mux1 wordval = byteval, @brcst
72 shr.u loopcnt = cnt, 4 ;; // loopcnt = cnt / 16
73 cmp.eq p6, p0 = loopcnt, r0
74 (p6) br.cond.spnt .one_more
75 and cnt = 0xf, cnt // compute the remaining cnt
76 adds loopcnt = -1, loopcnt;;
79 st8 [ptr1] = wordval, 16
80 st8 [ptr2] = wordval, 16
82 cmp.le p6, p0 = 8, cnt ;;
84 (p6) st8 [ptr1] = wordval, 8
85 (p6) adds cnt = -8, cnt ;;
86 cmp.eq p6, p0 = cnt, r0
87 (p6) br.cond.spnt .restore_and_exit
89 adds loopcnt = -1, cnt;;
92 st1 [ptr1] = byteval, 1