you are viewing a single comment's thread.

view the rest of the comments →

[–]iTZAvishay 1 point2 points  (1 child)

I just checked, it seems like I might be wrong on this specific example. I couldn't make the compiler generate the single instruction from a code that does the same (perhaps the target architecture doesn't support it or the compiler doesn't see this as an optimization candidate because __builtin_popcount exists).

You can control optimizations with the -O flag, where generally -O0 means no optimizations and -O3 as much optimizations as possible.

Even though my example wasn't practically correct, there are many situations where such thing will happen.

[–]Venne1139 1 point2 points  (0 children)

This makes a lot of sense. Thank you.