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.
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.