[PATCH] D40774: [libcxx] Fix intrinsics for MSVC

Shoaib Meenai via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 5 09:46:55 PST 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rCXX319802: [libcxx] Fix intrinsics for MSVC (authored by smeenai).

Repository:
  rCXX libc++

https://reviews.llvm.org/D40774

Files:
  include/algorithm


Index: include/algorithm
===================================================================
--- include/algorithm
+++ include/algorithm
@@ -797,7 +797,7 @@
   unsigned long where;
   // Search from LSB to MSB for first set bit.
   // Returns zero if no set bit is found.
-  if (_BitScanForward(&where, mask))
+  if (_BitScanForward(&where, __x))
     return where;
   return 32;
 #endif
@@ -823,15 +823,15 @@
 // Returns zero if no set bit is found.
 #if defined(_LIBCPP_HAS_BITSCAN64)
     (defined(_M_AMD64) || defined(__x86_64__))
-  if (_BitScanForward64(&where, mask))
+  if (_BitScanForward64(&where, __x))
     return static_cast<int>(where);
 #else
   // Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls.
   // Scan the Low Word.
-  if (_BitScanForward(&where, static_cast<unsigned long>(mask)))
+  if (_BitScanForward(&where, static_cast<unsigned long>(__x)))
     return where;
   // Scan the High Word.
-  if (_BitScanForward(&where, static_cast<unsigned long>(mask >> 32)))
+  if (_BitScanForward(&where, static_cast<unsigned long>(__x >> 32)))
     return where + 32; // Create a bit offset from the LSB.
 #endif
   return 64;
@@ -849,7 +849,7 @@
   unsigned long where;
   // Search from LSB to MSB for first set bit.
   // Returns zero if no set bit is found.
-  if (_BitScanReverse(&where, mask))
+  if (_BitScanReverse(&where, __x))
     return 31 - where;
   return 32; // Undefined Behavior.
 #endif
@@ -874,14 +874,14 @@
 // BitScanReverse scans from MSB to LSB for first set bit.
 // Returns 0 if no set bit is found.
 #if defined(_LIBCPP_HAS_BITSCAN64)
-  if (_BitScanReverse64(&where, mask))
+  if (_BitScanReverse64(&where, __x))
     return static_cast<int>(63 - where);
 #else
   // Scan the high 32 bits.
-  if (_BitScanReverse(&where, static_cast<unsigned long>(mask >> 32)))
+  if (_BitScanReverse(&where, static_cast<unsigned long>(__x >> 32)))
     return 63 - (where + 32); // Create a bit offset from the MSB.
   // Scan the low 32 bits.
-  if (_BitScanReverse(&where, static_cast<unsigned long>(mask)))
+  if (_BitScanReverse(&where, static_cast<unsigned long>(__x)))
     return 63 - where;
 #endif
   return 64; // Undefined Behavior.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40774.125562.patch
Type: text/x-patch
Size: 2196 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171205/cd1013d9/attachment-0001.bin>


More information about the cfe-commits mailing list