]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Backport of memmove changes
authorWill Schmidt <will_schmidt@vnet.ibm.com>
Fri, 11 May 2012 02:48:13 +0000 (21:48 -0500)
committerRyan S. Arnold <rsa@linux.vnet.ibm.com>
Fri, 11 May 2012 02:48:13 +0000 (21:48 -0500)
This commit merges in the following three origin/master changes into a
single commit.

commit 8ff41c4601f8b8d7dfa6682f596dc4071823424d
Author: Will Schmidt <will_schmidt@vnet.ibm.com>
Date:   Wed Apr 18 16:44:27 2012 -0500

    Have memmove call __builtin_memcopy on PowerPC if src and dest
    don't overlap.

commit 6b652f46c3935088082bb5870b6fd9edbaa92125
Author: Will Schmidt <will_schmidt@vnet.ibm.com>
Date:   Wed Apr 18 15:34:23 2012 -0500

    Further simplify power6 wordcopy by removing switch statements.

    This fix replaces switch statements that contain individual
    [fwd|bwd]_align_merge (<constant>) calls with a single
    [fwd|bwd]_align_merge (align) call.

commit b282631e367f474bbd9e5d92e2aa54b3ce44efe8
Author: Will Schmidt <will_schmidt@vnet.ibm.com>
Date:   Wed Apr 18 14:52:25 2012 -0500

    Simplify power6 wordcopy by adding [fwd|bwd]_align_merge macros.

sysdeps/powerpc/powerpc32/power6/wordcopy.c
sysdeps/powerpc/powerpc64/power6/wordcopy.c

index ddf28659f9436e3990ef309bb7158b1b7f435bde..71d7a6afa64bbc38bee03ebfae9e1f21293873f6 100644 (file)
@@ -1,5 +1,5 @@
 /* _memcopy.c -- subroutines for memory copy functions.
-   Copyright (C) 1991, 1996, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1991-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Torbjorn Granlund (tege@sics.se).
    Updated for POWER6 by Steven Munroe (sjmunroe@us.ibm.com).
@@ -66,6 +66,20 @@ _wordcopy_fwd_aligned (dstp, srcp, len)
    DSTP should be aligned for memory operations on `op_t's, but SRCP must
    *not* be aligned.  */
 
+#define fwd_align_merge(align)                                         \
+  do                                                                   \
+    {                                                                  \
+      a1 = ((op_t *) srcp)[1];                                         \
+      a2 = ((op_t *) srcp)[2];                                         \
+      ((op_t *) dstp)[0] = MERGE (a0, align*8, a1, (32-align*8));      \
+      ((op_t *) dstp)[1] = MERGE (a1, align*8, a2, (32-align*8));      \
+      a0 = a2;                                                         \
+      srcp += 2 * OPSIZ;                                               \
+      dstp += 2 * OPSIZ;                                               \
+      len -= 2;                                                                \
+    }                                                                  \
+  while (len != 0)
+
 void
 _wordcopy_fwd_dest_aligned (dstp, srcp, len)
      long int dstp;
@@ -102,54 +116,7 @@ _wordcopy_fwd_dest_aligned (dstp, srcp, len)
     len -= 1;
   }
 
-  switch (align)
-    {
-    case 1:
-      do
-        {
-          a1 = ((op_t *) srcp)[1];
-          a2 = ((op_t *) srcp)[2];
-          ((op_t *) dstp)[0] = MERGE (a0, 8, a1, (32-8));
-          ((op_t *) dstp)[1] = MERGE (a1, 8, a2, (32-8));
-          a0 = a2;
-    
-          srcp += 2 * OPSIZ;
-          dstp += 2 * OPSIZ;
-          len -= 2;
-        }
-      while (len != 0);
-      break;
-    case 2:
-      do
-        {
-          a1 = ((op_t *) srcp)[1];
-          a2 = ((op_t *) srcp)[2];
-          ((op_t *) dstp)[0] = MERGE (a0, 16, a1, (32-16));
-          ((op_t *) dstp)[1] = MERGE (a1, 16, a2, (32-16));
-          a0 = a2;
-    
-          srcp += 2 * OPSIZ;
-          dstp += 2 * OPSIZ;
-          len -= 2;
-        }
-      while (len != 0);
-      break;
-    case 3:
-      do
-        {
-          a1 = ((op_t *) srcp)[1];
-          a2 = ((op_t *) srcp)[2];
-          ((op_t *) dstp)[0] = MERGE (a0, 24, a1, (32-24));
-          ((op_t *) dstp)[1] = MERGE (a1, 24, a2, (32-24));
-          a0 = a2;
-    
-          srcp += 2 * OPSIZ;
-          dstp += 2 * OPSIZ;
-          len -= 2;
-        }
-      while (len != 0);
-      break;
-    }
+  fwd_align_merge (align);
 
 }
 
@@ -192,6 +159,20 @@ _wordcopy_bwd_aligned (dstp, srcp, len)
   while (len != 0);
 }
 
+#define bwd_align_merge(align)                                         \
+  do                                                                   \
+    {                                                                  \
+      srcp -= 2 * OPSIZ;                                               \
+      dstp -= 2 * OPSIZ;                                               \
+      a1 = ((op_t *) srcp)[1];                                         \
+      a0 = ((op_t *) srcp)[0];                                         \
+      ((op_t *) dstp)[1] = MERGE (a1, align*8, a2, (32-align*8));      \
+      ((op_t *) dstp)[0] = MERGE (a0, align*8, a1, (32-align*8));      \
+      a2 = a0;                                                         \
+      len -= 2;                                                                \
+    }                                                                  \
+  while (len != 0)
+
 /* _wordcopy_bwd_dest_aligned -- Copy block finishing right
    before SRCP to block finishing right before DSTP with LEN `op_t'
    words (not LEN bytes!).  DSTP should be aligned for memory
@@ -233,55 +214,5 @@ _wordcopy_bwd_dest_aligned (dstp, srcp, len)
     len -= 1;
   }
 
-  switch (align)
-    {
-    case 1:
-      do
-        {
-          srcp -= 2 * OPSIZ;
-          dstp -= 2 * OPSIZ;
-    
-          a1 = ((op_t *) srcp)[1];
-          a0 = ((op_t *) srcp)[0];
-          ((op_t *) dstp)[1] = MERGE (a1, 8, a2, (32-8));
-          ((op_t *) dstp)[0] = MERGE (a0, 8, a1, (32-8));
-          a2 = a0;
-    
-          len -= 2;
-        }
-      while (len != 0);
-      break;
-    case 2:
-      do
-        {
-          srcp -= 2 * OPSIZ;
-          dstp -= 2 * OPSIZ;
-    
-          a1 = ((op_t *) srcp)[1];
-          a0 = ((op_t *) srcp)[0];
-          ((op_t *) dstp)[1] = MERGE (a1, 16, a2, (32-16));
-          ((op_t *) dstp)[0] = MERGE (a0, 16, a1, (32-16));
-          a2 = a0;
-    
-          len -= 2;
-        }
-      while (len != 0);
-      break;
-    case 3:
-      do
-        {
-          srcp -= 2 * OPSIZ;
-          dstp -= 2 * OPSIZ;
-    
-          a1 = ((op_t *) srcp)[1];
-          a0 = ((op_t *) srcp)[0];
-          ((op_t *) dstp)[1] = MERGE (a1, 24, a2, (32-24));
-          ((op_t *) dstp)[0] = MERGE (a0, 24, a1, (32-24));
-          a2 = a0;
-    
-          len -= 2;
-        }
-      while (len != 0);
-      break;
-    }
+  bwd_align_merge (align);
 }
index faddd945b3ec20e9c281c4eff41f36034efee582..a6ded6aa59d3b02d8d9300ed0c5e09c4b1e9efc4 100644 (file)
@@ -1,5 +1,5 @@
 /* _memcopy.c -- subroutines for memory copy functions.
-   Copyright (C) 1991, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1991-2012 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Torbjorn Granlund (tege@sics.se).
 
@@ -60,6 +60,21 @@ _wordcopy_fwd_aligned (dstp, srcp, len)
   while (len != 0);
 }
 
+#define fwd_align_merge(align)                                         \
+  do                                                                   \
+    {                                                                  \
+      a1 = ((op_t *) srcp)[1];                                         \
+      a2 = ((op_t *) srcp)[2];                                         \
+      ((op_t *) dstp)[0] = MERGE (a0, align*8, a1, (64-align*8));      \
+      ((op_t *) dstp)[1] = MERGE (a1, align*8, a2, (64-align*8));      \
+      a0 = a2;                                                         \
+      srcp += 2 * OPSIZ;                                               \
+      dstp += 2 * OPSIZ;                                               \
+      len -= 2;                                                                \
+    }                                                                  \
+  while (len != 0)
+
+
 /* _wordcopy_fwd_dest_aligned -- Copy block beginning at SRCP to
    block beginning at DSTP with LEN `op_t' words (not LEN bytes!).
    DSTP should be aligned for memory operations on `op_t's, but SRCP must
@@ -101,114 +116,7 @@ _wordcopy_fwd_dest_aligned (dstp, srcp, len)
     len -= 1;
   }
 
-  switch (align)
-    {
-    case 1:
-      do
-        {
-          a1 = ((op_t *) srcp)[1];
-          a2 = ((op_t *) srcp)[2];
-          ((op_t *) dstp)[0] = MERGE (a0, 8, a1, (64-8));
-          ((op_t *) dstp)[1] = MERGE (a1, 8, a2, (64-8));
-          a0 = a2;
-    
-          srcp += 2 * OPSIZ;
-          dstp += 2 * OPSIZ;
-          len -= 2;
-        }
-      while (len != 0);
-      break;
-    case 2:
-      do
-        {
-          a1 = ((op_t *) srcp)[1];
-          a2 = ((op_t *) srcp)[2];
-          ((op_t *) dstp)[0] = MERGE (a0, 16, a1, (64-16));
-          ((op_t *) dstp)[1] = MERGE (a1, 16, a2, (64-16));
-          a0 = a2;
-    
-          srcp += 2 * OPSIZ;
-          dstp += 2 * OPSIZ;
-          len -= 2;
-        }
-      while (len != 0);
-      break;
-    case 3:
-      do
-        {
-          a1 = ((op_t *) srcp)[1];
-          a2 = ((op_t *) srcp)[2];
-          ((op_t *) dstp)[0] = MERGE (a0, 24, a1, (64-24));
-          ((op_t *) dstp)[1] = MERGE (a1, 24, a2, (64-24));
-          a0 = a2;
-    
-          srcp += 2 * OPSIZ;
-          dstp += 2 * OPSIZ;
-          len -= 2;
-        }
-      while (len != 0);
-      break;
-    case 4:
-      do
-        {
-          a1 = ((op_t *) srcp)[1];
-          a2 = ((op_t *) srcp)[2];
-          ((op_t *) dstp)[0] = MERGE (a0, 32, a1, (64-32));
-          ((op_t *) dstp)[1] = MERGE (a1, 32, a2, (64-32));
-          a0 = a2;
-    
-          srcp += 2 * OPSIZ;
-          dstp += 2 * OPSIZ;
-          len -= 2;
-        }
-      while (len != 0);
-      break;
-    case 5:
-      do
-        {
-          a1 = ((op_t *) srcp)[1];
-          a2 = ((op_t *) srcp)[2];
-          ((op_t *) dstp)[0] = MERGE (a0, 40, a1, (64-40));
-          ((op_t *) dstp)[1] = MERGE (a1, 40, a2, (64-40));
-          a0 = a2;
-    
-          srcp += 2 * OPSIZ;
-          dstp += 2 * OPSIZ;
-          len -= 2;
-        }
-      while (len != 0);
-      break;
-    case 6:
-      do
-        {
-          a1 = ((op_t *) srcp)[1];
-          a2 = ((op_t *) srcp)[2];
-          ((op_t *) dstp)[0] = MERGE (a0, 48, a1, (64-48));
-          ((op_t *) dstp)[1] = MERGE (a1, 48, a2, (64-48));
-          a0 = a2;
-    
-          srcp += 2 * OPSIZ;
-          dstp += 2 * OPSIZ;
-          len -= 2;
-        }
-      while (len != 0);
-      break;
-    case 7:
-      do
-        {
-          a1 = ((op_t *) srcp)[1];
-          a2 = ((op_t *) srcp)[2];
-          ((op_t *) dstp)[0] = MERGE (a0, 56, a1, (64-56));
-          ((op_t *) dstp)[1] = MERGE (a1, 56, a2, (64-56));
-          a0 = a2;
-    
-          srcp += 2 * OPSIZ;
-          dstp += 2 * OPSIZ;
-          len -= 2;
-        }
-      while (len != 0);
-      break;
-    }
+  fwd_align_merge (align);
 
 }
 
@@ -251,6 +159,20 @@ _wordcopy_bwd_aligned (dstp, srcp, len)
   while (len != 0);
 }
 
+#define bwd_align_merge(align)                                         \
+  do                                                                   \
+    {                                                                  \
+      srcp -= 2 * OPSIZ;                                               \
+      dstp -= 2 * OPSIZ;                                               \
+      a1 = ((op_t *) srcp)[1];                                         \
+      a0 = ((op_t *) srcp)[0];                                         \
+      ((op_t *) dstp)[1] = MERGE (a1, align*8, a2, (64-align*8));      \
+      ((op_t *) dstp)[0] = MERGE (a0, align*8, a1, (64-align*8));      \
+      a2 = a0;                                                         \
+      len -= 2;                                                                \
+    }                                                                  \
+  while (len != 0)
+
 /* _wordcopy_bwd_dest_aligned -- Copy block finishing right
    before SRCP to block finishing right before DSTP with LEN `op_t'
    words (not LEN bytes!).  DSTP should be aligned for memory
@@ -292,119 +214,5 @@ _wordcopy_bwd_dest_aligned (dstp, srcp, len)
     len -= 1;
   }
 
-  switch (align)
-    {
-    case 1:
-      do
-        {
-          srcp -= 2 * OPSIZ;
-          dstp -= 2 * OPSIZ;
-    
-          a1 = ((op_t *) srcp)[1];
-          a0 = ((op_t *) srcp)[0];
-          ((op_t *) dstp)[1] = MERGE (a1, 8, a2, (64-8));
-          ((op_t *) dstp)[0] = MERGE (a0, 8, a1, (64-8));
-          a2 = a0;
-    
-          len -= 2;
-        }
-      while (len != 0);
-      break;
-    case 2:
-      do
-        {
-          srcp -= 2 * OPSIZ;
-          dstp -= 2 * OPSIZ;
-    
-          a1 = ((op_t *) srcp)[1];
-          a0 = ((op_t *) srcp)[0];
-          ((op_t *) dstp)[1] = MERGE (a1, 16, a2, (64-16));
-          ((op_t *) dstp)[0] = MERGE (a0, 16, a1, (64-16));
-          a2 = a0;
-    
-          len -= 2;
-        }
-      while (len != 0);
-      break;
-    case 3:
-      do
-        {
-          srcp -= 2 * OPSIZ;
-          dstp -= 2 * OPSIZ;
-    
-          a1 = ((op_t *) srcp)[1];
-          a0 = ((op_t *) srcp)[0];
-          ((op_t *) dstp)[1] = MERGE (a1, 24, a2, (64-24));
-          ((op_t *) dstp)[0] = MERGE (a0, 24, a1, (64-24));
-          a2 = a0;
-    
-          len -= 2;
-        }
-      while (len != 0);
-      break;
-    case 4:
-      do
-        {
-          srcp -= 2 * OPSIZ;
-          dstp -= 2 * OPSIZ;
-    
-          a1 = ((op_t *) srcp)[1];
-          a0 = ((op_t *) srcp)[0];
-          ((op_t *) dstp)[1] = MERGE (a1, 32, a2, (64-32));
-          ((op_t *) dstp)[0] = MERGE (a0, 32, a1, (64-32));
-          a2 = a0;
-    
-          len -= 2;
-        }
-      while (len != 0);
-      break;
-    case 5:
-      do
-        {
-          srcp -= 2 * OPSIZ;
-          dstp -= 2 * OPSIZ;
-    
-          a1 = ((op_t *) srcp)[1];
-          a0 = ((op_t *) srcp)[0];
-          ((op_t *) dstp)[1] = MERGE (a1, 40, a2, (64-40));
-          ((op_t *) dstp)[0] = MERGE (a0, 40, a1, (64-40));
-          a2 = a0;
-    
-          len -= 2;
-        }
-      while (len != 0);
-      break;
-    case 6:
-      do
-        {
-          srcp -= 2 * OPSIZ;
-          dstp -= 2 * OPSIZ;
-    
-          a1 = ((op_t *) srcp)[1];
-          a0 = ((op_t *) srcp)[0];
-          ((op_t *) dstp)[1] = MERGE (a1, 48, a2, (64-48));
-          ((op_t *) dstp)[0] = MERGE (a0, 48, a1, (64-48));
-          a2 = a0;
-    
-          len -= 2;
-        }
-      while (len != 0);
-      break;
-    case 7:
-      do
-        {
-          srcp -= 2 * OPSIZ;
-          dstp -= 2 * OPSIZ;
-    
-          a1 = ((op_t *) srcp)[1];
-          a0 = ((op_t *) srcp)[0];
-          ((op_t *) dstp)[1] = MERGE (a1, 56, a2, (64-56));
-          ((op_t *) dstp)[0] = MERGE (a0, 56, a1, (64-56));
-          a2 = a0;
-    
-          len -= 2;
-        }
-      while (len != 0);
-      break;
-    }
+  bwd_align_merge (align);
 }