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;
|
||||
size_t off = 0;
|
||||
|
||||
for (size_t bit = 0; bit != sizeof(T) * 8; ++bit) {
|
||||
const bool valBit = (val >> bit) & 1;
|
||||
const bool maskBit = (mask >> bit) & 1;
|
||||
for (size_t bit = 0; bit < sizeof(T) * 8; ++bit) {
|
||||
bool maskBit = (mask >> bit) & 1;
|
||||
if (maskBit) {
|
||||
bool valBit = (val >> bit) & 1;
|
||||
result |= static_cast<T>(valBit) << off;
|
||||
++off;
|
||||
}
|
||||
|
@ -41,10 +41,10 @@ template <typename T> T scatterBits(T val, T mask) {
|
|||
T result = 0;
|
||||
size_t off = 0;
|
||||
|
||||
for (size_t bit = 0; bit != sizeof(T) * 8; ++bit) {
|
||||
const bool valBit = (val >> off) & 1;
|
||||
const bool maskBit = (mask >> bit) & 1;
|
||||
for (size_t bit = 0; bit < sizeof(T) * 8; ++bit) {
|
||||
bool maskBit = (mask >> bit) & 1;
|
||||
if (maskBit) {
|
||||
bool valBit = (val >> off) & 1;
|
||||
result |= static_cast<T>(valBit) << bit;
|
||||
++off;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue