From 0cc83d15e8dd51b04d3927efe1740df600491840 Mon Sep 17 00:00:00 2001
From: Warren Hunt <whunt@google.com>
Date: Tue, 1 Oct 2013 17:12:40 +0000
Subject: [PATCH] Fixing implementation of bittestandset in Intrin.h.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@191783 91177308-0d34-0410-b5e6-96231b3b80d8
---
 lib/Headers/Intrin.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/Headers/Intrin.h b/lib/Headers/Intrin.h
index 8b7550ca1f..5b00e3c8fe 100644
--- a/lib/Headers/Intrin.h
+++ b/lib/Headers/Intrin.h
@@ -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
-- 
2.40.0