[fpc-devel] x86 TEST instruction

J. Gareth Moreton gareth at moreton-family.com
Thu Jun 30 13:08:30 CEST 2022

Yeah, I just realised I was pretty silly to miss that! I must be more 
tired than I thought!

The reason why I brought it up is because I found an upgrade to the 
"MovAndTest2Test" optimisation where you might have something like "movl 
%eax,(memory); andl $1,%eax; testb %al;%al" (Yes, that code sequence 
does get generated sometimes) and it can be simplified to just "testb 
$1,(memory)", reading only 1 byte instead of all 4 (the AND instruction 
would have masked out the upper 3 bytes).

Gareth aka. Kit

On 30/06/2022 11:52, Thorsten Otto via fpc-devel wrote:
> On Montag, 27. Juni 2022 04:43:46 CEST J. Gareth Moreton via fpc-devel 
> wrote:
> > testl $1,%ebx -> testb $1,%bl
> Obviously, thats not the same. The latter will only compare the 
> least-significant byte against 1, and ignore the rest of the register. 
> The former will also compare the remainder of the register against 
> zero. SO you canot do such "optimizations"
> _______________________________________________
> fpc-devel maillist  -fpc-devel at lists.freepascal.org
> https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

This email has been checked for viruses by Avast antivirus software.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20220630/6faf3c95/attachment.htm>

More information about the fpc-devel mailing list