This is my first stab at disallowing load data races that happen when we cache the value of a global. I would appreciate input before committing, especially on the RTL bits, cause it's been quite a while since I typed d-e-b-u-g-_-r-t-x. :-) In the example below we usually hoist "global" into a register or temporary to avoid reading from it at each step. This would cause a race if another thread had modified "global" in between iterations. for (x=0; x< 5; x++) sum[x] = global; As expected, multiple passes can cause the same end result, so plugging the problem involves multiple places. First, loop invariant movement moves the invariant. Barring that, PRE moves the load, and even if we get past the SSA passes, rtl-CSE pulls the rug from under us. If that weren't enough, the post-reload pass performs CSE over the hard registers, and we end up eliminating subsequent loads of "global". I am sure there are many other places, but I'm starting with whatever it takes to fix gcc.dg/memmodel/global-hoist.c. The patch below fixes the test in question with "--param allow-load-data-races=0". What do y'all think? Thanks.