1 ; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64 -mattr=+lse -O0 | FileCheck %s
2 ; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64 -mattr=+lse -O1 | FileCheck %s
4 ; When their destination register is WZR/ZZR, SWP operations are not regarded as
5 ; a read for the purpose of a DMB.LD in the AArch64 memory model.
6 ; This test ensures that the AArch64DeadRegisterDefinitions pass does not
7 ; replace the desitnation register of SWP instructions with the zero register
8 ; when the read value is unused.
10 define dso_local i32 @atomic_exchange_monotonic(ptr %ptr, ptr %ptr2, i32 %value) {
11 ; CHECK-LABEL: atomic_exchange_monotonic:
15 ; CHECK-NEXT: dmb ishld
16 ; CHECK-NEXT: ldr w0, [x1]
18 %r0 = atomicrmw xchg ptr %ptr, i32 %value monotonic
20 %r1 = load atomic i32, ptr %ptr2 monotonic, align 4
24 define dso_local i32 @atomic_exchange_acquire(ptr %ptr, ptr %ptr2, i32 %value) {
25 ; CHECK-LABEL: atomic_exchange_acquire:
29 ; CHECK-NEXT: dmb ishld
30 ; CHECK-NEXT: ldr w0, [x1]
32 %r0 = atomicrmw xchg ptr %ptr, i32 %value acquire
34 %r1 = load atomic i32, ptr %ptr2 monotonic, align 4
38 define dso_local i32 @atomic_exchange_release(ptr %ptr, ptr %ptr2, i32 %value) {
39 ; CHECK-LABEL: atomic_exchange_release:
43 ; CHECK-NEXT: dmb ishld
44 ; CHECK-NEXT: ldr w0, [x1]
46 %r0 = atomicrmw xchg ptr %ptr, i32 %value release
48 %r1 = load atomic i32, ptr %ptr2 monotonic, align 4
52 define dso_local i32 @atomic_exchange_acquire_release(ptr %ptr, ptr %ptr2, i32 %value) {
53 ; CHECK-LABEL: atomic_exchange_acquire_release:
57 ; CHECK-NEXT: dmb ishld
58 ; CHECK-NEXT: ldr w0, [x1]
60 %r0 = atomicrmw xchg ptr %ptr, i32 %value acq_rel
62 %r1 = load atomic i32, ptr %ptr2 monotonic, align 4