Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2008-11

(patch) optimized 32 to 64 bits multiplication for i386

4 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Sergei Gorelkin

Hello,

The attached patch implements i386-specific codegeneration for 32 -> 64 bits multiplications, approximately as described in "FPC HowToDo" wiki page. I also copied the generic part from tcgaddnode into ti386addnode.second_mul, so that all multiplications are handled in a single procedure. Although there was no absolute need to do that, it makes the code easier to understand.

Regards,
Sergei

Reply by email

Jonas Maebe
to Sergei Gorelkin
Sergei Gorelkin wrote
The attached patch implements i386-specific codegeneration for 32 -> 64 bits multiplications, approximately as described in "FPC HowToDo" wiki page.

Thanks!

I also copied the generic part from tcgaddnode into ti386addnode.second_mul, so that all multiplications are handled in a single procedure. Although there was no absolute need to do that, it makes the code easier to understand.

Could you rewrite it so it does not do that? I have already fixed several times in the past code generator bugs which were fixed for one architecture but not for another (or not in the generic code) exactly due to this sort of duplication.

Thanks,

Jonas

Reply by email

Sergei Gorelkin
to Jonas Maebe
Jonas Maebe wrote 5 lines
Could you rewrite it so it does not do that? I have already fixed several times in the past code generator bugs which were fixed for one architecture but not for another (or not in the generic code) exactly due to this sort of duplication.

Done, attached is a modified patch witout duplication.

Regards,
Sergei

Reply by email

Jonas Maebe
to Sergei Gorelkin
Sergei Gorelkin wrote 7 lines
Jonas Maebe wrote: > Could you rewrite it so it does not do that? I have already fixed > several times in the past code generator bugs which were fixed for > one architecture but not for another (or not in the generic code) > exactly due to this sort of duplication. Done, attached is a modified patch witout duplication.

Thanks, comment with one small change: you cannot first release both EDX and EAX, then allocate 2 new registers and move EDX and EAX into them. The reason is that in this case the first allocated register may be mapped to EAX by the register allocator, so you can get this in the end:

movl %edx, %eax
movl %eax, %ecx

or even

movl %edx, %eax
movl %eax, %edx

Jonas

Reply by email