<< 64/66 >>
First Last

賢い加算

 0.upto(15){ |x|
     i = (x&1)*8+(x/2)
     @asm<<"e cntb $r#{i},$r#{i}"
     @asm<<"e cntb $r#{i+16},$r#{i+16}"
     @asm<<"e sumb $r#{i},$r#{i+16},$r#{i}"
 }
 0.upto(7){|i|
     @asm<<"o shufb $r#{i},$r#{i},$r#{i+8},shufc"
     @asm<<"e a %#{i},%#{i},$r#{i}"
 }
 ※shufc = {1,17,3,19, 5,21,7,23, 9,25,11,27, 13,29,15,31}

http://longlong.way-nifty.com/blog/2009/03/post-21ee.html