[fpc-devel] TFPHashList (Was: Alternative parsers)

Dariusz Mazur darekm at emadar.com
Sat Oct 23 23:40:19 CEST 2010


  W dniu 2010-10-23 23:04, Florian Klämpfl pisze:
>>
>>>> Second: when I review assembler list I've notice some strange lines (all
>>>> optimizations are enabled):
>>>>
>>> Which compiler version? 2.4.x? I think r15502 in trunk should fix this.
>> 2.5.1 but older. Now I test from current. Its better (faster) but  I
>> found other strange:
>>
>> first: dec(i) is translate to three lines
>>      movl    %esi,%eax
>>      decl    %eax
>>      movl    %eax,%esi
>>
>> why not simple decl %esi ?
> Yes. I saw this too and I didn't find the cause, especially because I
> were not able to reproduce it in a small example.

attached before uhlm.pas is too long? its form fpHash

>> When variable is in %ebx things are the same.
>>
>>
>> second  if I have:
>>    while ii>0 do begin
>>       ....;
>>     dec(ii);
>>
>>
>> assembler look:
>>
>>
>> # [121] while ii>0 do begin
>>      jmp    .Lj16  //<   here add first test of ii
>>      .balign 4,0x90
>> .Lj15:
>> .Ll8:
>> # [122] result:=LongWord(result *8010817  ) xor (Pw^);
>> .Ll10:
>> # [124] dec(ii);
>>      movl    %esi,%eax
>>      decl    %eax
>>      movl    %eax,%esi
>> .Lj16:
>>      testl    %esi,%esi    //<--  this can be avoid, because test from DECL
>>      jg    .Lj15
>>
>>
>> Is this possible to achieve this optimizations,
>> If yes, can somebody help, from which file I should start
>>
> Replacing the jmp by a test and jz is two-fold: it increases code size
> (thus higher code cache pollution) and it pollutes the branch prediction
> unit while an uncoditional jump is very cheap on modern processers.

You don't understand me
My proposition is moving one instruction, outside loop

# [121] while ii>0 do begin
     testl    %esi,%esi    //<--  this should be added, because after .Lj16 test is absent
     jmp    .Lj16   // jmp not change ZF
.balign 4,0x90
.Lj15:
.Ll8:
# [122] result:=LongWord(result *8010817  ) xor (Pw^);
.Ll10:
# [124] dec(ii);
     decl    %esi
.Lj16:
     jg    .Lj15 // ZF is setting by decl (first timie by testl)





-- 
   Darek







More information about the fpc-devel mailing list