Hello,
> One thing I have been considering is to promote fields and global variables to local registers to reduce memory accesses.
That would be great. But multithreaded code which assume (incorrectly) that those fields and globals are in memory may be broken.
Other languages don't allow to assume anything about such entities in multithreaded code.
From the other side, such languages do have a memory model which tells when a assignment result will become visible to other threads (if ever).
> However, it would make multi-threaded code a bit trickier to write and demand the use of the "volatile" intrinsic on things like the conditions of while loops.
Volatile (I assume you mean a C-like volatile) is usable in very rare special cases. Such as work with hardware buffers.
In optimization sphere FPC can be improved in many ways. For example, expressions like: x + y * Ord(x > y)
FPC 3.0.4 does use IMUL instruction. But it can be compiled much more effective with cmov:
cmp edi, esi
mov eax, 0
cmovle esi, eax
add edi, esi
https://godbolt.org/z/Cf-AQE
Don't know how hard is to implement such oiptimization though.
---
Best regards, George
_______________________________________________ fpc-devel maillist - [email protected] https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
