| ▲ | rokob 3 hours ago | |
Have you considered what happens in the presence of multiple threads? I know aarch is weakly memory ordered but the assembly output by those two versions is quite different when multiple threads are involved. There must be a reason spreading the mutations across multiple lines causes the compiler to pessimize to the branch version. Edit: not saying they are different just that it is harder for the compiler to see the safety of the transform when they are quite different. | ||
| ▲ | wat10000 an hour ago | parent [-] | |
The compiler doesn’t have to consider how other threads will see this. If you don’t use atomics, the compiler is free to reorder things however it wishes as long as the single threaded behavior is the same in the end. | ||