3 ms·
Relaxed ordering impacts the compiler. There are a number of optimizations it cannot make. I am not sure exactly what those are, but it is measurable.
by carllerche 7y ago
Relaxed ordering impacts the compiler. There are a number of optimizations it cannot make. I am not sure exactly what those are, but it is measurable.
- dunkelheit 7y agoProbably some reordering? Would be interesting to compare generated assembly.
- carllerche 7y agoI believe there are some LLVM "bugs" with regards to Relaxed ordering. I don't know the specifics.
- CodesInChaos 7y agoThe only forbidden optimization I could come up with is: x = load-relaxed(a) ... f(x) cannot be turned into x0 = load-relaxed(a) ... x1 = load-relaxed(a) f(x1) while this would be possible with normal memory access. so under register pressure the compiler would be required to spill something onto the stack instead of just reloading `x` from the original location.
- carllerche 7y agoLast time I spoke about this topic w/ the rust compiler devs, they mentioned there were some LLVM "bugs" with regards to optimizations and Relaxed, as in LLVM is too conservative.