This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 4/5] [Powerpc] tune/optimize memmove/wordcopy. Convertswitch to if-then-else
- From: Will Schmidt <will_schmidt at vnet dot ibm dot com>
- To: libc-alpha at sourceware dot org
- Cc: willschm at us dot ibm dot com
- Date: Mon, 12 Mar 2012 16:38:36 -0500
- Subject: [PATCH 4/5] [Powerpc] tune/optimize memmove/wordcopy. Convertswitch to if-then-else
- References: <20120312213742.28917.97709.stgit@brimstone>
[Powerpc] tune/optimize memmove/wordcopy. Convert switch to if-then-else
Convert the switch statements to a (slightly faster) if-then-else decision
tree.
2012-03-12 Will Schmidt <will_schmidt@vnet.ibm.com>
* sysdeps/powerpc/powerpc64/power7/wordcopy.c: Replace switch
statement with if-then-else tree.
* sysdeps/powerpc/powerpc32/power7/wordcopy.c: Likewise.
---
sysdeps/powerpc/powerpc32/power7/wordcopy.c | 34 ++++-----
sysdeps/powerpc/powerpc64/power7/wordcopy.c | 98 +++++++++++++++------------
2 files changed, 68 insertions(+), 64 deletions(-)
diff --git a/sysdeps/powerpc/powerpc32/power7/wordcopy.c b/sysdeps/powerpc/powerpc32/power7/wordcopy.c
index 9748268..00bd444 100644
--- a/sysdeps/powerpc/powerpc32/power7/wordcopy.c
+++ b/sysdeps/powerpc/powerpc32/power7/wordcopy.c
@@ -116,18 +116,15 @@ _wordcopy_fwd_dest_aligned (dstp, srcp, len)
len -= 1;
}
- switch (align)
+ if (align >=2)
{
- case 1:
- fwd_align_merge(1)
- break;
- case 2:
- fwd_align_merge(2)
- break;
- case 3:
- fwd_align_merge(3)
- break;
+ if (align == 2)
+ fwd_align_merge(2)
+ else
+ fwd_align_merge(3)
}
+ else
+ fwd_align_merge(1)
}
@@ -225,16 +222,13 @@ _wordcopy_bwd_dest_aligned (dstp, srcp, len)
len -= 1;
}
- switch (align)
+ if (align >=2)
{
- case 1:
- bwd_align_merge(1)
- break;
- case 2:
- bwd_align_merge(2)
- break;
- case 3:
- bwd_align_merge(3)
- break;
+ if (align == 2)
+ bwd_align_merge(2)
+ else
+ bwd_align_merge(3)
}
+ else
+ bwd_align_merge(1)
}
diff --git a/sysdeps/powerpc/powerpc64/power7/wordcopy.c b/sysdeps/powerpc/powerpc64/power7/wordcopy.c
index 1ff9c92..1c7b99a 100644
--- a/sysdeps/powerpc/powerpc64/power7/wordcopy.c
+++ b/sysdeps/powerpc/powerpc64/power7/wordcopy.c
@@ -116,29 +116,34 @@ _wordcopy_fwd_dest_aligned (dstp, srcp, len)
len -= 1;
}
- switch (align)
+ if (align >=4)
{
- case 1:
- fwd_align_merge(1)
- break;
- case 2:
- fwd_align_merge(2)
- break;
- case 3:
- fwd_align_merge(3)
- break;
- case 4:
- fwd_align_merge(4)
- break;
- case 5:
- fwd_align_merge(5)
- break;
- case 6:
- fwd_align_merge(6)
- break;
- case 7:
- fwd_align_merge(7)
- break;
+ if (align >=6)
+ {
+ if (align==6)
+ fwd_align_merge(6)
+ else
+ fwd_align_merge(7)
+ }
+ else
+ {
+ if (align==4)
+ fwd_align_merge(4)
+ else
+ fwd_align_merge(5)
+ }
+ }
+ else
+ {
+ if (align >=2)
+ {
+ if (align == 2)
+ fwd_align_merge(2)
+ else
+ fwd_align_merge(3)
+ }
+ else
+ fwd_align_merge(1)
}
}
@@ -237,28 +242,33 @@ _wordcopy_bwd_dest_aligned (dstp, srcp, len)
len -= 1;
}
- switch (align)
+ if (align >=4)
+ {
+ if (align >=6)
+ {
+ if (align==6)
+ bwd_align_merge(6)
+ else
+ bwd_align_merge(7)
+ }
+ else
+ {
+ if (align==4)
+ bwd_align_merge(4)
+ else
+ bwd_align_merge(5)
+ }
+ }
+ else
{
- case 1:
- bwd_align_merge(1)
- break;
- case 2:
- bwd_align_merge(2)
- break;
- case 3:
- bwd_align_merge(3)
- break;
- case 4:
- bwd_align_merge(4)
- break;
- case 5:
- bwd_align_merge(5)
- break;
- case 6:
- bwd_align_merge(6)
- break;
- case 7:
- bwd_align_merge(7)
- break;
+ if (align >=2)
+ {
+ if (align == 2)
+ bwd_align_merge(2)
+ else
+ bwd_align_merge(3)
+ }
+ else
+ bwd_align_merge(1)
}
}