Skip to content

Commit

Permalink
Minor Clang speedup
Browse files Browse the repository at this point in the history
  • Loading branch information
kimwalisch committed Jun 26, 2024
1 parent 613a0b2 commit 7491b48
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions libpopcnt.h
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ static inline uint64_t popcnt(const void* data, uint64_t size)
uint64_t bytes = (uint64_t) (8 - rem % 8);
bytes = (bytes <= 7) ? bytes : 7;
for (uint64_t j = 0; j < bytes; j++)
val = (val << 8) + ptr[i + j];
val |= ((uint64_t) ptr[i + j]) << (j * 8);
cnt += popcnt64(val);
i += bytes;
}
Expand All @@ -608,7 +608,7 @@ static inline uint64_t popcnt(const void* data, uint64_t size)
uint64_t bytes = (uint64_t) (size - i);
bytes = (bytes <= 7) ? bytes : 7;
for (uint64_t j = 0; j < bytes; j++)
val = (val << 8) + ptr[i + j];
val |= ((uint64_t) ptr[i + j]) << (j * 8);
cnt += popcnt64(val);
}

Expand All @@ -635,7 +635,7 @@ static inline uint64_t popcnt(const void* data, uint64_t size)
uint64_t bytes = (uint64_t) (8 - rem % 8);
bytes = (bytes <= 7) ? bytes : 7;
for (uint64_t j = 0; j < bytes; j++)
val = (val << 8) + ptr[i + j];
val |= ((uint64_t) ptr[i + j]) << (j * 8);
cnt += popcnt64_bitwise(val);
i += bytes;
}
Expand All @@ -650,7 +650,7 @@ static inline uint64_t popcnt(const void* data, uint64_t size)
uint64_t bytes = (uint64_t) (size - i);
bytes = (bytes <= 7) ? bytes : 7;
for (uint64_t j = 0; j < bytes; j++)
val = (val << 8) + ptr[i + j];
val |= ((uint64_t) ptr[i + j]) << (j * 8);
cnt += popcnt64_bitwise(val);
}

Expand Down Expand Up @@ -696,7 +696,7 @@ static inline uint64_t popcnt(const void* data, uint64_t size)
uint64_t val = 0;
bytes = (bytes <= 7) ? bytes : 7;
for (uint64_t j = 0; j < bytes; j++)
val = (val << 8) + ptr8[i + j];
val |= ((uint64_t) ptr[i + j]) << (j * 8);
cnt += popcnt64(val);
}

Expand Down Expand Up @@ -786,7 +786,7 @@ static inline uint64_t popcnt(const void* data, uint64_t size)
uint64_t bytes = (uint64_t) (8 - rem % 8);
bytes = (bytes <= 7) ? bytes : 7;
for (uint64_t j = 0; j < bytes; j++)
val = (val << 8) + ptr[i + j];
val |= ((uint64_t) ptr[i + j]) << (j * 8);
cnt += popcnt64(val);
i += bytes;
}
Expand All @@ -801,7 +801,7 @@ static inline uint64_t popcnt(const void* data, uint64_t size)
uint64_t bytes = (uint64_t) (size - i);
bytes = (bytes <= 7) ? bytes : 7;
for (uint64_t j = 0; j < bytes; j++)
val = (val << 8) + ptr[i + j];
val |= ((uint64_t) ptr[i + j]) << (j * 8);
cnt += popcnt64(val);
}

Expand Down Expand Up @@ -833,7 +833,7 @@ static inline uint64_t popcnt(const void* data, uint64_t size)
uint64_t bytes = (uint64_t) (8 - rem % 8);
bytes = (bytes <= 7) ? bytes : 7;
for (uint64_t j = 0; j < bytes; j++)
val = (val << 8) + ptr[i + j];
val |= ((uint64_t) ptr[i + j]) << (j * 8);
cnt += popcnt64(val);
i += bytes;
}
Expand All @@ -848,7 +848,7 @@ static inline uint64_t popcnt(const void* data, uint64_t size)
uint64_t bytes = (uint64_t) (size - i);
bytes = (bytes <= 7) ? bytes : 7;
for (uint64_t j = 0; j < bytes; j++)
val = (val << 8) + ptr[i + j];
val |= ((uint64_t) ptr[i + j]) << (j * 8);
cnt += popcnt64(val);
}

Expand Down

0 comments on commit 7491b48

Please sign in to comment.