Conceivably there's a benefit when you can't load the value you want in one instruction (e.g. on many RISC architectures with fixed 32-bit instructions you can't have a 32-bit immediate)
for example on Alpha the most general way to load an arbitrary unsigned 32-bit value is
since it knows the original LDAH will be shared by either of the new values, it can save an instruction on each path.
And so, conceivably, if another thread changed the high 16 bits of x->y between the original store and the load before the comparison, we could observe a mixed value.
Of course, you'd have to create a condition where the compiler writes r22 back to memory and then loads it again but assumes the loaded value is still >= 65536 and < 131072.
Is this contrived? Absolutely. Is it _plausible_? Maybe.
―
Disclaimer: I've never used an Alpha in my life. This is all inferred from Raymond Chen's really amazing series about processors that Windows NT used to support. [0]
for example on Alpha the most general way to load an arbitrary unsigned 32-bit value is
Suppose you have code that toggles some value in memory between, say, 65537 and 65538, e.g. Conceivably, the compiler could emit for the first load, write it to shared memory and reload it later, and then for the comparison could emit since it knows the original LDAH will be shared by either of the new values, it can save an instruction on each path.And so, conceivably, if another thread changed the high 16 bits of x->y between the original store and the load before the comparison, we could observe a mixed value.
Of course, you'd have to create a condition where the compiler writes r22 back to memory and then loads it again but assumes the loaded value is still >= 65536 and < 131072.
Is this contrived? Absolutely. Is it _plausible_? Maybe.
―
Disclaimer: I've never used an Alpha in my life. This is all inferred from Raymond Chen's really amazing series about processors that Windows NT used to support. [0]
[0] https://devblogs.microsoft.com/oldnewthing/20170807-00/?p=96...