From f59ad976ed979d22637c5187f6a92fbbd8c191e4 Mon Sep 17 00:00:00 2001 From: Rajalakshmi Srinivasaraghavan Date: Wed, 31 Dec 2014 14:05:00 -0500 Subject: powerpc: POWER7 strcpy optimization for unaligned strings This patch optimizes strcpy for ppc64/power7 for unaligned source or destination address. The source or destination address is aligned to doubleword and data is shifted based on the alignment and added with the previous loaded data to be written as a doubleword. For each load, cmpb instruction is used for faster null check. The word aligned optimization is also removed, since the new unaligned code path shows better results handling word-aligned strings. More combination of unaligned inputs is also added in benchtest to measure the improvement.The new optimization shows 2 to 80% of performance improvement for longer string though it does not show big difference on string size less than 16 due to additional checks. --- benchtests/bench-strcpy.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'benchtests/bench-strcpy.c') diff --git a/benchtests/bench-strcpy.c b/benchtests/bench-strcpy.c index c3ab4cfcf7..e9445f290f 100644 --- a/benchtests/bench-strcpy.c +++ b/benchtests/bench-strcpy.c @@ -171,6 +171,22 @@ test_main (void) do_test (i, i, 8 << i, BIG_CHAR); } + for (i = 16; i <= 512; i+=4) + { + do_test (0, 4, i, SMALL_CHAR); + do_test (4, 0, i, BIG_CHAR); + do_test (4, 4, i, SMALL_CHAR); + do_test (2, 2, i, BIG_CHAR); + do_test (2, 6, i, SMALL_CHAR); + do_test (6, 2, i, BIG_CHAR); + do_test (1, 7, i, SMALL_CHAR); + do_test (7, 1, i, BIG_CHAR); + do_test (3, 4, i, SMALL_CHAR); + do_test (4, 3, i, BIG_CHAR); + do_test (5, 7, i, SMALL_CHAR); + do_test (7, 5, i, SMALL_CHAR); + } + return ret; } -- cgit 1.4.1