Hello, ARMv8.1 adds atomic swap and atomic load-operate instructions with optional memory ordering specifiers. This patch uses the ARMv8.1 load-operate instructions to implement the atomic__fetch patterns. The approach is to use the atomic load-operate instruction to atomically load the data and update memory and then to use the loaded data to calculate the value that the instruction would have stored. The calculation attempts to mirror the operation of the atomic instruction. For example, atomic_and_fetch is implemented with an atomic load-bic so the result is also calculated using a BIC instruction. The general form of the code generated for an atomic__fetch, with destination D, source S, memory address A and memory order MO, depends on whether or not the operation is directly supported by the instruction. If is one of PLUS, IOR or XOR, the code generated is: ld S, D, [A] D, D, S where is one {add, set, eor} is one of {add, orr, xor} is one of {'', 'a', 'l', 'al'} depending on memory order MO. is one of {'', 'b', 'h'} depending on the data size. If is SUB, the code generated is: neg S, S ldadd S, D, [A] add D, D, S If is AND, the code generated is: not S, S ldclr S, D, [A] bic D, S, S Any operation not in {PLUS, IOR, XOR, SUB, AND} is passed to the existing aarch64_split_atomic_op function, to implement the operation using sequences built with the ARMv8 load-exclusive/store-exclusive instructions Tested the series for aarch64-none-linux-gnu with native bootstrap and make check. Also tested for aarch64-none-elf with cross-compiled check-gcc on an ARMv8.1 emulator with +lse enabled by default. Ok for trunk? Matthew 2015-09-17 Matthew Wahab * config/aarch64/aarch64-protos.h (aarch64_gen_atomic_ldop): Adjust declaration. * config/aarch64/aarch64.c (aarch64_emit_bic): New. (aarch64_gen_atomic_load_op): Adjust comment. Add parameter out_result. Update to support update-fetch operations. * config/aarch64/atomics.md (aarch64_atomic_exchange_lse): Adjust for change to aarch64_gen_atomic_ldop. (aarch64_atomic__lse): Likewise. (aarch64_atomic_fetch__lse): Likewise. (atomic__fetch): Change to an expander. (aarch64_atomic__fetch): New. (aarch64_atomic__fetch_lse): New. gcc/testsuite 2015-09-17 Matthew Wahab * gcc.target/aarch64/atomic-inst-ldadd.c: Add tests for update-fetch operations. * gcc.target/aarch64/atomic-inst-ldlogic.c: Likewise.