4 ms·
That instruction only encodes to 2 bytes, so size-wise it's the most efficient. In isolation it's the smallest, but it's no longer the smallest if you consider
by userbinator 2y ago
That instruction only encodes to 2 bytes, so size-wise it's the most efficient.
In isolation it's the smallest, but it's no longer the smallest if you consider that the value, which in this example is the loop counter, needs to be preserved, meaning you'll need at least 2 bytes for another mov to make a copy. With test, the value doesn't get modified.
- dansalvato 2y agoThat is true, I deliberately set up an isolated scenario to do these fun theoretical tests. It actually took some effort to stop the compiler from being too smart, because it would want to transform the result into a return value, or even into a pointer offset, to avoid branching.