Register variables and optimizations for x86_64 lazarus / 67-Windows ---------------------------------------------------------------------- 440bx · 2018-11-29 16:38 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. ---------------------------------------------------------------------- Nitorami · 2018-11-29 17:10 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 · 2018-11-29 17:33 Quote from: Nitorami on November 29, 2018, 06:10:28 pmI 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.