[fpc-devel] x86 TEST instruction

J. Gareth Moreton gareth at moreton-family.com
Mon Jun 27 04:43:46 CEST 2022

Hi everyone,

I'm playing around with a peephole optimization (back to my roots!) and 
I've come across a relatively simple one that aims to reduce instruction 
size occasionally.  One part involves reducing the opsize if the 
constant is numeric.  For example:

testl    $17,76(%rcx) -> testb $17,76(%rcx)


testl    $1,%ebx -> testb    $1,%bl

Obviously I check to make sure the constant fits into the smaller size.  
Is there a time when this is NOT recommended?  I'm trying to remember 
issues with partial register or memory writes, but in this case, it's 
just a partial read.

Gareth aka. Kit

This email has been checked for viruses by Avast antivirus software.

More information about the fpc-devel mailing list