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.pas:49 if left < right then 000000010002E3C0 39ca cmp edx,ecx 000000010002E3C2 7e06 jle 0x10002e3ca <COMPAREINT+10> unit1.pas:50 Result := -1 000000010002E3C4 b8ffffffff mov eax,0xffffffff 000000010002E3C9 c3 ret unit1.pas:51 else if left > right then 000000010002E3CA 39ca cmp edx,ecx 000000010002E3CC 7d06 jge 0x10002e3d4 <COMPAREINT+20> unit1.pas:52 Result := 1 000000010002E3CE b801000000c3 mov eax,0x1 unit1.pas:54 Result := 0; 000000010002E3D4 31c0 xor eax,eax unit1.pas:55 end; 000000010002E3D6 c3 ret
Similar for even simpler things:
unit1.pas:43 if i < 0 then 000000010002E3A1 85c0 test eax,eax 000000010002E3A3 7d03 jge 0x10002e3a8 <BUTTON1CLICK+72>
unit1.pas:44 i := 0; 000000010002E3A5 31c0 xor eax,eax 000000010002E3A7 90 nop
Imo someone should work at that and make the compiler produce less branches. Not sure if that is on your list but it should be looked at.
