+ (:temporary (:sc unsigned-reg) temp)
+ (: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".
+ ;; 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 16 2-digit numbers at once.