This was reverted in https://github.com/llvm/llvm-project/pull/110969 due to a failure on aarch64. Weirdly aarch64 (but apparently not x86?) has a spurious phi instruction. flang -fc1 -emit-llvm will run midle-end optimization passes. Presumably one of those is behaving differently on different targets. I have adapted the test to work correctly on aarch64. The difference is in the RUN lines and the atomic exit block.