3 ms·
I think the issue that the article is not explaining very well, is that what it's actually trying to do is check if a number is a power of two, and one part of
by IshKebab 2y ago
I think the issue that the article is not explaining very well, is that what it's actually trying to do is check if a number is a power of two, and one part of the compiler says "use popcnt!" and then later another part says "oh sorry, we'll have to emulate that with a ton of instructions". Whereas it could have just used a shift and and.
- mrcode007 2y agoThe power of two test is simply x & (x-1) == 0 which could be special cased through templates too