mercredi 4 novembre 2015

Optimize simple comparison with zero for performance

I have a bottleneck (about 20% CPU time) in my code which is in following if statement:

if (a == 0) { // here
    ...
}

where a is a uint8_t, so a number from 0 to 255.

Are there any low level optimizations to make it faster?
I thought about using bitwise NOR (~(a| 0)), but that would work only if a was a 1-bit, right?

Just in case: I don't care about code readability in this particular case.

Aucun commentaire:

Enregistrer un commentaire