Skip to content

Commit d8c2875

Browse files
author
Eddie
committed
Minor improvement
1 parent fa2ea47 commit d8c2875

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

inc/zoo/swar/associative_iteration.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ compress(SWAR<NB, B> input, SWAR<NB, B> compressionMask) {
198198
ZTE(forParallelSuffix);
199199
// note: forParallelSuffix denotes positions with a zero
200200
// immediately to the right in 'compressionMask'
201-
do {
201+
for(;;) {
202202
ZTE(groupSize);
203203
ZTE(shiftLeftMask);
204204
ZTE(shiftRightMask);
@@ -217,7 +217,10 @@ compress(SWAR<NB, B> input, SWAR<NB, B> compressionMask) {
217217
result =
218218
(result ^ movingFromInput) | // clear the moving from the result
219219
movingFromInput.shiftIntraLaneRight(groupSize, shiftRightMask);
220-
220+
auto nextGroupSize = groupSize << 1;
221+
if(NB <= nextGroupSize) {
222+
break;
223+
}
221224
auto evenCountOfGroupsOfZerosToTheRight =
222225
~oddCountOfGroupsOfZerosToTheRight;
223226
forParallelSuffix =
@@ -227,8 +230,8 @@ compress(SWAR<NB, B> input, SWAR<NB, B> compressionMask) {
227230
shiftRightMask =
228231
shiftRightMask.shiftIntraLaneLeft(groupSize, shiftLeftMask);
229232
shiftLeftMask = newShiftLeftMask;
230-
groupSize <<= 1;
231-
} while(groupSize < NB);
233+
groupSize = nextGroupSize;
234+
}
232235
ZTE(result);
233236
#undef ZTE
234237
return result;

0 commit comments

Comments
 (0)