Recent

Author Topic: Register variables and optimizations for x86_64  (Read 3217 times)

440bx

  • Hero Member
  • *****
  • Posts: 3945
Register variables and optimizations for x86_64
« on: November 29, 2018, 05:38:24 pm »
Hello,

I'd like to tell FPC to place one or more variables in registers. Is this possible and if so how ?

The other question I have is, is it possible to tell the compiler to optimize for the x86_64 architecture ?... those CPUs/mode have more registers available that the compiler can use to optimize code. 

I tried -Or but, it didn't seem to have any effect  (maybe I missed something else though)

Basically, what's the "magic" switch sauce that will produce the best possible code (tight and fast) for Windows 64bit applications ?

Thank you for your help.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

Nitorami

  • Sr. Member
  • ****
  • Posts: 481
Re: Register variables and optimizations for x86_64
« Reply #1 on: November 29, 2018, 06:10:28 pm »
I would expect that with -OoREGVAR set, fpc uses registers for optimizing function calls. This does make a noticeable difference to me when calling procedures in tight loops.
You may also tell the compiler to additionally use EBP and RBP, see here
http://wiki.freepascal.org/Optimization.
Regarding these, I did not notice any difference so far in my programs, but I guess any effects may be very code specific.

440bx

  • Hero Member
  • *****
  • Posts: 3945
Re: Register variables and optimizations for x86_64
« Reply #2 on: November 29, 2018, 06:33:06 pm »
I would expect that with -OoREGVAR set, fpc uses registers for optimizing function calls. This does make a noticeable difference to me when calling procedures in tight loops.

I'll give that -OoREGVAR a try.  Thank you for the suggestion.

I wish there was a way to tell the compiler to put a specific variable (or variables) in a register.  There are times when that would not only make the code faster but also, a good bit smaller.
(FPC v3.0.4 and Lazarus 1.8.2) or (FPC v3.2.2 and Lazarus v3.2) on Windows 7 SP1 64bit.

 

TinyPortal © 2005-2018