diff options
author | Jonas Hahnfeld <Hahnfeld@itc.rwth-aachen.de> | 2017-01-12 11:39:04 +0000 |
---|---|---|
committer | Jonas Hahnfeld <Hahnfeld@itc.rwth-aachen.de> | 2017-01-12 11:39:04 +0000 |
commit | c9a8a6c03005a38de29d947e3cf964fa31b400fe (patch) | |
tree | d4f5ef41fb29af80d6fd9c07627040972bc0c202 /openmp/runtime/src/kmp_affinity.cpp | |
parent | eff6e83f23d4bfafbf9a812f2bbabe349adf1e3d (diff) | |
download | bcm5719-llvm-c9a8a6c03005a38de29d947e3cf964fa31b400fe.tar.gz bcm5719-llvm-c9a8a6c03005a38de29d947e3cf964fa31b400fe.zip |
kmp_affinity: Fix check if specific bit is set
Clang 4.0 trunk warns:
warning: logical not is only applied to the left hand side of this bitwise operator [-Wlogical-not-parentheses]
This points to a potential bug if the code really wants to check if the single
bit is not set: If for example (buf.edx >> 9) = 2 (has any bit set except the
least significant one), 'logical not' will return 0 which stays 0 after the
'bitwise and'.
To do this correctly we first need to evaluate the 'bitwise and'. In that case
it returns 2 & 1 = 0 which after the 'logical not' evaluates to 1.
Differential Revision: https://reviews.llvm.org/D28599
llvm-svn: 291764
Diffstat (limited to 'openmp/runtime/src/kmp_affinity.cpp')
-rw-r--r-- | openmp/runtime/src/kmp_affinity.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/openmp/runtime/src/kmp_affinity.cpp b/openmp/runtime/src/kmp_affinity.cpp index f09c3cdac93..79b9b91df75 100644 --- a/openmp/runtime/src/kmp_affinity.cpp +++ b/openmp/runtime/src/kmp_affinity.cpp @@ -1022,7 +1022,7 @@ __kmp_affinity_create_apicid_map(AddrUnsPair **address2os, // The apic id and max threads per pkg come from cpuid(1). // __kmp_x86_cpuid(1, 0, &buf); - if (! (buf.edx >> 9) & 1) { + if (((buf.edx >> 9) & 1) == 0) { __kmp_set_system_affinity(oldMask, TRUE); __kmp_free(threadInfo); KMP_CPU_FREE(oldMask); |