forked from OSchip/llvm-project
No need to compute valBit until mask bit is 1.
llvm-svn: 210084
This commit is contained in:
parent
6c3bbf4271
commit
9ef8a9c94b
|
@ -21,10 +21,10 @@ template <typename T> T gatherBits(T val, T mask) {
|
||||||
T result = 0;
|
T result = 0;
|
||||||
size_t off = 0;
|
size_t off = 0;
|
||||||
|
|
||||||
for (size_t bit = 0; bit != sizeof(T) * 8; ++bit) {
|
for (size_t bit = 0; bit < sizeof(T) * 8; ++bit) {
|
||||||
const bool valBit = (val >> bit) & 1;
|
bool maskBit = (mask >> bit) & 1;
|
||||||
const bool maskBit = (mask >> bit) & 1;
|
|
||||||
if (maskBit) {
|
if (maskBit) {
|
||||||
|
bool valBit = (val >> bit) & 1;
|
||||||
result |= static_cast<T>(valBit) << off;
|
result |= static_cast<T>(valBit) << off;
|
||||||
++off;
|
++off;
|
||||||
}
|
}
|
||||||
|
@ -41,10 +41,10 @@ template <typename T> T scatterBits(T val, T mask) {
|
||||||
T result = 0;
|
T result = 0;
|
||||||
size_t off = 0;
|
size_t off = 0;
|
||||||
|
|
||||||
for (size_t bit = 0; bit != sizeof(T) * 8; ++bit) {
|
for (size_t bit = 0; bit < sizeof(T) * 8; ++bit) {
|
||||||
const bool valBit = (val >> off) & 1;
|
bool maskBit = (mask >> bit) & 1;
|
||||||
const bool maskBit = (mask >> bit) & 1;
|
|
||||||
if (maskBit) {
|
if (maskBit) {
|
||||||
|
bool valBit = (val >> off) & 1;
|
||||||
result |= static_cast<T>(valBit) << bit;
|
result |= static_cast<T>(valBit) << bit;
|
||||||
++off;
|
++off;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue