Yes, you can have a test and a branch considered as one instruction, and the way to do this is to write them as two instructions, like you, use a modern Intel processor and follow a few simple rules (the branch instruction must be in the same 16-byte line of code that ends with a test instruction, the two instructions should not be separated by any other instruction, ...).
The mechanism is called macro-fusion . For more information, including the exact conditions under which macro summation is applied, see the Agner Fog manual, page 82.
source share