Skip to content

Commit 685154c

Browse files
committed
stress-insertionsort: unroll search loop
Minor improvement with unrolled search loops Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
1 parent fdc5c8e commit 685154c

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

stress-insertionsort.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "stress-ng.h"
2020
#include "core-madvise.h"
2121
#include "core-mmap.h"
22+
#include "core-pragma.h"
2223
#include "core-signal.h"
2324
#include "core-sort.h"
2425
#include "core-target-clones.h"
@@ -48,6 +49,7 @@ static uint64_t OPTIMIZE3 TARGET_CLONES insertionsort_fwd(int32_t *base, size_t
4849
register const int32_t tmp = base[i];
4950
register size_t j = i;
5051

52+
PRAGMA_UNROLL
5153
while ((j > 0) && (base[j - 1] > tmp)) {
5254
base[j] = base[j - 1];
5355
j--;
@@ -67,6 +69,7 @@ static uint64_t OPTIMIZE3 TARGET_CLONES insertionsort_rev(int32_t *base, size_t
6769
register const int32_t tmp = base[i];
6870
register size_t j = i;
6971

72+
PRAGMA_UNROLL
7073
while ((j > 0) && (base[j - 1] < tmp)) {
7174
base[j] = base[j - 1];
7275
j--;

0 commit comments

Comments
 (0)