Re: [fpc-devel] Producing assembly with less branches?

2020-07-21 Thread J. Gareth Moreton
It might still be possible to detect some patterns cheaply - I'l see what I can come up with. Also, any successful reduction in the number of passes in the peephole optimizer will result in a speed-up that may offset any expensive checks (and the most expensive ones can be reserved for -O3 and

Re: [fpc-devel] Producing assembly with less branches?

2020-07-20 Thread Florian Klämpfl
Am 19.07.20 um 23:37 schrieb Stefan Glienke: Still kinda disappointing compared to what it could be - while this is some simple code a modern compiler should try to eliminate conditional jumps even with the incredibly powerful branch predictors nowadays. clang and gcc emit this - I would guess

Re: [fpc-devel] Producing assembly with less branches?

2020-07-19 Thread Stefan Glienke
Am 20.07.2020 um 02:37 schrieb J. Gareth Moreton: On 19/07/2020 22:37, Stefan Glienke wrote: clang and gcc emit this - I would guess they detect quite some common patterns like this.  ...   cmp eax, edx   mov edx, -1   setg    al   movzx   eax, al   cmovl   eax, edx   ret I think I

Re: [fpc-devel] Producing assembly with less branches?

2020-07-19 Thread J. Gareth Moreton
On 19/07/2020 22:37, Stefan Glienke wrote: clang and gcc emit this - I would guess they detect quite some common patterns like this.  ...   cmp eax, edx   mov edx, -1   setg    al   movzx   eax, al   cmovl   eax, edx   ret I think I can make improvements to that already! (Note the se

Re: [fpc-devel] Producing assembly with less branches?

2020-07-19 Thread Stefan Glienke
- Reply to message - Subject: [fpc-devel] Producing assembly with less branches? From: Stefan Glienke To: Hi, not sure if anything significantly changed in trunk compared to 3.2 wrt to optimized code being generated but I am quite disappointed that fpc (checked win64 with -O3 and

Re: [fpc-devel] Producing assembly with less branches?

2020-07-19 Thread Florian Klämpfl
Am 19.07.20 um 19:24 schrieb Stefan Glienke: Hi, not sure if anything significantly changed in trunk compared to 3.2 wrt to optimized code being generated but I am quite disappointed that fpc (checked win64 with -O3 and -O4) does not use cmovxx instructions and alike for the most basic things

Re: [fpc-devel] Producing assembly with less branches?

2020-07-19 Thread Marģers . via fpc-devel
- Reply to message - Subject: [fpc-devel] Producing assembly with less branches? From: Stefan Glienke To: > Hi, > not sure if anything significantly changed in trunk compared to 3.2 wrt > to optimized code being generated but I am quite disappointed that fpc > (checked wi

[fpc-devel] Producing assembly with less branches?

2020-07-19 Thread Stefan Glienke
Hi, not sure if anything significantly changed in trunk compared to 3.2 wrt to optimized code being generated but I am quite disappointed that fpc (checked win64 with -O3 and -O4) does not use cmovxx instructions and alike for the most basic things and produces terrible code like this: unit1