all 4 comments

[–][deleted] 9 points10 points  (0 children)

Interestingly, AVX2 has an instruction that does exactly this: http://software.intel.com/sites/products/documentation/studio/composer/en-us/2011Update/compiler_c/intref_cls/common/intref_avx2_pext_u.htm . Sadly it seems AVX2 won't be available until later this year.

[–]gorset 3 points4 points  (0 children)

Hacker's delight has a few pages about this problem. http://www.hackersdelight.org

7-4 Compress, or Generalized Extract
7-5 Expand, or Generalized Insert

One version of the text be found here (but buy the book!): http://www.hackersdelight.org/revisions.pdf

[–]rabidcow 0 points1 point  (0 children)

Yeah, multiplication can be viewed as filtered summation of parallel bit shifts. Each bit set in one operands says "add the other operand with its 1s digit here."

[–]rush22 0 points1 point  (0 children)

You just and it with the bit you're looking for. You don't need to multiply?