- (:temporary (:sc unsigned-reg :from (:argument 0)) temp)
- (:temporary (:sc unsigned-reg :from (:argument 0)) t1)
- (:generator 60
+ (:temporary (:sc unsigned-reg) temp)
+ (:temporary (:sc unsigned-reg) mask)
+ (:generator 14
+ ;; See the comments below for how the algorithm works. The tricks
+ ;; used can be found for example in AMD's software optimization
+ ;; guide or at "http://www.hackersdelight.org/HDcode/pop.cc" in the
+ ;; function "pop1", for 32-bit words. The extension to 64 bits is
+ ;; straightforward.
+ ;; Calculate 2-bit sums. Note that the value of a two-digit binary
+ ;; number is the sum of the right digit and twice the left digit.
+ ;; Thus we can calculate the sum of the two digits by shifting the
+ ;; left digit to the right position and doing a two-bit subtraction.
+ ;; This subtraction will never create a borrow and thus can be made
+ ;; on all 32 2-digit numbers at once.