On Fri, 12 Nov 2021, J. Gareth Moreton via fpc-devel wrote:
Hi everyone,
I have a question when it comes to optimising memory reads and writes.
What are the rules for FPC when it comes to writing to memory and then
reading from it later within a single subroutine? For example, say I had
this pair of commands:
movq %rdx,-584(%rbp)
movl -584(%rbp),%eax
That could easily be converted to "movl %edx,%eax", especially as %rbp
is likely pointing to the top of the stack. But if the reference uses
different registers, would it still be safe to make this optimisation
given that the scheduler could suspend the thread in between the two
instructions and then another thread writes to the same memory block
before control is returned?
The user is responsible for synchronizing between threads, so I don't think
the compiler needs to take this into account ?
Michael.
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel