From 9184fb847b4b8bd75bdc2c67c1f64994920132b5 Mon Sep 17 00:00:00 2001 From: Alexander Langer Date: Mon, 2 Nov 1998 00:14:50 +0000 Subject: [PATCH] Optimize bzero() by unrolling the aligned quadword loop and moving the length manipulation away from the length comparison. Measurements on beast.cdrom.com show >3X improvement over the original code on large block sizes, putting the performance on par with the optimized assembly code in libc. --- sys/alpha/alpha/machdep.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sys/alpha/alpha/machdep.c b/sys/alpha/alpha/machdep.c index 93744448e726..d604ad274cea 100644 --- a/sys/alpha/alpha/machdep.c +++ b/sys/alpha/alpha/machdep.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: machdep.c,v 1.18 1998/10/15 22:00:54 dfr Exp $ + * $Id: machdep.c,v 1.19 1998/10/30 05:41:07 msmith Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -1029,10 +1029,22 @@ bzero(void *buf, size_t len) *p++ = 0; len--; } + while (len >= sizeof(u_long) * 8) { + *(u_long*) p = 0; + *((u_long*) p + 1) = 0; + *((u_long*) p + 2) = 0; + *((u_long*) p + 3) = 0; + len -= sizeof(u_long) * 8; + *((u_long*) p + 4) = 0; + *((u_long*) p + 5) = 0; + *((u_long*) p + 6) = 0; + *((u_long*) p + 7) = 0; + p += sizeof(u_long) * 8; + } while (len >= sizeof(u_long)) { *(u_long*) p = 0; - p += sizeof(u_long); len -= sizeof(u_long); + p += sizeof(u_long); } while (len) { *p++ = 0;