Re: [fpc-devel] x86 TEST instruction

2022-06-30 Thread Stefan Glienke via fpc-devel
Both clang and gcc seem to do this > On 30/06/2022 17:28 CEST J. Gareth Moreton via fpc-devel > wrote: > > > This was what I was working on: > > https://gitlab.com/freepascal.org/fpc/source/-/merge_requests/252 > > The same question applies regarding the TEST instruction, but it's a > litt

Re: [fpc-devel] x86 TEST instruction

2022-06-30 Thread J. Gareth Moreton via fpc-devel
This was what I was working on: https://gitlab.com/freepascal.org/fpc/source/-/merge_requests/252 The same question applies regarding the TEST instruction, but it's a little more restrictive in this instance in that it's determined that the program doesn't care about the upper bytes of the reg

Re: [fpc-devel] x86 TEST instruction

2022-06-30 Thread J. Gareth Moreton via fpc-devel
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 s

Re: [fpc-devel] x86 TEST instruction

2022-06-30 Thread Thorsten Otto via fpc-devel
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

Re: [fpc-devel] x86 TEST instruction

2022-06-30 Thread Marc Weustink via fpc-devel
On 27-6-2022 04:43, J. Gareth Moreton via fpc-devel wrote: 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

[fpc-devel] x86 TEST instruction

2022-06-26 Thread J. Gareth Moreton via fpc-devel
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