]> granicus.if.org Git - clang/commitdiff
Fixing implementation of bittestandset in Intrin.h.
authorWarren Hunt <whunt@google.com>
Tue, 1 Oct 2013 17:12:40 +0000 (17:12 +0000)
committerWarren Hunt <whunt@google.com>
Tue, 1 Oct 2013 17:12:40 +0000 (17:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191783 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Headers/Intrin.h

index 8b7550ca1f2a6daca9a31bedcc8375d6f51fe42b..5b00e3c8fe497fc59bdc0eacce3e3c3b09e1b9df 100644 (file)
@@ -497,7 +497,7 @@ _bittestandreset(long *a, long b) {
 static __inline__ unsigned char __attribute__((__always_inline__, __nodebug__))
 _bittestandset(long *a, long b) {
   unsigned char x = (*a >> b) & 1;
-  *a = *a & (1 << b);
+  *a = *a | (1 << b);
   return x;
 }
 #ifdef __x86_64__
@@ -546,7 +546,7 @@ _bittestandreset64(__int64 *a, __int64 b) {
 static __inline__ unsigned char __attribute__((__always_inline__, __nodebug__))
 _bittestandset64(__int64 *a, __int64 b) {
   unsigned char x = (*a >> b) & 1;
-  *a = *a & (1ll << b);
+  *a = *a | (1ll << b);
   return x;
 }
 #endif