[fpc-devel] x86_64 question

Nikolay Nikolov nickysn at gmail.com
Thu Oct 1 20:43:51 CEST 2020


On 10/1/20 8:17 PM, J. Gareth Moreton via fpc-devel wrote:
> Hi everyone,
>
> I have a small question with assembler size optimisation that maybe 
> one of you guys can give me a second opinion on:
>
> If you are using the "test" instruction to test some of the lower bits 
> of an instruction, e.g. TEST RCX, $2, is there a penalty with calling 
> TEST CL, $2 instead? The instruction size is a lot smaller on account 
> of the immediate only being 1 byte long instead of 4 bytes, and are 
> mathematically equivalent.  I know you have to be careful with partial 
> write penalties, but partial reads seem to be a bit more nebulous (the 
> register is not modified with TEST).

Yes, I think the shorter TEST CL, $2 is preferred over TEST RCX, $2 on 
every x86_64 CPU. AFAIK, there's no penalty for using 8-bit subregisters 
(except perhaps AH, BH, CH and DH, but the FPC code generator doesn't 
use them). Others can correct me if I'm wrong.

Nikolay



More information about the fpc-devel mailing list