Permalink
Browse files

Remove 1 instruction from popcount

Summary:
by removing the unnecessary constraint that the input and output be in
the same register (copypasta from https://phabricator.fb.com/D542718)

Test Plan: folly/test

Reviewed By: soren@fb.com

FB internal diff: D543310
  • Loading branch information...
1 parent 7fd87e7 commit 71acc41b44cb2f8a20cbf37a17f32a4eb7f7fc25 @tudor tudor committed Aug 8, 2012
Showing with 6 additions and 4 deletions.
  1. +6 −4 folly/Bits.cpp
View
10 folly/Bits.cpp
@@ -25,17 +25,19 @@
namespace {
int popcount_inst(unsigned int x) {
- asm ("popcntl %0, %0" : "=r" (x) : "0" (x));
- return x;
+ int n;
+ asm ("popcntl %1, %0" : "=r" (n) : "r" (x));
+ return n;
}
int popcount_builtin(unsigned int x) {
return __builtin_popcount(x);
}
int popcountll_inst(unsigned long long x) {
- asm ("popcntq %0, %0" : "=r" (x) : "0" (x));
- return x;
+ unsigned long long n;
+ asm ("popcntq %1, %0" : "=r" (n) : "r" (x));
+ return n;
}
int popcountll_builtin(unsigned long long x) {

0 comments on commit 71acc41

Please sign in to comment.