tag:blogger.com,1999:blog-2543858175797658864.post562068034308434976..comments2017-01-19T07:30:20.841-05:00Comments on Trash Can of Code: Bitwise Set-Bit (#2)cottonvibeshttp://www.blogger.com/profile/15542648017139504620noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-2543858175797658864.post-64603474123371213062011-10-06T20:14:33.736-04:002011-10-06T20:14:33.736-04:00Yup that's an excellent point. The bitwise sol...Yup that's an excellent point. The bitwise solution will allow you to do this on multiple vectors of the SIMD reg at once without needing any conditional jumps or jump-tables.<br /><br />Since SSE2 has integer comparison operations, you can use another bitwise solution other than the one above:<br /><br />PXOR xmm1, xmm1 // Set xmm1 to 0<br />PCMPNED xmm0, xmm1 // Set xmm0 to all 1's if not equal<br />PSRLD xmm0, 31 // Logical right shift by 31<br /><br />If your SIMD instruction set didn't have integer comparison operations, then the bitwise solution in the blog post might be the way to go.cottonvibeshttp://www.blogger.com/profile/15542648017139504620noreply@blogger.comtag:blogger.com,1999:blog-2543858175797658864.post-33340124449164004882011-10-06T16:04:08.522-04:002011-10-06T16:04:08.522-04:00Am I correct in saying that the "bitwise"...Am I correct in saying that the "bitwise" solution is the most useful when applied to SIMD? Since it's a condition-free computational process that can be applied equally across entire arrays of data -- and since SETcc stuff typically doesn't exist on SIMD instruction sets.<br /><br />So even when it seems less intuitive, a bitwise solution is good to know because can still be useful where SIMD-style data operations are involved.Airhttp://www.blogger.com/profile/02119011110657057621noreply@blogger.com