[llvm] 5a9cb37 - [AArch64] Add atomics tests for lse2+lse128
Tomas Matheson via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 30 03:40:42 PST 2023
Author: Tomas Matheson
Date: 2023-01-30T11:36:12Z
New Revision: 5a9cb377228b5465d343a1af0f088a09c2e098d7
URL: https://github.com/llvm/llvm-project/commit/5a9cb377228b5465d343a1af0f088a09c2e098d7
DIFF: https://github.com/llvm/llvm-project/commit/5a9cb377228b5465d343a1af0f088a09c2e098d7.diff
LOG: [AArch64] Add atomics tests for lse2+lse128
FEAT_LSE128 implies FEAT_LSE but not FEAT_LSE2, so add tests showing
what happens when you have both.
Differential Revision: https://reviews.llvm.org/D142712
Added:
llvm/test/CodeGen/AArch64/Atomics/aarch64-atomic-load-lse2_lse128.ll
llvm/test/CodeGen/AArch64/Atomics/aarch64-atomic-store-lse2_lse128.ll
llvm/test/CodeGen/AArch64/Atomics/aarch64-atomicrmw-lse2_lse128.ll
llvm/test/CodeGen/AArch64/Atomics/aarch64-cmpxchg-lse2_lse128.ll
llvm/test/CodeGen/AArch64/Atomics/aarch64_be-atomic-load-lse2_lse128.ll
llvm/test/CodeGen/AArch64/Atomics/aarch64_be-atomic-store-lse2_lse128.ll
llvm/test/CodeGen/AArch64/Atomics/aarch64_be-atomicrmw-lse2_lse128.ll
llvm/test/CodeGen/AArch64/Atomics/aarch64_be-cmpxchg-lse2_lse128.ll
Modified:
llvm/test/CodeGen/AArch64/Atomics/aarch64-fence.ll
llvm/test/CodeGen/AArch64/Atomics/aarch64_be-fence.ll
llvm/test/CodeGen/AArch64/Atomics/generate-tests.py
Removed:
################################################################################
diff --git a/llvm/test/CodeGen/AArch64/Atomics/aarch64-atomic-load-lse2_lse128.ll b/llvm/test/CodeGen/AArch64/Atomics/aarch64-atomic-load-lse2_lse128.ll
new file mode 100644
index 000000000000..2f030b0e23ab
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/Atomics/aarch64-atomic-load-lse2_lse128.ll
@@ -0,0 +1,571 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --filter-out "\b(sp)\b" --filter "^\s*(ld|st[^r]|swp|cas|bl|add|and|eor|orn|orr|sub|mvn|sxt|cmp|ccmp|csel|dmb)"
+; The base test file was generated by ./llvm/test/CodeGen/AArch64/Atomics/generate-tests.py
+; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64 -mattr=+lse2,+lse128 -O0 | FileCheck %s --check-prefixes=CHECK,-O0
+; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64 -mattr=+lse2,+lse128 -O1 | FileCheck %s --check-prefixes=CHECK,-O1
+
+define dso_local i8 @load_atomic_i8_aligned_unordered(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i8_aligned_unordered:
+; CHECK: ldrb w0, [x0]
+ %r = load atomic i8, ptr %ptr unordered, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_aligned_unordered_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i8_aligned_unordered_const:
+; CHECK: ldrb w0, [x0]
+ %r = load atomic i8, ptr %ptr unordered, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_aligned_monotonic(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i8_aligned_monotonic:
+; CHECK: ldrb w0, [x0]
+ %r = load atomic i8, ptr %ptr monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_aligned_monotonic_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i8_aligned_monotonic_const:
+; CHECK: ldrb w0, [x0]
+ %r = load atomic i8, ptr %ptr monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_aligned_acquire(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i8_aligned_acquire:
+; CHECK: ldarb w0, [x0]
+ %r = load atomic i8, ptr %ptr acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_aligned_acquire_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i8_aligned_acquire_const:
+; CHECK: ldarb w0, [x0]
+ %r = load atomic i8, ptr %ptr acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_aligned_seq_cst(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i8_aligned_seq_cst:
+; CHECK: ldarb w0, [x0]
+ %r = load atomic i8, ptr %ptr seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_aligned_seq_cst_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i8_aligned_seq_cst_const:
+; CHECK: ldarb w0, [x0]
+ %r = load atomic i8, ptr %ptr seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @load_atomic_i16_aligned_unordered(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i16_aligned_unordered:
+; CHECK: ldrh w0, [x0]
+ %r = load atomic i16, ptr %ptr unordered, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_aligned_unordered_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i16_aligned_unordered_const:
+; CHECK: ldrh w0, [x0]
+ %r = load atomic i16, ptr %ptr unordered, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_aligned_monotonic(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i16_aligned_monotonic:
+; CHECK: ldrh w0, [x0]
+ %r = load atomic i16, ptr %ptr monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_aligned_monotonic_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i16_aligned_monotonic_const:
+; CHECK: ldrh w0, [x0]
+ %r = load atomic i16, ptr %ptr monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_aligned_acquire(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i16_aligned_acquire:
+; CHECK: ldarh w0, [x0]
+ %r = load atomic i16, ptr %ptr acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_aligned_acquire_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i16_aligned_acquire_const:
+; CHECK: ldarh w0, [x0]
+ %r = load atomic i16, ptr %ptr acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_aligned_seq_cst(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i16_aligned_seq_cst:
+; CHECK: ldarh w0, [x0]
+ %r = load atomic i16, ptr %ptr seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_aligned_seq_cst_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i16_aligned_seq_cst_const:
+; CHECK: ldarh w0, [x0]
+ %r = load atomic i16, ptr %ptr seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i32 @load_atomic_i32_aligned_unordered(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i32_aligned_unordered:
+; CHECK: ldr w0, [x0]
+ %r = load atomic i32, ptr %ptr unordered, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_aligned_unordered_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i32_aligned_unordered_const:
+; CHECK: ldr w0, [x0]
+ %r = load atomic i32, ptr %ptr unordered, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_aligned_monotonic(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i32_aligned_monotonic:
+; CHECK: ldr w0, [x0]
+ %r = load atomic i32, ptr %ptr monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_aligned_monotonic_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i32_aligned_monotonic_const:
+; CHECK: ldr w0, [x0]
+ %r = load atomic i32, ptr %ptr monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_aligned_acquire(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i32_aligned_acquire:
+; CHECK: ldar w0, [x0]
+ %r = load atomic i32, ptr %ptr acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_aligned_acquire_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i32_aligned_acquire_const:
+; CHECK: ldar w0, [x0]
+ %r = load atomic i32, ptr %ptr acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_aligned_seq_cst(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i32_aligned_seq_cst:
+; CHECK: ldar w0, [x0]
+ %r = load atomic i32, ptr %ptr seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_aligned_seq_cst_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i32_aligned_seq_cst_const:
+; CHECK: ldar w0, [x0]
+ %r = load atomic i32, ptr %ptr seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i64 @load_atomic_i64_aligned_unordered(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i64_aligned_unordered:
+; CHECK: ldr x0, [x0]
+ %r = load atomic i64, ptr %ptr unordered, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_aligned_unordered_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i64_aligned_unordered_const:
+; CHECK: ldr x0, [x0]
+ %r = load atomic i64, ptr %ptr unordered, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_aligned_monotonic(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i64_aligned_monotonic:
+; CHECK: ldr x0, [x0]
+ %r = load atomic i64, ptr %ptr monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_aligned_monotonic_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i64_aligned_monotonic_const:
+; CHECK: ldr x0, [x0]
+ %r = load atomic i64, ptr %ptr monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_aligned_acquire(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i64_aligned_acquire:
+; CHECK: ldar x0, [x0]
+ %r = load atomic i64, ptr %ptr acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_aligned_acquire_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i64_aligned_acquire_const:
+; CHECK: ldar x0, [x0]
+ %r = load atomic i64, ptr %ptr acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_aligned_seq_cst(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i64_aligned_seq_cst:
+; CHECK: ldar x0, [x0]
+ %r = load atomic i64, ptr %ptr seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_aligned_seq_cst_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i64_aligned_seq_cst_const:
+; CHECK: ldar x0, [x0]
+ %r = load atomic i64, ptr %ptr seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i128 @load_atomic_i128_aligned_unordered(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i128_aligned_unordered:
+; CHECK: ldp x0, x1, [x0]
+ %r = load atomic i128, ptr %ptr unordered, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_aligned_unordered_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i128_aligned_unordered_const:
+; CHECK: ldp x0, x1, [x0]
+ %r = load atomic i128, ptr %ptr unordered, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_aligned_monotonic(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i128_aligned_monotonic:
+; CHECK: ldp x0, x1, [x0]
+ %r = load atomic i128, ptr %ptr monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_aligned_monotonic_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i128_aligned_monotonic_const:
+; CHECK: ldp x0, x1, [x0]
+ %r = load atomic i128, ptr %ptr monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_aligned_acquire(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i128_aligned_acquire:
+; CHECK: ldp x0, x1, [x0]
+; CHECK: dmb ishld
+ %r = load atomic i128, ptr %ptr acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_aligned_acquire_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i128_aligned_acquire_const:
+; CHECK: ldp x0, x1, [x0]
+; CHECK: dmb ishld
+ %r = load atomic i128, ptr %ptr acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_aligned_seq_cst(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i128_aligned_seq_cst:
+; CHECK: ldp x0, x1, [x0]
+; CHECK: dmb ish
+ %r = load atomic i128, ptr %ptr seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_aligned_seq_cst_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i128_aligned_seq_cst_const:
+; CHECK: ldp x0, x1, [x0]
+; CHECK: dmb ish
+ %r = load atomic i128, ptr %ptr seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i8 @load_atomic_i8_unaligned_unordered(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i8_unaligned_unordered:
+; CHECK: ldrb w0, [x0]
+ %r = load atomic i8, ptr %ptr unordered, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_unaligned_unordered_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i8_unaligned_unordered_const:
+; CHECK: ldrb w0, [x0]
+ %r = load atomic i8, ptr %ptr unordered, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_unaligned_monotonic(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i8_unaligned_monotonic:
+; CHECK: ldrb w0, [x0]
+ %r = load atomic i8, ptr %ptr monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_unaligned_monotonic_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i8_unaligned_monotonic_const:
+; CHECK: ldrb w0, [x0]
+ %r = load atomic i8, ptr %ptr monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_unaligned_acquire(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i8_unaligned_acquire:
+; CHECK: ldarb w0, [x0]
+ %r = load atomic i8, ptr %ptr acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_unaligned_acquire_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i8_unaligned_acquire_const:
+; CHECK: ldarb w0, [x0]
+ %r = load atomic i8, ptr %ptr acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_unaligned_seq_cst(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i8_unaligned_seq_cst:
+; CHECK: ldarb w0, [x0]
+ %r = load atomic i8, ptr %ptr seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_unaligned_seq_cst_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i8_unaligned_seq_cst_const:
+; CHECK: ldarb w0, [x0]
+ %r = load atomic i8, ptr %ptr seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @load_atomic_i16_unaligned_unordered(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i16_unaligned_unordered:
+; CHECK: bl __atomic_load
+ %r = load atomic i16, ptr %ptr unordered, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_unaligned_unordered_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i16_unaligned_unordered_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i16, ptr %ptr unordered, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_unaligned_monotonic(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i16_unaligned_monotonic:
+; CHECK: bl __atomic_load
+ %r = load atomic i16, ptr %ptr monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_unaligned_monotonic_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i16_unaligned_monotonic_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i16, ptr %ptr monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_unaligned_acquire(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i16_unaligned_acquire:
+; CHECK: bl __atomic_load
+ %r = load atomic i16, ptr %ptr acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_unaligned_acquire_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i16_unaligned_acquire_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i16, ptr %ptr acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_unaligned_seq_cst(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i16_unaligned_seq_cst:
+; CHECK: bl __atomic_load
+ %r = load atomic i16, ptr %ptr seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_unaligned_seq_cst_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i16_unaligned_seq_cst_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i16, ptr %ptr seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i32 @load_atomic_i32_unaligned_unordered(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i32_unaligned_unordered:
+; CHECK: bl __atomic_load
+ %r = load atomic i32, ptr %ptr unordered, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_unaligned_unordered_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i32_unaligned_unordered_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i32, ptr %ptr unordered, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_unaligned_monotonic(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i32_unaligned_monotonic:
+; CHECK: bl __atomic_load
+ %r = load atomic i32, ptr %ptr monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_unaligned_monotonic_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i32_unaligned_monotonic_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i32, ptr %ptr monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_unaligned_acquire(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i32_unaligned_acquire:
+; CHECK: bl __atomic_load
+ %r = load atomic i32, ptr %ptr acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_unaligned_acquire_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i32_unaligned_acquire_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i32, ptr %ptr acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_unaligned_seq_cst(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i32_unaligned_seq_cst:
+; CHECK: bl __atomic_load
+ %r = load atomic i32, ptr %ptr seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_unaligned_seq_cst_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i32_unaligned_seq_cst_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i32, ptr %ptr seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i64 @load_atomic_i64_unaligned_unordered(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i64_unaligned_unordered:
+; CHECK: bl __atomic_load
+ %r = load atomic i64, ptr %ptr unordered, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_unaligned_unordered_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i64_unaligned_unordered_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i64, ptr %ptr unordered, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_unaligned_monotonic(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i64_unaligned_monotonic:
+; CHECK: bl __atomic_load
+ %r = load atomic i64, ptr %ptr monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_unaligned_monotonic_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i64_unaligned_monotonic_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i64, ptr %ptr monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_unaligned_acquire(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i64_unaligned_acquire:
+; CHECK: bl __atomic_load
+ %r = load atomic i64, ptr %ptr acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_unaligned_acquire_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i64_unaligned_acquire_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i64, ptr %ptr acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_unaligned_seq_cst(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i64_unaligned_seq_cst:
+; CHECK: bl __atomic_load
+ %r = load atomic i64, ptr %ptr seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_unaligned_seq_cst_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i64_unaligned_seq_cst_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i64, ptr %ptr seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i128 @load_atomic_i128_unaligned_unordered(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i128_unaligned_unordered:
+; CHECK: bl __atomic_load
+ %r = load atomic i128, ptr %ptr unordered, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_unaligned_unordered_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i128_unaligned_unordered_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i128, ptr %ptr unordered, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_unaligned_monotonic(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i128_unaligned_monotonic:
+; CHECK: bl __atomic_load
+ %r = load atomic i128, ptr %ptr monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_unaligned_monotonic_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i128_unaligned_monotonic_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i128, ptr %ptr monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_unaligned_acquire(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i128_unaligned_acquire:
+; CHECK: bl __atomic_load
+ %r = load atomic i128, ptr %ptr acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_unaligned_acquire_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i128_unaligned_acquire_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i128, ptr %ptr acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_unaligned_seq_cst(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i128_unaligned_seq_cst:
+; CHECK: bl __atomic_load
+ %r = load atomic i128, ptr %ptr seq_cst, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_unaligned_seq_cst_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i128_unaligned_seq_cst_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i128, ptr %ptr seq_cst, align 1
+ ret i128 %r
+}
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; -O0: {{.*}}
+; -O1: {{.*}}
diff --git a/llvm/test/CodeGen/AArch64/Atomics/aarch64-atomic-store-lse2_lse128.ll b/llvm/test/CodeGen/AArch64/Atomics/aarch64-atomic-store-lse2_lse128.ll
new file mode 100644
index 000000000000..9ba75708f7b7
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/Atomics/aarch64-atomic-store-lse2_lse128.ll
@@ -0,0 +1,290 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --filter-out "\b(sp)\b" --filter "^\s*(ld[^r]|st|swp|cas|bl|add|and|eor|orn|orr|sub|mvn|sxt|cmp|ccmp|csel|dmb)"
+; The base test file was generated by ./llvm/test/CodeGen/AArch64/Atomics/generate-tests.py
+; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64 -mattr=+lse2,+lse128 -O0 | FileCheck %s --check-prefixes=CHECK,-O0
+; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64 -mattr=+lse2,+lse128 -O1 | FileCheck %s --check-prefixes=CHECK,-O1
+
+define dso_local void @store_atomic_i8_aligned_unordered(i8 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i8_aligned_unordered:
+; CHECK: strb w0, [x1]
+ store atomic i8 %value, ptr %ptr unordered, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i8_aligned_monotonic(i8 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i8_aligned_monotonic:
+; CHECK: strb w0, [x1]
+ store atomic i8 %value, ptr %ptr monotonic, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i8_aligned_release(i8 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i8_aligned_release:
+; CHECK: stlrb w0, [x1]
+ store atomic i8 %value, ptr %ptr release, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i8_aligned_seq_cst(i8 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i8_aligned_seq_cst:
+; CHECK: stlrb w0, [x1]
+ store atomic i8 %value, ptr %ptr seq_cst, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i16_aligned_unordered(i16 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i16_aligned_unordered:
+; CHECK: strh w0, [x1]
+ store atomic i16 %value, ptr %ptr unordered, align 2
+ ret void
+}
+
+define dso_local void @store_atomic_i16_aligned_monotonic(i16 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i16_aligned_monotonic:
+; CHECK: strh w0, [x1]
+ store atomic i16 %value, ptr %ptr monotonic, align 2
+ ret void
+}
+
+define dso_local void @store_atomic_i16_aligned_release(i16 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i16_aligned_release:
+; CHECK: stlrh w0, [x1]
+ store atomic i16 %value, ptr %ptr release, align 2
+ ret void
+}
+
+define dso_local void @store_atomic_i16_aligned_seq_cst(i16 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i16_aligned_seq_cst:
+; CHECK: stlrh w0, [x1]
+ store atomic i16 %value, ptr %ptr seq_cst, align 2
+ ret void
+}
+
+define dso_local void @store_atomic_i32_aligned_unordered(i32 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i32_aligned_unordered:
+; CHECK: str w0, [x1]
+ store atomic i32 %value, ptr %ptr unordered, align 4
+ ret void
+}
+
+define dso_local void @store_atomic_i32_aligned_monotonic(i32 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i32_aligned_monotonic:
+; CHECK: str w0, [x1]
+ store atomic i32 %value, ptr %ptr monotonic, align 4
+ ret void
+}
+
+define dso_local void @store_atomic_i32_aligned_release(i32 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i32_aligned_release:
+; CHECK: stlr w0, [x1]
+ store atomic i32 %value, ptr %ptr release, align 4
+ ret void
+}
+
+define dso_local void @store_atomic_i32_aligned_seq_cst(i32 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i32_aligned_seq_cst:
+; CHECK: stlr w0, [x1]
+ store atomic i32 %value, ptr %ptr seq_cst, align 4
+ ret void
+}
+
+define dso_local void @store_atomic_i64_aligned_unordered(i64 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i64_aligned_unordered:
+; CHECK: str x0, [x1]
+ store atomic i64 %value, ptr %ptr unordered, align 8
+ ret void
+}
+
+define dso_local void @store_atomic_i64_aligned_monotonic(i64 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i64_aligned_monotonic:
+; CHECK: str x0, [x1]
+ store atomic i64 %value, ptr %ptr monotonic, align 8
+ ret void
+}
+
+define dso_local void @store_atomic_i64_aligned_release(i64 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i64_aligned_release:
+; CHECK: stlr x0, [x1]
+ store atomic i64 %value, ptr %ptr release, align 8
+ ret void
+}
+
+define dso_local void @store_atomic_i64_aligned_seq_cst(i64 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i64_aligned_seq_cst:
+; CHECK: stlr x0, [x1]
+ store atomic i64 %value, ptr %ptr seq_cst, align 8
+ ret void
+}
+
+define dso_local void @store_atomic_i128_aligned_unordered(i128 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i128_aligned_unordered:
+; CHECK: stp x0, x1, [x2]
+ store atomic i128 %value, ptr %ptr unordered, align 16
+ ret void
+}
+
+define dso_local void @store_atomic_i128_aligned_monotonic(i128 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i128_aligned_monotonic:
+; CHECK: stp x0, x1, [x2]
+ store atomic i128 %value, ptr %ptr monotonic, align 16
+ ret void
+}
+
+define dso_local void @store_atomic_i128_aligned_release(i128 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i128_aligned_release:
+; CHECK: dmb ish
+; CHECK: stp x0, x1, [x2]
+ store atomic i128 %value, ptr %ptr release, align 16
+ ret void
+}
+
+define dso_local void @store_atomic_i128_aligned_seq_cst(i128 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i128_aligned_seq_cst:
+; CHECK: dmb ish
+; CHECK: stp x0, x1, [x2]
+; CHECK: dmb ish
+ store atomic i128 %value, ptr %ptr seq_cst, align 16
+ ret void
+}
+
+define dso_local void @store_atomic_i8_unaligned_unordered(i8 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i8_unaligned_unordered:
+; CHECK: strb w0, [x1]
+ store atomic i8 %value, ptr %ptr unordered, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i8_unaligned_monotonic(i8 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i8_unaligned_monotonic:
+; CHECK: strb w0, [x1]
+ store atomic i8 %value, ptr %ptr monotonic, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i8_unaligned_release(i8 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i8_unaligned_release:
+; CHECK: stlrb w0, [x1]
+ store atomic i8 %value, ptr %ptr release, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i8_unaligned_seq_cst(i8 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i8_unaligned_seq_cst:
+; CHECK: stlrb w0, [x1]
+ store atomic i8 %value, ptr %ptr seq_cst, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i16_unaligned_unordered(i16 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i16_unaligned_unordered:
+; CHECK: bl __atomic_store
+ store atomic i16 %value, ptr %ptr unordered, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i16_unaligned_monotonic(i16 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i16_unaligned_monotonic:
+; CHECK: bl __atomic_store
+ store atomic i16 %value, ptr %ptr monotonic, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i16_unaligned_release(i16 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i16_unaligned_release:
+; CHECK: bl __atomic_store
+ store atomic i16 %value, ptr %ptr release, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i16_unaligned_seq_cst(i16 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i16_unaligned_seq_cst:
+; CHECK: bl __atomic_store
+ store atomic i16 %value, ptr %ptr seq_cst, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i32_unaligned_unordered(i32 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i32_unaligned_unordered:
+; CHECK: bl __atomic_store
+ store atomic i32 %value, ptr %ptr unordered, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i32_unaligned_monotonic(i32 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i32_unaligned_monotonic:
+; CHECK: bl __atomic_store
+ store atomic i32 %value, ptr %ptr monotonic, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i32_unaligned_release(i32 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i32_unaligned_release:
+; CHECK: bl __atomic_store
+ store atomic i32 %value, ptr %ptr release, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i32_unaligned_seq_cst(i32 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i32_unaligned_seq_cst:
+; CHECK: bl __atomic_store
+ store atomic i32 %value, ptr %ptr seq_cst, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i64_unaligned_unordered(i64 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i64_unaligned_unordered:
+; CHECK: bl __atomic_store
+ store atomic i64 %value, ptr %ptr unordered, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i64_unaligned_monotonic(i64 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i64_unaligned_monotonic:
+; CHECK: bl __atomic_store
+ store atomic i64 %value, ptr %ptr monotonic, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i64_unaligned_release(i64 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i64_unaligned_release:
+; CHECK: bl __atomic_store
+ store atomic i64 %value, ptr %ptr release, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i64_unaligned_seq_cst(i64 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i64_unaligned_seq_cst:
+; CHECK: bl __atomic_store
+ store atomic i64 %value, ptr %ptr seq_cst, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i128_unaligned_unordered(i128 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i128_unaligned_unordered:
+; CHECK: bl __atomic_store
+ store atomic i128 %value, ptr %ptr unordered, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i128_unaligned_monotonic(i128 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i128_unaligned_monotonic:
+; CHECK: bl __atomic_store
+ store atomic i128 %value, ptr %ptr monotonic, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i128_unaligned_release(i128 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i128_unaligned_release:
+; CHECK: bl __atomic_store
+ store atomic i128 %value, ptr %ptr release, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i128_unaligned_seq_cst(i128 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i128_unaligned_seq_cst:
+; CHECK: bl __atomic_store
+ store atomic i128 %value, ptr %ptr seq_cst, align 1
+ ret void
+}
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; -O0: {{.*}}
+; -O1: {{.*}}
diff --git a/llvm/test/CodeGen/AArch64/Atomics/aarch64-atomicrmw-lse2_lse128.ll b/llvm/test/CodeGen/AArch64/Atomics/aarch64-atomicrmw-lse2_lse128.ll
new file mode 100644
index 000000000000..a020e1327fcb
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/Atomics/aarch64-atomicrmw-lse2_lse128.ll
@@ -0,0 +1,6609 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --filter-out "\b(sp)\b" --filter "^\s*(ld[^r]|st[^r]|swp|cas|bl|add|and|eor|orn|orr|sub|mvn|sxt|cmp|ccmp|csel|dmb)"
+; The base test file was generated by ./llvm/test/CodeGen/AArch64/Atomics/generate-tests.py
+; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64 -mattr=+lse2,+lse128 -O0 | FileCheck %s --check-prefixes=CHECK,-O0
+; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64 -mattr=+lse2,+lse128 -O1 | FileCheck %s --check-prefixes=CHECK,-O1
+
+define dso_local i8 @atomicrmw_xchg_i8_aligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i8_aligned_monotonic:
+; CHECK: swpb w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xchg_i8_aligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i8_aligned_acquire:
+; CHECK: swpab w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xchg_i8_aligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i8_aligned_release:
+; CHECK: swplb w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xchg_i8_aligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i8_aligned_acq_rel:
+; CHECK: swpalb w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xchg_i8_aligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i8_aligned_seq_cst:
+; CHECK: swpalb w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_xchg_i16_aligned_monotonic(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i16_aligned_monotonic:
+; CHECK: swph w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i16 %value monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xchg_i16_aligned_acquire(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i16_aligned_acquire:
+; CHECK: swpah w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i16 %value acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xchg_i16_aligned_release(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i16_aligned_release:
+; CHECK: swplh w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i16 %value release, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xchg_i16_aligned_acq_rel(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i16_aligned_acq_rel:
+; CHECK: swpalh w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i16 %value acq_rel, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xchg_i16_aligned_seq_cst(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i16_aligned_seq_cst:
+; CHECK: swpalh w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i16 %value seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_xchg_i32_aligned_monotonic(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i32_aligned_monotonic:
+; CHECK: swp w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i32 %value monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xchg_i32_aligned_acquire(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i32_aligned_acquire:
+; CHECK: swpa w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i32 %value acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xchg_i32_aligned_release(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i32_aligned_release:
+; CHECK: swpl w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i32 %value release, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xchg_i32_aligned_acq_rel(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i32_aligned_acq_rel:
+; CHECK: swpal w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i32 %value acq_rel, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xchg_i32_aligned_seq_cst(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i32_aligned_seq_cst:
+; CHECK: swpal w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i32 %value seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_xchg_i64_aligned_monotonic(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i64_aligned_monotonic:
+; CHECK: swp x1, x0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i64 %value monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xchg_i64_aligned_acquire(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i64_aligned_acquire:
+; CHECK: swpa x1, x0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i64 %value acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xchg_i64_aligned_release(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i64_aligned_release:
+; CHECK: swpl x1, x0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i64 %value release, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xchg_i64_aligned_acq_rel(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i64_aligned_acq_rel:
+; CHECK: swpal x1, x0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i64 %value acq_rel, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xchg_i64_aligned_seq_cst(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i64_aligned_seq_cst:
+; CHECK: swpal x1, x0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i64 %value seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_xchg_i128_aligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xchg_i128_aligned_monotonic:
+; -O0: swpp x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_xchg_i128_aligned_monotonic:
+; -O1: swpp x2, x1, [x0]
+ %r = atomicrmw xchg ptr %ptr, i128 %value monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xchg_i128_aligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xchg_i128_aligned_acquire:
+; -O0: swppa x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_xchg_i128_aligned_acquire:
+; -O1: swppa x2, x1, [x0]
+ %r = atomicrmw xchg ptr %ptr, i128 %value acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xchg_i128_aligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xchg_i128_aligned_release:
+; -O0: swppl x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_xchg_i128_aligned_release:
+; -O1: swppl x2, x1, [x0]
+ %r = atomicrmw xchg ptr %ptr, i128 %value release, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xchg_i128_aligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xchg_i128_aligned_acq_rel:
+; -O0: swppal x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_xchg_i128_aligned_acq_rel:
+; -O1: swppal x2, x1, [x0]
+ %r = atomicrmw xchg ptr %ptr, i128 %value acq_rel, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xchg_i128_aligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xchg_i128_aligned_seq_cst:
+; -O0: swppal x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_xchg_i128_aligned_seq_cst:
+; -O1: swppal x2, x1, [x0]
+ %r = atomicrmw xchg ptr %ptr, i128 %value seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_xchg_i8_unaligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i8_unaligned_monotonic:
+; CHECK: swpb w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xchg_i8_unaligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i8_unaligned_acquire:
+; CHECK: swpab w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xchg_i8_unaligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i8_unaligned_release:
+; CHECK: swplb w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xchg_i8_unaligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i8_unaligned_acq_rel:
+; CHECK: swpalb w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xchg_i8_unaligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i8_unaligned_seq_cst:
+; CHECK: swpalb w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_xchg_i16_unaligned_monotonic(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i16_unaligned_monotonic:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i16 %value monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xchg_i16_unaligned_acquire(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i16_unaligned_acquire:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i16 %value acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xchg_i16_unaligned_release(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i16_unaligned_release:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i16 %value release, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xchg_i16_unaligned_acq_rel(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i16_unaligned_acq_rel:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i16 %value acq_rel, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xchg_i16_unaligned_seq_cst(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i16_unaligned_seq_cst:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i16 %value seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_xchg_i32_unaligned_monotonic(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i32_unaligned_monotonic:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i32 %value monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xchg_i32_unaligned_acquire(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i32_unaligned_acquire:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i32 %value acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xchg_i32_unaligned_release(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i32_unaligned_release:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i32 %value release, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xchg_i32_unaligned_acq_rel(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i32_unaligned_acq_rel:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i32 %value acq_rel, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xchg_i32_unaligned_seq_cst(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i32_unaligned_seq_cst:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i32 %value seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_xchg_i64_unaligned_monotonic(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i64_unaligned_monotonic:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i64 %value monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xchg_i64_unaligned_acquire(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i64_unaligned_acquire:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i64 %value acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xchg_i64_unaligned_release(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i64_unaligned_release:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i64 %value release, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xchg_i64_unaligned_acq_rel(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i64_unaligned_acq_rel:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i64 %value acq_rel, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xchg_i64_unaligned_seq_cst(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i64_unaligned_seq_cst:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i64 %value seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_xchg_i128_unaligned_monotonic(ptr %ptr, i128 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i128_unaligned_monotonic:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i128 %value monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xchg_i128_unaligned_acquire(ptr %ptr, i128 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i128_unaligned_acquire:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i128 %value acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xchg_i128_unaligned_release(ptr %ptr, i128 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i128_unaligned_release:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i128 %value release, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xchg_i128_unaligned_acq_rel(ptr %ptr, i128 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i128_unaligned_acq_rel:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i128 %value acq_rel, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xchg_i128_unaligned_seq_cst(ptr %ptr, i128 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i128_unaligned_seq_cst:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i128 %value seq_cst, align 1
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_add_i8_aligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_add_i8_aligned_monotonic:
+; CHECK: ldaddb w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_add_i8_aligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_add_i8_aligned_acquire:
+; CHECK: ldaddab w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_add_i8_aligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_add_i8_aligned_release:
+; CHECK: ldaddlb w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_add_i8_aligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_add_i8_aligned_acq_rel:
+; CHECK: ldaddalb w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_add_i8_aligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_add_i8_aligned_seq_cst:
+; CHECK: ldaddalb w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_add_i16_aligned_monotonic(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_add_i16_aligned_monotonic:
+; CHECK: ldaddh w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i16 %value monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_add_i16_aligned_acquire(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_add_i16_aligned_acquire:
+; CHECK: ldaddah w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i16 %value acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_add_i16_aligned_release(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_add_i16_aligned_release:
+; CHECK: ldaddlh w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i16 %value release, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_add_i16_aligned_acq_rel(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_add_i16_aligned_acq_rel:
+; CHECK: ldaddalh w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i16 %value acq_rel, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_add_i16_aligned_seq_cst(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_add_i16_aligned_seq_cst:
+; CHECK: ldaddalh w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i16 %value seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_add_i32_aligned_monotonic(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_add_i32_aligned_monotonic:
+; CHECK: ldadd w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i32 %value monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_add_i32_aligned_acquire(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_add_i32_aligned_acquire:
+; CHECK: ldadda w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i32 %value acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_add_i32_aligned_release(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_add_i32_aligned_release:
+; CHECK: ldaddl w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i32 %value release, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_add_i32_aligned_acq_rel(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_add_i32_aligned_acq_rel:
+; CHECK: ldaddal w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i32 %value acq_rel, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_add_i32_aligned_seq_cst(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_add_i32_aligned_seq_cst:
+; CHECK: ldaddal w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i32 %value seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_add_i64_aligned_monotonic(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_add_i64_aligned_monotonic:
+; CHECK: ldadd x1, x0, [x0]
+ %r = atomicrmw add ptr %ptr, i64 %value monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_add_i64_aligned_acquire(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_add_i64_aligned_acquire:
+; CHECK: ldadda x1, x0, [x0]
+ %r = atomicrmw add ptr %ptr, i64 %value acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_add_i64_aligned_release(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_add_i64_aligned_release:
+; CHECK: ldaddl x1, x0, [x0]
+ %r = atomicrmw add ptr %ptr, i64 %value release, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_add_i64_aligned_acq_rel(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_add_i64_aligned_acq_rel:
+; CHECK: ldaddal x1, x0, [x0]
+ %r = atomicrmw add ptr %ptr, i64 %value acq_rel, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_add_i64_aligned_seq_cst(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_add_i64_aligned_seq_cst:
+; CHECK: ldaddal x1, x0, [x0]
+ %r = atomicrmw add ptr %ptr, i64 %value seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_add_i128_aligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_add_i128_aligned_monotonic:
+; -O0: adds x2, x10, x12
+; -O0: casp x0, x1, x2, x3, [x8]
+; -O0: subs x11, x8, x11
+; -O0: ccmp x9, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_add_i128_aligned_monotonic:
+; -O1: ldp x4, x5, [x0]
+; -O1: adds x8, x4, x2
+; -O1: casp x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw add ptr %ptr, i128 %value monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_add_i128_aligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_add_i128_aligned_acquire:
+; -O0: adds x2, x10, x12
+; -O0: caspa x0, x1, x2, x3, [x8]
+; -O0: subs x11, x8, x11
+; -O0: ccmp x9, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_add_i128_aligned_acquire:
+; -O1: ldp x4, x5, [x0]
+; -O1: adds x8, x4, x2
+; -O1: caspa x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw add ptr %ptr, i128 %value acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_add_i128_aligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_add_i128_aligned_release:
+; -O0: adds x2, x10, x12
+; -O0: caspl x0, x1, x2, x3, [x8]
+; -O0: subs x11, x8, x11
+; -O0: ccmp x9, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_add_i128_aligned_release:
+; -O1: ldp x4, x5, [x0]
+; -O1: adds x8, x4, x2
+; -O1: caspl x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw add ptr %ptr, i128 %value release, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_add_i128_aligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_add_i128_aligned_acq_rel:
+; -O0: adds x2, x10, x12
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: subs x11, x8, x11
+; -O0: ccmp x9, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_add_i128_aligned_acq_rel:
+; -O1: ldp x4, x5, [x0]
+; -O1: adds x8, x4, x2
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw add ptr %ptr, i128 %value acq_rel, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_add_i128_aligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_add_i128_aligned_seq_cst:
+; -O0: adds x2, x10, x12
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: subs x11, x8, x11
+; -O0: ccmp x9, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_add_i128_aligned_seq_cst:
+; -O1: ldp x4, x5, [x0]
+; -O1: adds x8, x4, x2
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw add ptr %ptr, i128 %value seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_add_i8_unaligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_add_i8_unaligned_monotonic:
+; CHECK: ldaddb w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_add_i8_unaligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_add_i8_unaligned_acquire:
+; CHECK: ldaddab w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_add_i8_unaligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_add_i8_unaligned_release:
+; CHECK: ldaddlb w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_add_i8_unaligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_add_i8_unaligned_acq_rel:
+; CHECK: ldaddalb w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_add_i8_unaligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_add_i8_unaligned_seq_cst:
+; CHECK: ldaddalb w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_add_i16_unaligned_monotonic(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_add_i16_unaligned_monotonic:
+; -O0: add w8, w8, w9, uxth
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i16_unaligned_monotonic:
+; -O1: add w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i16 %value monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_add_i16_unaligned_acquire(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_add_i16_unaligned_acquire:
+; -O0: add w8, w8, w9, uxth
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i16_unaligned_acquire:
+; -O1: add w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i16 %value acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_add_i16_unaligned_release(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_add_i16_unaligned_release:
+; -O0: add w8, w8, w9, uxth
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i16_unaligned_release:
+; -O1: add w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i16 %value release, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_add_i16_unaligned_acq_rel(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_add_i16_unaligned_acq_rel:
+; -O0: add w8, w8, w9, uxth
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i16_unaligned_acq_rel:
+; -O1: add w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i16 %value acq_rel, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_add_i16_unaligned_seq_cst(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_add_i16_unaligned_seq_cst:
+; -O0: add w8, w8, w9, uxth
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i16_unaligned_seq_cst:
+; -O1: add w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i16 %value seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_add_i32_unaligned_monotonic(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_add_i32_unaligned_monotonic:
+; -O0: add w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i32_unaligned_monotonic:
+; -O1: add w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i32 %value monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_add_i32_unaligned_acquire(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_add_i32_unaligned_acquire:
+; -O0: add w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i32_unaligned_acquire:
+; -O1: add w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i32 %value acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_add_i32_unaligned_release(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_add_i32_unaligned_release:
+; -O0: add w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i32_unaligned_release:
+; -O1: add w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i32 %value release, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_add_i32_unaligned_acq_rel(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_add_i32_unaligned_acq_rel:
+; -O0: add w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i32_unaligned_acq_rel:
+; -O1: add w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i32 %value acq_rel, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_add_i32_unaligned_seq_cst(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_add_i32_unaligned_seq_cst:
+; -O0: add w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i32_unaligned_seq_cst:
+; -O1: add w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i32 %value seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_add_i64_unaligned_monotonic(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_add_i64_unaligned_monotonic:
+; -O0: add x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i64_unaligned_monotonic:
+; -O1: add x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i64 %value monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_add_i64_unaligned_acquire(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_add_i64_unaligned_acquire:
+; -O0: add x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i64_unaligned_acquire:
+; -O1: add x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i64 %value acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_add_i64_unaligned_release(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_add_i64_unaligned_release:
+; -O0: add x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i64_unaligned_release:
+; -O1: add x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i64 %value release, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_add_i64_unaligned_acq_rel(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_add_i64_unaligned_acq_rel:
+; -O0: add x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i64_unaligned_acq_rel:
+; -O1: add x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i64 %value acq_rel, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_add_i64_unaligned_seq_cst(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_add_i64_unaligned_seq_cst:
+; -O0: add x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i64_unaligned_seq_cst:
+; -O1: add x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i64 %value seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_add_i128_unaligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_add_i128_unaligned_monotonic:
+; -O0: adds x8, x11, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i128_unaligned_monotonic:
+; -O1: ldp x0, x1, [x0]
+; -O1: adds x8, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i128 %value monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_add_i128_unaligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_add_i128_unaligned_acquire:
+; -O0: adds x8, x11, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i128_unaligned_acquire:
+; -O1: ldp x0, x1, [x0]
+; -O1: adds x8, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i128 %value acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_add_i128_unaligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_add_i128_unaligned_release:
+; -O0: adds x8, x11, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i128_unaligned_release:
+; -O1: ldp x0, x1, [x0]
+; -O1: adds x8, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i128 %value release, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_add_i128_unaligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_add_i128_unaligned_acq_rel:
+; -O0: adds x8, x11, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i128_unaligned_acq_rel:
+; -O1: ldp x0, x1, [x0]
+; -O1: adds x8, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i128 %value acq_rel, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_add_i128_unaligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_add_i128_unaligned_seq_cst:
+; -O0: adds x8, x11, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i128_unaligned_seq_cst:
+; -O1: ldp x0, x1, [x0]
+; -O1: adds x8, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i128 %value seq_cst, align 1
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_sub_i8_aligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_sub_i8_aligned_monotonic:
+; CHECK: ldaddb w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_sub_i8_aligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_sub_i8_aligned_acquire:
+; CHECK: ldaddab w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_sub_i8_aligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_sub_i8_aligned_release:
+; CHECK: ldaddlb w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_sub_i8_aligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_sub_i8_aligned_acq_rel:
+; CHECK: ldaddalb w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_sub_i8_aligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_sub_i8_aligned_seq_cst:
+; CHECK: ldaddalb w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_sub_i16_aligned_monotonic(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_sub_i16_aligned_monotonic:
+; CHECK: ldaddh w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i16 %value monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_sub_i16_aligned_acquire(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_sub_i16_aligned_acquire:
+; CHECK: ldaddah w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i16 %value acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_sub_i16_aligned_release(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_sub_i16_aligned_release:
+; CHECK: ldaddlh w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i16 %value release, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_sub_i16_aligned_acq_rel(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_sub_i16_aligned_acq_rel:
+; CHECK: ldaddalh w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i16 %value acq_rel, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_sub_i16_aligned_seq_cst(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_sub_i16_aligned_seq_cst:
+; CHECK: ldaddalh w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i16 %value seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_sub_i32_aligned_monotonic(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_sub_i32_aligned_monotonic:
+; CHECK: ldadd w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i32 %value monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_sub_i32_aligned_acquire(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_sub_i32_aligned_acquire:
+; CHECK: ldadda w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i32 %value acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_sub_i32_aligned_release(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_sub_i32_aligned_release:
+; CHECK: ldaddl w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i32 %value release, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_sub_i32_aligned_acq_rel(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_sub_i32_aligned_acq_rel:
+; CHECK: ldaddal w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i32 %value acq_rel, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_sub_i32_aligned_seq_cst(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_sub_i32_aligned_seq_cst:
+; CHECK: ldaddal w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i32 %value seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_sub_i64_aligned_monotonic(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_sub_i64_aligned_monotonic:
+; CHECK: ldadd x8, x0, [x0]
+ %r = atomicrmw sub ptr %ptr, i64 %value monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_sub_i64_aligned_acquire(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_sub_i64_aligned_acquire:
+; CHECK: ldadda x8, x0, [x0]
+ %r = atomicrmw sub ptr %ptr, i64 %value acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_sub_i64_aligned_release(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_sub_i64_aligned_release:
+; CHECK: ldaddl x8, x0, [x0]
+ %r = atomicrmw sub ptr %ptr, i64 %value release, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_sub_i64_aligned_acq_rel(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_sub_i64_aligned_acq_rel:
+; CHECK: ldaddal x8, x0, [x0]
+ %r = atomicrmw sub ptr %ptr, i64 %value acq_rel, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_sub_i64_aligned_seq_cst(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_sub_i64_aligned_seq_cst:
+; CHECK: ldaddal x8, x0, [x0]
+ %r = atomicrmw sub ptr %ptr, i64 %value seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_sub_i128_aligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_sub_i128_aligned_monotonic:
+; -O0: subs x2, x10, x12
+; -O0: casp x0, x1, x2, x3, [x8]
+; -O0: subs x11, x8, x11
+; -O0: ccmp x9, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_sub_i128_aligned_monotonic:
+; -O1: ldp x4, x5, [x0]
+; -O1: subs x8, x4, x2
+; -O1: casp x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw sub ptr %ptr, i128 %value monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_sub_i128_aligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_sub_i128_aligned_acquire:
+; -O0: subs x2, x10, x12
+; -O0: caspa x0, x1, x2, x3, [x8]
+; -O0: subs x11, x8, x11
+; -O0: ccmp x9, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_sub_i128_aligned_acquire:
+; -O1: ldp x4, x5, [x0]
+; -O1: subs x8, x4, x2
+; -O1: caspa x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw sub ptr %ptr, i128 %value acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_sub_i128_aligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_sub_i128_aligned_release:
+; -O0: subs x2, x10, x12
+; -O0: caspl x0, x1, x2, x3, [x8]
+; -O0: subs x11, x8, x11
+; -O0: ccmp x9, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_sub_i128_aligned_release:
+; -O1: ldp x4, x5, [x0]
+; -O1: subs x8, x4, x2
+; -O1: caspl x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw sub ptr %ptr, i128 %value release, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_sub_i128_aligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_sub_i128_aligned_acq_rel:
+; -O0: subs x2, x10, x12
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: subs x11, x8, x11
+; -O0: ccmp x9, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_sub_i128_aligned_acq_rel:
+; -O1: ldp x4, x5, [x0]
+; -O1: subs x8, x4, x2
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw sub ptr %ptr, i128 %value acq_rel, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_sub_i128_aligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_sub_i128_aligned_seq_cst:
+; -O0: subs x2, x10, x12
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: subs x11, x8, x11
+; -O0: ccmp x9, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_sub_i128_aligned_seq_cst:
+; -O1: ldp x4, x5, [x0]
+; -O1: subs x8, x4, x2
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw sub ptr %ptr, i128 %value seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_sub_i8_unaligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_sub_i8_unaligned_monotonic:
+; CHECK: ldaddb w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_sub_i8_unaligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_sub_i8_unaligned_acquire:
+; CHECK: ldaddab w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_sub_i8_unaligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_sub_i8_unaligned_release:
+; CHECK: ldaddlb w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_sub_i8_unaligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_sub_i8_unaligned_acq_rel:
+; CHECK: ldaddalb w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_sub_i8_unaligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_sub_i8_unaligned_seq_cst:
+; CHECK: ldaddalb w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_sub_i16_unaligned_monotonic(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_sub_i16_unaligned_monotonic:
+; -O0: subs w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i16_unaligned_monotonic:
+; -O1: sub w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i16 %value monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_sub_i16_unaligned_acquire(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_sub_i16_unaligned_acquire:
+; -O0: subs w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i16_unaligned_acquire:
+; -O1: sub w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i16 %value acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_sub_i16_unaligned_release(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_sub_i16_unaligned_release:
+; -O0: subs w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i16_unaligned_release:
+; -O1: sub w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i16 %value release, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_sub_i16_unaligned_acq_rel(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_sub_i16_unaligned_acq_rel:
+; -O0: subs w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i16_unaligned_acq_rel:
+; -O1: sub w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i16 %value acq_rel, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_sub_i16_unaligned_seq_cst(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_sub_i16_unaligned_seq_cst:
+; -O0: subs w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i16_unaligned_seq_cst:
+; -O1: sub w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i16 %value seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_sub_i32_unaligned_monotonic(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_sub_i32_unaligned_monotonic:
+; -O0: subs w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i32_unaligned_monotonic:
+; -O1: sub w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i32 %value monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_sub_i32_unaligned_acquire(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_sub_i32_unaligned_acquire:
+; -O0: subs w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i32_unaligned_acquire:
+; -O1: sub w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i32 %value acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_sub_i32_unaligned_release(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_sub_i32_unaligned_release:
+; -O0: subs w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i32_unaligned_release:
+; -O1: sub w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i32 %value release, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_sub_i32_unaligned_acq_rel(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_sub_i32_unaligned_acq_rel:
+; -O0: subs w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i32_unaligned_acq_rel:
+; -O1: sub w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i32 %value acq_rel, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_sub_i32_unaligned_seq_cst(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_sub_i32_unaligned_seq_cst:
+; -O0: subs w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i32_unaligned_seq_cst:
+; -O1: sub w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i32 %value seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_sub_i64_unaligned_monotonic(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_sub_i64_unaligned_monotonic:
+; -O0: subs x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i64_unaligned_monotonic:
+; -O1: sub x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i64 %value monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_sub_i64_unaligned_acquire(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_sub_i64_unaligned_acquire:
+; -O0: subs x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i64_unaligned_acquire:
+; -O1: sub x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i64 %value acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_sub_i64_unaligned_release(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_sub_i64_unaligned_release:
+; -O0: subs x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i64_unaligned_release:
+; -O1: sub x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i64 %value release, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_sub_i64_unaligned_acq_rel(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_sub_i64_unaligned_acq_rel:
+; -O0: subs x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i64_unaligned_acq_rel:
+; -O1: sub x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i64 %value acq_rel, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_sub_i64_unaligned_seq_cst(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_sub_i64_unaligned_seq_cst:
+; -O0: subs x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i64_unaligned_seq_cst:
+; -O1: sub x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i64 %value seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_sub_i128_unaligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_sub_i128_unaligned_monotonic:
+; -O0: subs x8, x11, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i128_unaligned_monotonic:
+; -O1: ldp x0, x1, [x0]
+; -O1: subs x8, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i128 %value monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_sub_i128_unaligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_sub_i128_unaligned_acquire:
+; -O0: subs x8, x11, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i128_unaligned_acquire:
+; -O1: ldp x0, x1, [x0]
+; -O1: subs x8, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i128 %value acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_sub_i128_unaligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_sub_i128_unaligned_release:
+; -O0: subs x8, x11, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i128_unaligned_release:
+; -O1: ldp x0, x1, [x0]
+; -O1: subs x8, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i128 %value release, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_sub_i128_unaligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_sub_i128_unaligned_acq_rel:
+; -O0: subs x8, x11, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i128_unaligned_acq_rel:
+; -O1: ldp x0, x1, [x0]
+; -O1: subs x8, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i128 %value acq_rel, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_sub_i128_unaligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_sub_i128_unaligned_seq_cst:
+; -O0: subs x8, x11, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i128_unaligned_seq_cst:
+; -O1: ldp x0, x1, [x0]
+; -O1: subs x8, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i128 %value seq_cst, align 1
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_and_i8_aligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_and_i8_aligned_monotonic:
+; CHECK: mvn w8, w1
+; CHECK: ldclrb w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_and_i8_aligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_and_i8_aligned_acquire:
+; CHECK: mvn w8, w1
+; CHECK: ldclrab w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_and_i8_aligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_and_i8_aligned_release:
+; CHECK: mvn w8, w1
+; CHECK: ldclrlb w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_and_i8_aligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_and_i8_aligned_acq_rel:
+; CHECK: mvn w8, w1
+; CHECK: ldclralb w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_and_i8_aligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_and_i8_aligned_seq_cst:
+; CHECK: mvn w8, w1
+; CHECK: ldclralb w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_and_i16_aligned_monotonic(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_and_i16_aligned_monotonic:
+; CHECK: mvn w8, w1
+; CHECK: ldclrh w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i16 %value monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_and_i16_aligned_acquire(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_and_i16_aligned_acquire:
+; CHECK: mvn w8, w1
+; CHECK: ldclrah w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i16 %value acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_and_i16_aligned_release(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_and_i16_aligned_release:
+; CHECK: mvn w8, w1
+; CHECK: ldclrlh w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i16 %value release, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_and_i16_aligned_acq_rel(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_and_i16_aligned_acq_rel:
+; CHECK: mvn w8, w1
+; CHECK: ldclralh w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i16 %value acq_rel, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_and_i16_aligned_seq_cst(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_and_i16_aligned_seq_cst:
+; CHECK: mvn w8, w1
+; CHECK: ldclralh w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i16 %value seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_and_i32_aligned_monotonic(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_and_i32_aligned_monotonic:
+; CHECK: mvn w8, w1
+; CHECK: ldclr w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i32 %value monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_and_i32_aligned_acquire(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_and_i32_aligned_acquire:
+; CHECK: mvn w8, w1
+; CHECK: ldclra w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i32 %value acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_and_i32_aligned_release(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_and_i32_aligned_release:
+; CHECK: mvn w8, w1
+; CHECK: ldclrl w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i32 %value release, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_and_i32_aligned_acq_rel(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_and_i32_aligned_acq_rel:
+; CHECK: mvn w8, w1
+; CHECK: ldclral w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i32 %value acq_rel, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_and_i32_aligned_seq_cst(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_and_i32_aligned_seq_cst:
+; CHECK: mvn w8, w1
+; CHECK: ldclral w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i32 %value seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_and_i64_aligned_monotonic(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_and_i64_aligned_monotonic:
+; CHECK: mvn x8, x1
+; CHECK: ldclr x8, x0, [x0]
+ %r = atomicrmw and ptr %ptr, i64 %value monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_and_i64_aligned_acquire(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_and_i64_aligned_acquire:
+; CHECK: mvn x8, x1
+; CHECK: ldclra x8, x0, [x0]
+ %r = atomicrmw and ptr %ptr, i64 %value acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_and_i64_aligned_release(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_and_i64_aligned_release:
+; CHECK: mvn x8, x1
+; CHECK: ldclrl x8, x0, [x0]
+ %r = atomicrmw and ptr %ptr, i64 %value release, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_and_i64_aligned_acq_rel(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_and_i64_aligned_acq_rel:
+; CHECK: mvn x8, x1
+; CHECK: ldclral x8, x0, [x0]
+ %r = atomicrmw and ptr %ptr, i64 %value acq_rel, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_and_i64_aligned_seq_cst(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_and_i64_aligned_seq_cst:
+; CHECK: mvn x8, x1
+; CHECK: ldclral x8, x0, [x0]
+ %r = atomicrmw and ptr %ptr, i64 %value seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_and_i128_aligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_and_i128_aligned_monotonic:
+; -O0: mvn x1, x3
+; -O0: mvn x0, x2
+; -O0: ldclrp x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_and_i128_aligned_monotonic:
+; -O1: mvn x1, x3
+; -O1: mvn x8, x2
+; -O1: ldclrp x8, x1, [x0]
+ %r = atomicrmw and ptr %ptr, i128 %value monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_and_i128_aligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_and_i128_aligned_acquire:
+; -O0: mvn x1, x3
+; -O0: mvn x0, x2
+; -O0: ldclrpa x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_and_i128_aligned_acquire:
+; -O1: mvn x1, x3
+; -O1: mvn x8, x2
+; -O1: ldclrpa x8, x1, [x0]
+ %r = atomicrmw and ptr %ptr, i128 %value acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_and_i128_aligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_and_i128_aligned_release:
+; -O0: mvn x1, x3
+; -O0: mvn x0, x2
+; -O0: ldclrpl x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_and_i128_aligned_release:
+; -O1: mvn x1, x3
+; -O1: mvn x8, x2
+; -O1: ldclrpl x8, x1, [x0]
+ %r = atomicrmw and ptr %ptr, i128 %value release, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_and_i128_aligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_and_i128_aligned_acq_rel:
+; -O0: mvn x1, x3
+; -O0: mvn x0, x2
+; -O0: ldclrpal x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_and_i128_aligned_acq_rel:
+; -O1: mvn x1, x3
+; -O1: mvn x8, x2
+; -O1: ldclrpal x8, x1, [x0]
+ %r = atomicrmw and ptr %ptr, i128 %value acq_rel, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_and_i128_aligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_and_i128_aligned_seq_cst:
+; -O0: mvn x1, x3
+; -O0: mvn x0, x2
+; -O0: ldclrpal x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_and_i128_aligned_seq_cst:
+; -O1: mvn x1, x3
+; -O1: mvn x8, x2
+; -O1: ldclrpal x8, x1, [x0]
+ %r = atomicrmw and ptr %ptr, i128 %value seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_and_i8_unaligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_and_i8_unaligned_monotonic:
+; CHECK: mvn w8, w1
+; CHECK: ldclrb w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_and_i8_unaligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_and_i8_unaligned_acquire:
+; CHECK: mvn w8, w1
+; CHECK: ldclrab w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_and_i8_unaligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_and_i8_unaligned_release:
+; CHECK: mvn w8, w1
+; CHECK: ldclrlb w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_and_i8_unaligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_and_i8_unaligned_acq_rel:
+; CHECK: mvn w8, w1
+; CHECK: ldclralb w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_and_i8_unaligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_and_i8_unaligned_seq_cst:
+; CHECK: mvn w8, w1
+; CHECK: ldclralb w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_and_i16_unaligned_monotonic(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_and_i16_unaligned_monotonic:
+; -O0: and w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i16_unaligned_monotonic:
+; -O1: and w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i16 %value monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_and_i16_unaligned_acquire(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_and_i16_unaligned_acquire:
+; -O0: and w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i16_unaligned_acquire:
+; -O1: and w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i16 %value acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_and_i16_unaligned_release(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_and_i16_unaligned_release:
+; -O0: and w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i16_unaligned_release:
+; -O1: and w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i16 %value release, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_and_i16_unaligned_acq_rel(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_and_i16_unaligned_acq_rel:
+; -O0: and w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i16_unaligned_acq_rel:
+; -O1: and w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i16 %value acq_rel, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_and_i16_unaligned_seq_cst(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_and_i16_unaligned_seq_cst:
+; -O0: and w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i16_unaligned_seq_cst:
+; -O1: and w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i16 %value seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_and_i32_unaligned_monotonic(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_and_i32_unaligned_monotonic:
+; -O0: and w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i32_unaligned_monotonic:
+; -O1: and w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i32 %value monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_and_i32_unaligned_acquire(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_and_i32_unaligned_acquire:
+; -O0: and w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i32_unaligned_acquire:
+; -O1: and w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i32 %value acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_and_i32_unaligned_release(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_and_i32_unaligned_release:
+; -O0: and w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i32_unaligned_release:
+; -O1: and w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i32 %value release, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_and_i32_unaligned_acq_rel(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_and_i32_unaligned_acq_rel:
+; -O0: and w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i32_unaligned_acq_rel:
+; -O1: and w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i32 %value acq_rel, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_and_i32_unaligned_seq_cst(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_and_i32_unaligned_seq_cst:
+; -O0: and w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i32_unaligned_seq_cst:
+; -O1: and w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i32 %value seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_and_i64_unaligned_monotonic(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_and_i64_unaligned_monotonic:
+; -O0: and x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i64_unaligned_monotonic:
+; -O1: and x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i64 %value monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_and_i64_unaligned_acquire(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_and_i64_unaligned_acquire:
+; -O0: and x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i64_unaligned_acquire:
+; -O1: and x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i64 %value acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_and_i64_unaligned_release(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_and_i64_unaligned_release:
+; -O0: and x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i64_unaligned_release:
+; -O1: and x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i64 %value release, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_and_i64_unaligned_acq_rel(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_and_i64_unaligned_acq_rel:
+; -O0: and x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i64_unaligned_acq_rel:
+; -O1: and x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i64 %value acq_rel, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_and_i64_unaligned_seq_cst(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_and_i64_unaligned_seq_cst:
+; -O0: and x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i64_unaligned_seq_cst:
+; -O1: and x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i64 %value seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_and_i128_unaligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_and_i128_unaligned_monotonic:
+; -O0: and x9, x8, x9
+; -O0: and x8, x8, x10
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i128_unaligned_monotonic:
+; -O1: ldp x0, x1, [x0]
+; -O1: and x8, x1, x19
+; -O1: and x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i128 %value monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_and_i128_unaligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_and_i128_unaligned_acquire:
+; -O0: and x9, x8, x9
+; -O0: and x8, x8, x10
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i128_unaligned_acquire:
+; -O1: ldp x0, x1, [x0]
+; -O1: and x8, x1, x19
+; -O1: and x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i128 %value acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_and_i128_unaligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_and_i128_unaligned_release:
+; -O0: and x9, x8, x9
+; -O0: and x8, x8, x10
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i128_unaligned_release:
+; -O1: ldp x0, x1, [x0]
+; -O1: and x8, x1, x19
+; -O1: and x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i128 %value release, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_and_i128_unaligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_and_i128_unaligned_acq_rel:
+; -O0: and x9, x8, x9
+; -O0: and x8, x8, x10
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i128_unaligned_acq_rel:
+; -O1: ldp x0, x1, [x0]
+; -O1: and x8, x1, x19
+; -O1: and x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i128 %value acq_rel, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_and_i128_unaligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_and_i128_unaligned_seq_cst:
+; -O0: and x9, x8, x9
+; -O0: and x8, x8, x10
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i128_unaligned_seq_cst:
+; -O1: ldp x0, x1, [x0]
+; -O1: and x8, x1, x19
+; -O1: and x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i128 %value seq_cst, align 1
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_nand_i8_aligned_monotonic(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_nand_i8_aligned_monotonic:
+; -O0: and w8, w10, w8
+; -O0: mvn w8, w8
+; -O0: casb w9, w8, [x11]
+; -O0: and w8, w9, #0xff
+; -O0: subs w8, w8, w10, uxtb
+;
+; -O1-LABEL: atomicrmw_nand_i8_aligned_monotonic:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casb w9, w10, [x0]
+; -O1: cmp w9, w8, uxtb
+ %r = atomicrmw nand ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_nand_i8_aligned_acquire(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_nand_i8_aligned_acquire:
+; -O0: and w8, w10, w8
+; -O0: mvn w8, w8
+; -O0: casab w9, w8, [x11]
+; -O0: and w8, w9, #0xff
+; -O0: subs w8, w8, w10, uxtb
+;
+; -O1-LABEL: atomicrmw_nand_i8_aligned_acquire:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casab w9, w10, [x0]
+; -O1: cmp w9, w8, uxtb
+ %r = atomicrmw nand ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_nand_i8_aligned_release(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_nand_i8_aligned_release:
+; -O0: and w8, w10, w8
+; -O0: mvn w8, w8
+; -O0: caslb w9, w8, [x11]
+; -O0: and w8, w9, #0xff
+; -O0: subs w8, w8, w10, uxtb
+;
+; -O1-LABEL: atomicrmw_nand_i8_aligned_release:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: caslb w9, w10, [x0]
+; -O1: cmp w9, w8, uxtb
+ %r = atomicrmw nand ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_nand_i8_aligned_acq_rel(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_nand_i8_aligned_acq_rel:
+; -O0: and w8, w10, w8
+; -O0: mvn w8, w8
+; -O0: casalb w9, w8, [x11]
+; -O0: and w8, w9, #0xff
+; -O0: subs w8, w8, w10, uxtb
+;
+; -O1-LABEL: atomicrmw_nand_i8_aligned_acq_rel:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casalb w9, w10, [x0]
+; -O1: cmp w9, w8, uxtb
+ %r = atomicrmw nand ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_nand_i8_aligned_seq_cst(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_nand_i8_aligned_seq_cst:
+; -O0: and w8, w10, w8
+; -O0: mvn w8, w8
+; -O0: casalb w9, w8, [x11]
+; -O0: and w8, w9, #0xff
+; -O0: subs w8, w8, w10, uxtb
+;
+; -O1-LABEL: atomicrmw_nand_i8_aligned_seq_cst:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casalb w9, w10, [x0]
+; -O1: cmp w9, w8, uxtb
+ %r = atomicrmw nand ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_nand_i16_aligned_monotonic(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_nand_i16_aligned_monotonic:
+; -O0: and w9, w8, w9
+; -O0: mvn w10, w9
+; -O0: cash w9, w10, [x11]
+; -O0: subs w8, w8, w9, uxth
+;
+; -O1-LABEL: atomicrmw_nand_i16_aligned_monotonic:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: cash w9, w10, [x0]
+; -O1: cmp w9, w8, uxth
+ %r = atomicrmw nand ptr %ptr, i16 %value monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_nand_i16_aligned_acquire(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_nand_i16_aligned_acquire:
+; -O0: and w9, w8, w9
+; -O0: mvn w10, w9
+; -O0: casah w9, w10, [x11]
+; -O0: subs w8, w8, w9, uxth
+;
+; -O1-LABEL: atomicrmw_nand_i16_aligned_acquire:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casah w9, w10, [x0]
+; -O1: cmp w9, w8, uxth
+ %r = atomicrmw nand ptr %ptr, i16 %value acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_nand_i16_aligned_release(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_nand_i16_aligned_release:
+; -O0: and w9, w8, w9
+; -O0: mvn w10, w9
+; -O0: caslh w9, w10, [x11]
+; -O0: subs w8, w8, w9, uxth
+;
+; -O1-LABEL: atomicrmw_nand_i16_aligned_release:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: caslh w9, w10, [x0]
+; -O1: cmp w9, w8, uxth
+ %r = atomicrmw nand ptr %ptr, i16 %value release, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_nand_i16_aligned_acq_rel(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_nand_i16_aligned_acq_rel:
+; -O0: and w9, w8, w9
+; -O0: mvn w10, w9
+; -O0: casalh w9, w10, [x11]
+; -O0: subs w8, w8, w9, uxth
+;
+; -O1-LABEL: atomicrmw_nand_i16_aligned_acq_rel:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casalh w9, w10, [x0]
+; -O1: cmp w9, w8, uxth
+ %r = atomicrmw nand ptr %ptr, i16 %value acq_rel, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_nand_i16_aligned_seq_cst(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_nand_i16_aligned_seq_cst:
+; -O0: and w9, w8, w9
+; -O0: mvn w10, w9
+; -O0: casalh w9, w10, [x11]
+; -O0: subs w8, w8, w9, uxth
+;
+; -O1-LABEL: atomicrmw_nand_i16_aligned_seq_cst:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casalh w9, w10, [x0]
+; -O1: cmp w9, w8, uxth
+ %r = atomicrmw nand ptr %ptr, i16 %value seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_nand_i32_aligned_monotonic(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_nand_i32_aligned_monotonic:
+; -O0: and w9, w8, w9
+; -O0: mvn w10, w9
+; -O0: cas w9, w10, [x11]
+; -O0: subs w8, w9, w8
+;
+; -O1-LABEL: atomicrmw_nand_i32_aligned_monotonic:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: cas w9, w10, [x0]
+; -O1: cmp w9, w8
+ %r = atomicrmw nand ptr %ptr, i32 %value monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_nand_i32_aligned_acquire(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_nand_i32_aligned_acquire:
+; -O0: and w9, w8, w9
+; -O0: mvn w10, w9
+; -O0: casa w9, w10, [x11]
+; -O0: subs w8, w9, w8
+;
+; -O1-LABEL: atomicrmw_nand_i32_aligned_acquire:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casa w9, w10, [x0]
+; -O1: cmp w9, w8
+ %r = atomicrmw nand ptr %ptr, i32 %value acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_nand_i32_aligned_release(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_nand_i32_aligned_release:
+; -O0: and w9, w8, w9
+; -O0: mvn w10, w9
+; -O0: casl w9, w10, [x11]
+; -O0: subs w8, w9, w8
+;
+; -O1-LABEL: atomicrmw_nand_i32_aligned_release:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casl w9, w10, [x0]
+; -O1: cmp w9, w8
+ %r = atomicrmw nand ptr %ptr, i32 %value release, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_nand_i32_aligned_acq_rel(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_nand_i32_aligned_acq_rel:
+; -O0: and w9, w8, w9
+; -O0: mvn w10, w9
+; -O0: casal w9, w10, [x11]
+; -O0: subs w8, w9, w8
+;
+; -O1-LABEL: atomicrmw_nand_i32_aligned_acq_rel:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casal w9, w10, [x0]
+; -O1: cmp w9, w8
+ %r = atomicrmw nand ptr %ptr, i32 %value acq_rel, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_nand_i32_aligned_seq_cst(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_nand_i32_aligned_seq_cst:
+; -O0: and w9, w8, w9
+; -O0: mvn w10, w9
+; -O0: casal w9, w10, [x11]
+; -O0: subs w8, w9, w8
+;
+; -O1-LABEL: atomicrmw_nand_i32_aligned_seq_cst:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casal w9, w10, [x0]
+; -O1: cmp w9, w8
+ %r = atomicrmw nand ptr %ptr, i32 %value seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_nand_i64_aligned_monotonic(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_nand_i64_aligned_monotonic:
+; -O0: and x9, x8, x9
+; -O0: mvn x10, x9
+; -O0: cas x9, x10, [x11]
+; -O0: subs x8, x9, x8
+;
+; -O1-LABEL: atomicrmw_nand_i64_aligned_monotonic:
+; -O1: and x10, x8, x1
+; -O1: mvn x10, x10
+; -O1: cas x9, x10, [x0]
+; -O1: cmp x9, x8
+ %r = atomicrmw nand ptr %ptr, i64 %value monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_nand_i64_aligned_acquire(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_nand_i64_aligned_acquire:
+; -O0: and x9, x8, x9
+; -O0: mvn x10, x9
+; -O0: casa x9, x10, [x11]
+; -O0: subs x8, x9, x8
+;
+; -O1-LABEL: atomicrmw_nand_i64_aligned_acquire:
+; -O1: and x10, x8, x1
+; -O1: mvn x10, x10
+; -O1: casa x9, x10, [x0]
+; -O1: cmp x9, x8
+ %r = atomicrmw nand ptr %ptr, i64 %value acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_nand_i64_aligned_release(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_nand_i64_aligned_release:
+; -O0: and x9, x8, x9
+; -O0: mvn x10, x9
+; -O0: casl x9, x10, [x11]
+; -O0: subs x8, x9, x8
+;
+; -O1-LABEL: atomicrmw_nand_i64_aligned_release:
+; -O1: and x10, x8, x1
+; -O1: mvn x10, x10
+; -O1: casl x9, x10, [x0]
+; -O1: cmp x9, x8
+ %r = atomicrmw nand ptr %ptr, i64 %value release, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_nand_i64_aligned_acq_rel(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_nand_i64_aligned_acq_rel:
+; -O0: and x9, x8, x9
+; -O0: mvn x10, x9
+; -O0: casal x9, x10, [x11]
+; -O0: subs x8, x9, x8
+;
+; -O1-LABEL: atomicrmw_nand_i64_aligned_acq_rel:
+; -O1: and x10, x8, x1
+; -O1: mvn x10, x10
+; -O1: casal x9, x10, [x0]
+; -O1: cmp x9, x8
+ %r = atomicrmw nand ptr %ptr, i64 %value acq_rel, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_nand_i64_aligned_seq_cst(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_nand_i64_aligned_seq_cst:
+; -O0: and x9, x8, x9
+; -O0: mvn x10, x9
+; -O0: casal x9, x10, [x11]
+; -O0: subs x8, x9, x8
+;
+; -O1-LABEL: atomicrmw_nand_i64_aligned_seq_cst:
+; -O1: and x10, x8, x1
+; -O1: mvn x10, x10
+; -O1: casal x9, x10, [x0]
+; -O1: cmp x9, x8
+ %r = atomicrmw nand ptr %ptr, i64 %value seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_nand_i128_aligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_nand_i128_aligned_monotonic:
+; -O0: and x10, x9, x10
+; -O0: and x9, x9, x11
+; -O0: mvn x2, x10
+; -O0: mvn x9, x9
+; -O0: casp x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_nand_i128_aligned_monotonic:
+; -O1: ldp x4, x5, [x0]
+; -O1: and x8, x4, x2
+; -O1: and x9, x7, x3
+; -O1: mvn x10, x8
+; -O1: mvn x11, x9
+; -O1: casp x4, x5, x10, x11, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw nand ptr %ptr, i128 %value monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_nand_i128_aligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_nand_i128_aligned_acquire:
+; -O0: and x10, x9, x10
+; -O0: and x9, x9, x11
+; -O0: mvn x2, x10
+; -O0: mvn x9, x9
+; -O0: caspa x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_nand_i128_aligned_acquire:
+; -O1: ldp x4, x5, [x0]
+; -O1: and x8, x4, x2
+; -O1: and x9, x7, x3
+; -O1: mvn x10, x8
+; -O1: mvn x11, x9
+; -O1: caspa x4, x5, x10, x11, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw nand ptr %ptr, i128 %value acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_nand_i128_aligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_nand_i128_aligned_release:
+; -O0: and x10, x9, x10
+; -O0: and x9, x9, x11
+; -O0: mvn x2, x10
+; -O0: mvn x9, x9
+; -O0: caspl x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_nand_i128_aligned_release:
+; -O1: ldp x4, x5, [x0]
+; -O1: and x8, x4, x2
+; -O1: and x9, x7, x3
+; -O1: mvn x10, x8
+; -O1: mvn x11, x9
+; -O1: caspl x4, x5, x10, x11, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw nand ptr %ptr, i128 %value release, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_nand_i128_aligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_nand_i128_aligned_acq_rel:
+; -O0: and x10, x9, x10
+; -O0: and x9, x9, x11
+; -O0: mvn x2, x10
+; -O0: mvn x9, x9
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_nand_i128_aligned_acq_rel:
+; -O1: ldp x4, x5, [x0]
+; -O1: and x8, x4, x2
+; -O1: and x9, x7, x3
+; -O1: mvn x10, x8
+; -O1: mvn x11, x9
+; -O1: caspal x4, x5, x10, x11, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw nand ptr %ptr, i128 %value acq_rel, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_nand_i128_aligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_nand_i128_aligned_seq_cst:
+; -O0: and x10, x9, x10
+; -O0: and x9, x9, x11
+; -O0: mvn x2, x10
+; -O0: mvn x9, x9
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_nand_i128_aligned_seq_cst:
+; -O1: ldp x4, x5, [x0]
+; -O1: and x8, x4, x2
+; -O1: and x9, x7, x3
+; -O1: mvn x10, x8
+; -O1: mvn x11, x9
+; -O1: caspal x4, x5, x10, x11, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw nand ptr %ptr, i128 %value seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_nand_i8_unaligned_monotonic(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_nand_i8_unaligned_monotonic:
+; -O0: and w8, w10, w8
+; -O0: mvn w8, w8
+; -O0: casb w9, w8, [x11]
+; -O0: and w8, w9, #0xff
+; -O0: subs w8, w8, w10, uxtb
+;
+; -O1-LABEL: atomicrmw_nand_i8_unaligned_monotonic:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casb w9, w10, [x0]
+; -O1: cmp w9, w8, uxtb
+ %r = atomicrmw nand ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_nand_i8_unaligned_acquire(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_nand_i8_unaligned_acquire:
+; -O0: and w8, w10, w8
+; -O0: mvn w8, w8
+; -O0: casab w9, w8, [x11]
+; -O0: and w8, w9, #0xff
+; -O0: subs w8, w8, w10, uxtb
+;
+; -O1-LABEL: atomicrmw_nand_i8_unaligned_acquire:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casab w9, w10, [x0]
+; -O1: cmp w9, w8, uxtb
+ %r = atomicrmw nand ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_nand_i8_unaligned_release(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_nand_i8_unaligned_release:
+; -O0: and w8, w10, w8
+; -O0: mvn w8, w8
+; -O0: caslb w9, w8, [x11]
+; -O0: and w8, w9, #0xff
+; -O0: subs w8, w8, w10, uxtb
+;
+; -O1-LABEL: atomicrmw_nand_i8_unaligned_release:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: caslb w9, w10, [x0]
+; -O1: cmp w9, w8, uxtb
+ %r = atomicrmw nand ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_nand_i8_unaligned_acq_rel(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_nand_i8_unaligned_acq_rel:
+; -O0: and w8, w10, w8
+; -O0: mvn w8, w8
+; -O0: casalb w9, w8, [x11]
+; -O0: and w8, w9, #0xff
+; -O0: subs w8, w8, w10, uxtb
+;
+; -O1-LABEL: atomicrmw_nand_i8_unaligned_acq_rel:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casalb w9, w10, [x0]
+; -O1: cmp w9, w8, uxtb
+ %r = atomicrmw nand ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_nand_i8_unaligned_seq_cst(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_nand_i8_unaligned_seq_cst:
+; -O0: and w8, w10, w8
+; -O0: mvn w8, w8
+; -O0: casalb w9, w8, [x11]
+; -O0: and w8, w9, #0xff
+; -O0: subs w8, w8, w10, uxtb
+;
+; -O1-LABEL: atomicrmw_nand_i8_unaligned_seq_cst:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casalb w9, w10, [x0]
+; -O1: cmp w9, w8, uxtb
+ %r = atomicrmw nand ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_nand_i16_unaligned_monotonic(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_nand_i16_unaligned_monotonic:
+; -O0: and w8, w9, w8
+; -O0: mvn w8, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i16_unaligned_monotonic:
+; -O1: and w8, w0, w19
+; -O1: mvn w8, w8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i16 %value monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_nand_i16_unaligned_acquire(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_nand_i16_unaligned_acquire:
+; -O0: and w8, w9, w8
+; -O0: mvn w8, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i16_unaligned_acquire:
+; -O1: and w8, w0, w19
+; -O1: mvn w8, w8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i16 %value acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_nand_i16_unaligned_release(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_nand_i16_unaligned_release:
+; -O0: and w8, w9, w8
+; -O0: mvn w8, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i16_unaligned_release:
+; -O1: and w8, w0, w19
+; -O1: mvn w8, w8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i16 %value release, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_nand_i16_unaligned_acq_rel(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_nand_i16_unaligned_acq_rel:
+; -O0: and w8, w9, w8
+; -O0: mvn w8, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i16_unaligned_acq_rel:
+; -O1: and w8, w0, w19
+; -O1: mvn w8, w8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i16 %value acq_rel, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_nand_i16_unaligned_seq_cst(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_nand_i16_unaligned_seq_cst:
+; -O0: and w8, w9, w8
+; -O0: mvn w8, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i16_unaligned_seq_cst:
+; -O1: and w8, w0, w19
+; -O1: mvn w8, w8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i16 %value seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_nand_i32_unaligned_monotonic(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_nand_i32_unaligned_monotonic:
+; -O0: and w8, w9, w8
+; -O0: mvn w8, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i32_unaligned_monotonic:
+; -O1: and w8, w0, w19
+; -O1: mvn w8, w8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i32 %value monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_nand_i32_unaligned_acquire(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_nand_i32_unaligned_acquire:
+; -O0: and w8, w9, w8
+; -O0: mvn w8, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i32_unaligned_acquire:
+; -O1: and w8, w0, w19
+; -O1: mvn w8, w8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i32 %value acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_nand_i32_unaligned_release(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_nand_i32_unaligned_release:
+; -O0: and w8, w9, w8
+; -O0: mvn w8, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i32_unaligned_release:
+; -O1: and w8, w0, w19
+; -O1: mvn w8, w8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i32 %value release, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_nand_i32_unaligned_acq_rel(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_nand_i32_unaligned_acq_rel:
+; -O0: and w8, w9, w8
+; -O0: mvn w8, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i32_unaligned_acq_rel:
+; -O1: and w8, w0, w19
+; -O1: mvn w8, w8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i32 %value acq_rel, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_nand_i32_unaligned_seq_cst(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_nand_i32_unaligned_seq_cst:
+; -O0: and w8, w9, w8
+; -O0: mvn w8, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i32_unaligned_seq_cst:
+; -O1: and w8, w0, w19
+; -O1: mvn w8, w8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i32 %value seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_nand_i64_unaligned_monotonic(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_nand_i64_unaligned_monotonic:
+; -O0: and x8, x9, x8
+; -O0: mvn x8, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i64_unaligned_monotonic:
+; -O1: and x8, x0, x19
+; -O1: mvn x8, x8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i64 %value monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_nand_i64_unaligned_acquire(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_nand_i64_unaligned_acquire:
+; -O0: and x8, x9, x8
+; -O0: mvn x8, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i64_unaligned_acquire:
+; -O1: and x8, x0, x19
+; -O1: mvn x8, x8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i64 %value acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_nand_i64_unaligned_release(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_nand_i64_unaligned_release:
+; -O0: and x8, x9, x8
+; -O0: mvn x8, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i64_unaligned_release:
+; -O1: and x8, x0, x19
+; -O1: mvn x8, x8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i64 %value release, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_nand_i64_unaligned_acq_rel(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_nand_i64_unaligned_acq_rel:
+; -O0: and x8, x9, x8
+; -O0: mvn x8, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i64_unaligned_acq_rel:
+; -O1: and x8, x0, x19
+; -O1: mvn x8, x8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i64 %value acq_rel, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_nand_i64_unaligned_seq_cst(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_nand_i64_unaligned_seq_cst:
+; -O0: and x8, x9, x8
+; -O0: mvn x8, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i64_unaligned_seq_cst:
+; -O1: and x8, x0, x19
+; -O1: mvn x8, x8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i64 %value seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_nand_i128_unaligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_nand_i128_unaligned_monotonic:
+; -O0: and x9, x8, x9
+; -O0: and x8, x8, x10
+; -O0: mvn x9, x9
+; -O0: mvn x8, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i128_unaligned_monotonic:
+; -O1: ldp x0, x1, [x0]
+; -O1: and x8, x1, x19
+; -O1: and x9, x0, x20
+; -O1: mvn x8, x8
+; -O1: mvn x9, x9
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i128 %value monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_nand_i128_unaligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_nand_i128_unaligned_acquire:
+; -O0: and x9, x8, x9
+; -O0: and x8, x8, x10
+; -O0: mvn x9, x9
+; -O0: mvn x8, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i128_unaligned_acquire:
+; -O1: ldp x0, x1, [x0]
+; -O1: and x8, x1, x19
+; -O1: and x9, x0, x20
+; -O1: mvn x8, x8
+; -O1: mvn x9, x9
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i128 %value acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_nand_i128_unaligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_nand_i128_unaligned_release:
+; -O0: and x9, x8, x9
+; -O0: and x8, x8, x10
+; -O0: mvn x9, x9
+; -O0: mvn x8, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i128_unaligned_release:
+; -O1: ldp x0, x1, [x0]
+; -O1: and x8, x1, x19
+; -O1: and x9, x0, x20
+; -O1: mvn x8, x8
+; -O1: mvn x9, x9
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i128 %value release, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_nand_i128_unaligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_nand_i128_unaligned_acq_rel:
+; -O0: and x9, x8, x9
+; -O0: and x8, x8, x10
+; -O0: mvn x9, x9
+; -O0: mvn x8, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i128_unaligned_acq_rel:
+; -O1: ldp x0, x1, [x0]
+; -O1: and x8, x1, x19
+; -O1: and x9, x0, x20
+; -O1: mvn x8, x8
+; -O1: mvn x9, x9
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i128 %value acq_rel, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_nand_i128_unaligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_nand_i128_unaligned_seq_cst:
+; -O0: and x9, x8, x9
+; -O0: and x8, x8, x10
+; -O0: mvn x9, x9
+; -O0: mvn x8, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i128_unaligned_seq_cst:
+; -O1: ldp x0, x1, [x0]
+; -O1: and x8, x1, x19
+; -O1: and x9, x0, x20
+; -O1: mvn x8, x8
+; -O1: mvn x9, x9
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i128 %value seq_cst, align 1
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_or_i8_aligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_or_i8_aligned_monotonic:
+; CHECK: ldsetb w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_or_i8_aligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_or_i8_aligned_acquire:
+; CHECK: ldsetab w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_or_i8_aligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_or_i8_aligned_release:
+; CHECK: ldsetlb w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_or_i8_aligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_or_i8_aligned_acq_rel:
+; CHECK: ldsetalb w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_or_i8_aligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_or_i8_aligned_seq_cst:
+; CHECK: ldsetalb w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_or_i16_aligned_monotonic(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_or_i16_aligned_monotonic:
+; CHECK: ldseth w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i16 %value monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_or_i16_aligned_acquire(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_or_i16_aligned_acquire:
+; CHECK: ldsetah w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i16 %value acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_or_i16_aligned_release(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_or_i16_aligned_release:
+; CHECK: ldsetlh w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i16 %value release, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_or_i16_aligned_acq_rel(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_or_i16_aligned_acq_rel:
+; CHECK: ldsetalh w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i16 %value acq_rel, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_or_i16_aligned_seq_cst(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_or_i16_aligned_seq_cst:
+; CHECK: ldsetalh w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i16 %value seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_or_i32_aligned_monotonic(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_or_i32_aligned_monotonic:
+; CHECK: ldset w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i32 %value monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_or_i32_aligned_acquire(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_or_i32_aligned_acquire:
+; CHECK: ldseta w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i32 %value acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_or_i32_aligned_release(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_or_i32_aligned_release:
+; CHECK: ldsetl w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i32 %value release, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_or_i32_aligned_acq_rel(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_or_i32_aligned_acq_rel:
+; CHECK: ldsetal w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i32 %value acq_rel, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_or_i32_aligned_seq_cst(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_or_i32_aligned_seq_cst:
+; CHECK: ldsetal w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i32 %value seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_or_i64_aligned_monotonic(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_or_i64_aligned_monotonic:
+; CHECK: ldset x1, x0, [x0]
+ %r = atomicrmw or ptr %ptr, i64 %value monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_or_i64_aligned_acquire(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_or_i64_aligned_acquire:
+; CHECK: ldseta x1, x0, [x0]
+ %r = atomicrmw or ptr %ptr, i64 %value acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_or_i64_aligned_release(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_or_i64_aligned_release:
+; CHECK: ldsetl x1, x0, [x0]
+ %r = atomicrmw or ptr %ptr, i64 %value release, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_or_i64_aligned_acq_rel(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_or_i64_aligned_acq_rel:
+; CHECK: ldsetal x1, x0, [x0]
+ %r = atomicrmw or ptr %ptr, i64 %value acq_rel, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_or_i64_aligned_seq_cst(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_or_i64_aligned_seq_cst:
+; CHECK: ldsetal x1, x0, [x0]
+ %r = atomicrmw or ptr %ptr, i64 %value seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_or_i128_aligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_or_i128_aligned_monotonic:
+; -O0: ldsetp x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_or_i128_aligned_monotonic:
+; -O1: ldsetp x2, x1, [x0]
+ %r = atomicrmw or ptr %ptr, i128 %value monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_or_i128_aligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_or_i128_aligned_acquire:
+; -O0: ldsetpa x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_or_i128_aligned_acquire:
+; -O1: ldsetpa x2, x1, [x0]
+ %r = atomicrmw or ptr %ptr, i128 %value acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_or_i128_aligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_or_i128_aligned_release:
+; -O0: ldsetpl x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_or_i128_aligned_release:
+; -O1: ldsetpl x2, x1, [x0]
+ %r = atomicrmw or ptr %ptr, i128 %value release, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_or_i128_aligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_or_i128_aligned_acq_rel:
+; -O0: ldsetpal x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_or_i128_aligned_acq_rel:
+; -O1: ldsetpal x2, x1, [x0]
+ %r = atomicrmw or ptr %ptr, i128 %value acq_rel, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_or_i128_aligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_or_i128_aligned_seq_cst:
+; -O0: ldsetpal x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_or_i128_aligned_seq_cst:
+; -O1: ldsetpal x2, x1, [x0]
+ %r = atomicrmw or ptr %ptr, i128 %value seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_or_i8_unaligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_or_i8_unaligned_monotonic:
+; CHECK: ldsetb w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_or_i8_unaligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_or_i8_unaligned_acquire:
+; CHECK: ldsetab w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_or_i8_unaligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_or_i8_unaligned_release:
+; CHECK: ldsetlb w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_or_i8_unaligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_or_i8_unaligned_acq_rel:
+; CHECK: ldsetalb w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_or_i8_unaligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_or_i8_unaligned_seq_cst:
+; CHECK: ldsetalb w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_or_i16_unaligned_monotonic(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_or_i16_unaligned_monotonic:
+; -O0: orr w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i16_unaligned_monotonic:
+; -O1: orr w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i16 %value monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_or_i16_unaligned_acquire(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_or_i16_unaligned_acquire:
+; -O0: orr w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i16_unaligned_acquire:
+; -O1: orr w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i16 %value acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_or_i16_unaligned_release(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_or_i16_unaligned_release:
+; -O0: orr w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i16_unaligned_release:
+; -O1: orr w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i16 %value release, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_or_i16_unaligned_acq_rel(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_or_i16_unaligned_acq_rel:
+; -O0: orr w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i16_unaligned_acq_rel:
+; -O1: orr w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i16 %value acq_rel, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_or_i16_unaligned_seq_cst(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_or_i16_unaligned_seq_cst:
+; -O0: orr w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i16_unaligned_seq_cst:
+; -O1: orr w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i16 %value seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_or_i32_unaligned_monotonic(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_or_i32_unaligned_monotonic:
+; -O0: orr w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i32_unaligned_monotonic:
+; -O1: orr w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i32 %value monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_or_i32_unaligned_acquire(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_or_i32_unaligned_acquire:
+; -O0: orr w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i32_unaligned_acquire:
+; -O1: orr w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i32 %value acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_or_i32_unaligned_release(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_or_i32_unaligned_release:
+; -O0: orr w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i32_unaligned_release:
+; -O1: orr w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i32 %value release, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_or_i32_unaligned_acq_rel(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_or_i32_unaligned_acq_rel:
+; -O0: orr w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i32_unaligned_acq_rel:
+; -O1: orr w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i32 %value acq_rel, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_or_i32_unaligned_seq_cst(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_or_i32_unaligned_seq_cst:
+; -O0: orr w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i32_unaligned_seq_cst:
+; -O1: orr w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i32 %value seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_or_i64_unaligned_monotonic(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_or_i64_unaligned_monotonic:
+; -O0: orr x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i64_unaligned_monotonic:
+; -O1: orr x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i64 %value monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_or_i64_unaligned_acquire(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_or_i64_unaligned_acquire:
+; -O0: orr x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i64_unaligned_acquire:
+; -O1: orr x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i64 %value acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_or_i64_unaligned_release(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_or_i64_unaligned_release:
+; -O0: orr x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i64_unaligned_release:
+; -O1: orr x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i64 %value release, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_or_i64_unaligned_acq_rel(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_or_i64_unaligned_acq_rel:
+; -O0: orr x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i64_unaligned_acq_rel:
+; -O1: orr x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i64 %value acq_rel, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_or_i64_unaligned_seq_cst(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_or_i64_unaligned_seq_cst:
+; -O0: orr x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i64_unaligned_seq_cst:
+; -O1: orr x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i64 %value seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_or_i128_unaligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_or_i128_unaligned_monotonic:
+; -O0: orr x9, x8, x9
+; -O0: orr x8, x8, x10
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i128_unaligned_monotonic:
+; -O1: ldp x0, x1, [x0]
+; -O1: orr x8, x1, x19
+; -O1: orr x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i128 %value monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_or_i128_unaligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_or_i128_unaligned_acquire:
+; -O0: orr x9, x8, x9
+; -O0: orr x8, x8, x10
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i128_unaligned_acquire:
+; -O1: ldp x0, x1, [x0]
+; -O1: orr x8, x1, x19
+; -O1: orr x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i128 %value acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_or_i128_unaligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_or_i128_unaligned_release:
+; -O0: orr x9, x8, x9
+; -O0: orr x8, x8, x10
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i128_unaligned_release:
+; -O1: ldp x0, x1, [x0]
+; -O1: orr x8, x1, x19
+; -O1: orr x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i128 %value release, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_or_i128_unaligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_or_i128_unaligned_acq_rel:
+; -O0: orr x9, x8, x9
+; -O0: orr x8, x8, x10
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i128_unaligned_acq_rel:
+; -O1: ldp x0, x1, [x0]
+; -O1: orr x8, x1, x19
+; -O1: orr x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i128 %value acq_rel, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_or_i128_unaligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_or_i128_unaligned_seq_cst:
+; -O0: orr x9, x8, x9
+; -O0: orr x8, x8, x10
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i128_unaligned_seq_cst:
+; -O1: ldp x0, x1, [x0]
+; -O1: orr x8, x1, x19
+; -O1: orr x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i128 %value seq_cst, align 1
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_xor_i8_aligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xor_i8_aligned_monotonic:
+; CHECK: ldeorb w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xor_i8_aligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xor_i8_aligned_acquire:
+; CHECK: ldeorab w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xor_i8_aligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xor_i8_aligned_release:
+; CHECK: ldeorlb w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xor_i8_aligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xor_i8_aligned_acq_rel:
+; CHECK: ldeoralb w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xor_i8_aligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xor_i8_aligned_seq_cst:
+; CHECK: ldeoralb w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_xor_i16_aligned_monotonic(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xor_i16_aligned_monotonic:
+; CHECK: ldeorh w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i16 %value monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xor_i16_aligned_acquire(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xor_i16_aligned_acquire:
+; CHECK: ldeorah w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i16 %value acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xor_i16_aligned_release(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xor_i16_aligned_release:
+; CHECK: ldeorlh w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i16 %value release, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xor_i16_aligned_acq_rel(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xor_i16_aligned_acq_rel:
+; CHECK: ldeoralh w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i16 %value acq_rel, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xor_i16_aligned_seq_cst(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xor_i16_aligned_seq_cst:
+; CHECK: ldeoralh w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i16 %value seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_xor_i32_aligned_monotonic(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xor_i32_aligned_monotonic:
+; CHECK: ldeor w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i32 %value monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xor_i32_aligned_acquire(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xor_i32_aligned_acquire:
+; CHECK: ldeora w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i32 %value acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xor_i32_aligned_release(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xor_i32_aligned_release:
+; CHECK: ldeorl w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i32 %value release, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xor_i32_aligned_acq_rel(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xor_i32_aligned_acq_rel:
+; CHECK: ldeoral w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i32 %value acq_rel, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xor_i32_aligned_seq_cst(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xor_i32_aligned_seq_cst:
+; CHECK: ldeoral w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i32 %value seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_xor_i64_aligned_monotonic(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xor_i64_aligned_monotonic:
+; CHECK: ldeor x1, x0, [x0]
+ %r = atomicrmw xor ptr %ptr, i64 %value monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xor_i64_aligned_acquire(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xor_i64_aligned_acquire:
+; CHECK: ldeora x1, x0, [x0]
+ %r = atomicrmw xor ptr %ptr, i64 %value acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xor_i64_aligned_release(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xor_i64_aligned_release:
+; CHECK: ldeorl x1, x0, [x0]
+ %r = atomicrmw xor ptr %ptr, i64 %value release, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xor_i64_aligned_acq_rel(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xor_i64_aligned_acq_rel:
+; CHECK: ldeoral x1, x0, [x0]
+ %r = atomicrmw xor ptr %ptr, i64 %value acq_rel, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xor_i64_aligned_seq_cst(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xor_i64_aligned_seq_cst:
+; CHECK: ldeoral x1, x0, [x0]
+ %r = atomicrmw xor ptr %ptr, i64 %value seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_xor_i128_aligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xor_i128_aligned_monotonic:
+; -O0: eor x2, x9, x11
+; -O0: eor x9, x9, x10
+; -O0: casp x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_xor_i128_aligned_monotonic:
+; -O1: ldp x4, x5, [x0]
+; -O1: eor x8, x4, x2
+; -O1: eor x9, x7, x3
+; -O1: casp x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw xor ptr %ptr, i128 %value monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xor_i128_aligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xor_i128_aligned_acquire:
+; -O0: eor x2, x9, x11
+; -O0: eor x9, x9, x10
+; -O0: caspa x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_xor_i128_aligned_acquire:
+; -O1: ldp x4, x5, [x0]
+; -O1: eor x8, x4, x2
+; -O1: eor x9, x7, x3
+; -O1: caspa x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw xor ptr %ptr, i128 %value acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xor_i128_aligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xor_i128_aligned_release:
+; -O0: eor x2, x9, x11
+; -O0: eor x9, x9, x10
+; -O0: caspl x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_xor_i128_aligned_release:
+; -O1: ldp x4, x5, [x0]
+; -O1: eor x8, x4, x2
+; -O1: eor x9, x7, x3
+; -O1: caspl x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw xor ptr %ptr, i128 %value release, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xor_i128_aligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xor_i128_aligned_acq_rel:
+; -O0: eor x2, x9, x11
+; -O0: eor x9, x9, x10
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_xor_i128_aligned_acq_rel:
+; -O1: ldp x4, x5, [x0]
+; -O1: eor x8, x4, x2
+; -O1: eor x9, x7, x3
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw xor ptr %ptr, i128 %value acq_rel, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xor_i128_aligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xor_i128_aligned_seq_cst:
+; -O0: eor x2, x9, x11
+; -O0: eor x9, x9, x10
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_xor_i128_aligned_seq_cst:
+; -O1: ldp x4, x5, [x0]
+; -O1: eor x8, x4, x2
+; -O1: eor x9, x7, x3
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw xor ptr %ptr, i128 %value seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_xor_i8_unaligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xor_i8_unaligned_monotonic:
+; CHECK: ldeorb w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xor_i8_unaligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xor_i8_unaligned_acquire:
+; CHECK: ldeorab w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xor_i8_unaligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xor_i8_unaligned_release:
+; CHECK: ldeorlb w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xor_i8_unaligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xor_i8_unaligned_acq_rel:
+; CHECK: ldeoralb w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xor_i8_unaligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xor_i8_unaligned_seq_cst:
+; CHECK: ldeoralb w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_xor_i16_unaligned_monotonic(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_xor_i16_unaligned_monotonic:
+; -O0: eor w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i16_unaligned_monotonic:
+; -O1: eor w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i16 %value monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xor_i16_unaligned_acquire(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_xor_i16_unaligned_acquire:
+; -O0: eor w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i16_unaligned_acquire:
+; -O1: eor w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i16 %value acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xor_i16_unaligned_release(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_xor_i16_unaligned_release:
+; -O0: eor w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i16_unaligned_release:
+; -O1: eor w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i16 %value release, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xor_i16_unaligned_acq_rel(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_xor_i16_unaligned_acq_rel:
+; -O0: eor w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i16_unaligned_acq_rel:
+; -O1: eor w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i16 %value acq_rel, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xor_i16_unaligned_seq_cst(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_xor_i16_unaligned_seq_cst:
+; -O0: eor w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i16_unaligned_seq_cst:
+; -O1: eor w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i16 %value seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_xor_i32_unaligned_monotonic(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_xor_i32_unaligned_monotonic:
+; -O0: eor w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i32_unaligned_monotonic:
+; -O1: eor w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i32 %value monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xor_i32_unaligned_acquire(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_xor_i32_unaligned_acquire:
+; -O0: eor w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i32_unaligned_acquire:
+; -O1: eor w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i32 %value acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xor_i32_unaligned_release(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_xor_i32_unaligned_release:
+; -O0: eor w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i32_unaligned_release:
+; -O1: eor w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i32 %value release, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xor_i32_unaligned_acq_rel(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_xor_i32_unaligned_acq_rel:
+; -O0: eor w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i32_unaligned_acq_rel:
+; -O1: eor w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i32 %value acq_rel, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xor_i32_unaligned_seq_cst(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_xor_i32_unaligned_seq_cst:
+; -O0: eor w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i32_unaligned_seq_cst:
+; -O1: eor w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i32 %value seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_xor_i64_unaligned_monotonic(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_xor_i64_unaligned_monotonic:
+; -O0: eor x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i64_unaligned_monotonic:
+; -O1: eor x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i64 %value monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xor_i64_unaligned_acquire(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_xor_i64_unaligned_acquire:
+; -O0: eor x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i64_unaligned_acquire:
+; -O1: eor x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i64 %value acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xor_i64_unaligned_release(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_xor_i64_unaligned_release:
+; -O0: eor x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i64_unaligned_release:
+; -O1: eor x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i64 %value release, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xor_i64_unaligned_acq_rel(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_xor_i64_unaligned_acq_rel:
+; -O0: eor x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i64_unaligned_acq_rel:
+; -O1: eor x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i64 %value acq_rel, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xor_i64_unaligned_seq_cst(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_xor_i64_unaligned_seq_cst:
+; -O0: eor x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i64_unaligned_seq_cst:
+; -O1: eor x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i64 %value seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_xor_i128_unaligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xor_i128_unaligned_monotonic:
+; -O0: eor x9, x8, x9
+; -O0: eor x8, x8, x10
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i128_unaligned_monotonic:
+; -O1: ldp x0, x1, [x0]
+; -O1: eor x8, x1, x19
+; -O1: eor x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i128 %value monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xor_i128_unaligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xor_i128_unaligned_acquire:
+; -O0: eor x9, x8, x9
+; -O0: eor x8, x8, x10
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i128_unaligned_acquire:
+; -O1: ldp x0, x1, [x0]
+; -O1: eor x8, x1, x19
+; -O1: eor x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i128 %value acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xor_i128_unaligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xor_i128_unaligned_release:
+; -O0: eor x9, x8, x9
+; -O0: eor x8, x8, x10
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i128_unaligned_release:
+; -O1: ldp x0, x1, [x0]
+; -O1: eor x8, x1, x19
+; -O1: eor x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i128 %value release, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xor_i128_unaligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xor_i128_unaligned_acq_rel:
+; -O0: eor x9, x8, x9
+; -O0: eor x8, x8, x10
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i128_unaligned_acq_rel:
+; -O1: ldp x0, x1, [x0]
+; -O1: eor x8, x1, x19
+; -O1: eor x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i128 %value acq_rel, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xor_i128_unaligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xor_i128_unaligned_seq_cst:
+; -O0: eor x9, x8, x9
+; -O0: eor x8, x8, x10
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i128_unaligned_seq_cst:
+; -O1: ldp x0, x1, [x0]
+; -O1: eor x8, x1, x19
+; -O1: eor x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i128 %value seq_cst, align 1
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_max_i8_aligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_max_i8_aligned_monotonic:
+; CHECK: ldsmaxb w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_max_i8_aligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_max_i8_aligned_acquire:
+; CHECK: ldsmaxab w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_max_i8_aligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_max_i8_aligned_release:
+; CHECK: ldsmaxlb w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_max_i8_aligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_max_i8_aligned_acq_rel:
+; CHECK: ldsmaxalb w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_max_i8_aligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_max_i8_aligned_seq_cst:
+; CHECK: ldsmaxalb w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_max_i16_aligned_monotonic(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_max_i16_aligned_monotonic:
+; CHECK: ldsmaxh w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i16 %value monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_max_i16_aligned_acquire(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_max_i16_aligned_acquire:
+; CHECK: ldsmaxah w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i16 %value acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_max_i16_aligned_release(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_max_i16_aligned_release:
+; CHECK: ldsmaxlh w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i16 %value release, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_max_i16_aligned_acq_rel(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_max_i16_aligned_acq_rel:
+; CHECK: ldsmaxalh w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i16 %value acq_rel, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_max_i16_aligned_seq_cst(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_max_i16_aligned_seq_cst:
+; CHECK: ldsmaxalh w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i16 %value seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_max_i32_aligned_monotonic(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_max_i32_aligned_monotonic:
+; CHECK: ldsmax w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i32 %value monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_max_i32_aligned_acquire(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_max_i32_aligned_acquire:
+; CHECK: ldsmaxa w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i32 %value acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_max_i32_aligned_release(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_max_i32_aligned_release:
+; CHECK: ldsmaxl w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i32 %value release, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_max_i32_aligned_acq_rel(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_max_i32_aligned_acq_rel:
+; CHECK: ldsmaxal w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i32 %value acq_rel, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_max_i32_aligned_seq_cst(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_max_i32_aligned_seq_cst:
+; CHECK: ldsmaxal w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i32 %value seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_max_i64_aligned_monotonic(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_max_i64_aligned_monotonic:
+; CHECK: ldsmax x1, x0, [x0]
+ %r = atomicrmw max ptr %ptr, i64 %value monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_max_i64_aligned_acquire(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_max_i64_aligned_acquire:
+; CHECK: ldsmaxa x1, x0, [x0]
+ %r = atomicrmw max ptr %ptr, i64 %value acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_max_i64_aligned_release(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_max_i64_aligned_release:
+; CHECK: ldsmaxl x1, x0, [x0]
+ %r = atomicrmw max ptr %ptr, i64 %value release, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_max_i64_aligned_acq_rel(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_max_i64_aligned_acq_rel:
+; CHECK: ldsmaxal x1, x0, [x0]
+ %r = atomicrmw max ptr %ptr, i64 %value acq_rel, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_max_i64_aligned_seq_cst(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_max_i64_aligned_seq_cst:
+; CHECK: ldsmaxal x1, x0, [x0]
+ %r = atomicrmw max ptr %ptr, i64 %value seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_max_i128_aligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_max_i128_aligned_monotonic:
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x12
+; -O0: and w13, w13, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel w9, w9, w11, ne
+; -O0: and w13, w9, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel x2, x11, x12, ne
+; -O0: and w11, w9, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x9, x9, x10, ne
+; -O0: casp x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_max_i128_aligned_monotonic:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x2, x4
+; -O1: csel x9, x7, x3, lt
+; -O1: csel x8, x4, x2, lt
+; -O1: casp x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw max ptr %ptr, i128 %value monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_max_i128_aligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_max_i128_aligned_acquire:
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x12
+; -O0: and w13, w13, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel w9, w9, w11, ne
+; -O0: and w13, w9, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel x2, x11, x12, ne
+; -O0: and w11, w9, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x9, x9, x10, ne
+; -O0: caspa x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_max_i128_aligned_acquire:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x2, x4
+; -O1: csel x9, x7, x3, lt
+; -O1: csel x8, x4, x2, lt
+; -O1: caspa x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw max ptr %ptr, i128 %value acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_max_i128_aligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_max_i128_aligned_release:
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x12
+; -O0: and w13, w13, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel w9, w9, w11, ne
+; -O0: and w13, w9, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel x2, x11, x12, ne
+; -O0: and w11, w9, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x9, x9, x10, ne
+; -O0: caspl x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_max_i128_aligned_release:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x2, x4
+; -O1: csel x9, x7, x3, lt
+; -O1: csel x8, x4, x2, lt
+; -O1: caspl x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw max ptr %ptr, i128 %value release, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_max_i128_aligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_max_i128_aligned_acq_rel:
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x12
+; -O0: and w13, w13, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel w9, w9, w11, ne
+; -O0: and w13, w9, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel x2, x11, x12, ne
+; -O0: and w11, w9, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x9, x9, x10, ne
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_max_i128_aligned_acq_rel:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x2, x4
+; -O1: csel x9, x7, x3, lt
+; -O1: csel x8, x4, x2, lt
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw max ptr %ptr, i128 %value acq_rel, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_max_i128_aligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_max_i128_aligned_seq_cst:
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x12
+; -O0: and w13, w13, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel w9, w9, w11, ne
+; -O0: and w13, w9, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel x2, x11, x12, ne
+; -O0: and w11, w9, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x9, x9, x10, ne
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_max_i128_aligned_seq_cst:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x2, x4
+; -O1: csel x9, x7, x3, lt
+; -O1: csel x8, x4, x2, lt
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw max ptr %ptr, i128 %value seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_max_i8_unaligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_max_i8_unaligned_monotonic:
+; CHECK: ldsmaxb w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_max_i8_unaligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_max_i8_unaligned_acquire:
+; CHECK: ldsmaxab w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_max_i8_unaligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_max_i8_unaligned_release:
+; CHECK: ldsmaxlb w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_max_i8_unaligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_max_i8_unaligned_acq_rel:
+; CHECK: ldsmaxalb w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_max_i8_unaligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_max_i8_unaligned_seq_cst:
+; CHECK: ldsmaxalb w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_max_i16_unaligned_monotonic(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_max_i16_unaligned_monotonic:
+; -O0: sxth w10, w9
+; -O0: subs w10, w10, w8, sxth
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i16_unaligned_monotonic:
+; -O1: sxth w8, w0
+; -O1: cmp w8, w19, sxth
+; -O1: csel w8, w0, w19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i16 %value monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_max_i16_unaligned_acquire(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_max_i16_unaligned_acquire:
+; -O0: sxth w10, w9
+; -O0: subs w10, w10, w8, sxth
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i16_unaligned_acquire:
+; -O1: sxth w8, w0
+; -O1: cmp w8, w19, sxth
+; -O1: csel w8, w0, w19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i16 %value acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_max_i16_unaligned_release(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_max_i16_unaligned_release:
+; -O0: sxth w10, w9
+; -O0: subs w10, w10, w8, sxth
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i16_unaligned_release:
+; -O1: sxth w8, w0
+; -O1: cmp w8, w19, sxth
+; -O1: csel w8, w0, w19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i16 %value release, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_max_i16_unaligned_acq_rel(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_max_i16_unaligned_acq_rel:
+; -O0: sxth w10, w9
+; -O0: subs w10, w10, w8, sxth
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i16_unaligned_acq_rel:
+; -O1: sxth w8, w0
+; -O1: cmp w8, w19, sxth
+; -O1: csel w8, w0, w19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i16 %value acq_rel, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_max_i16_unaligned_seq_cst(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_max_i16_unaligned_seq_cst:
+; -O0: sxth w10, w9
+; -O0: subs w10, w10, w8, sxth
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i16_unaligned_seq_cst:
+; -O1: sxth w8, w0
+; -O1: cmp w8, w19, sxth
+; -O1: csel w8, w0, w19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i16 %value seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_max_i32_unaligned_monotonic(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_max_i32_unaligned_monotonic:
+; -O0: subs w10, w9, w8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i32_unaligned_monotonic:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i32 %value monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_max_i32_unaligned_acquire(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_max_i32_unaligned_acquire:
+; -O0: subs w10, w9, w8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i32_unaligned_acquire:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i32 %value acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_max_i32_unaligned_release(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_max_i32_unaligned_release:
+; -O0: subs w10, w9, w8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i32_unaligned_release:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i32 %value release, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_max_i32_unaligned_acq_rel(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_max_i32_unaligned_acq_rel:
+; -O0: subs w10, w9, w8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i32_unaligned_acq_rel:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i32 %value acq_rel, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_max_i32_unaligned_seq_cst(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_max_i32_unaligned_seq_cst:
+; -O0: subs w10, w9, w8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i32_unaligned_seq_cst:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i32 %value seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_max_i64_unaligned_monotonic(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_max_i64_unaligned_monotonic:
+; -O0: subs x10, x9, x8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel x8, x9, x8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i64_unaligned_monotonic:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i64 %value monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_max_i64_unaligned_acquire(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_max_i64_unaligned_acquire:
+; -O0: subs x10, x9, x8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel x8, x9, x8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i64_unaligned_acquire:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i64 %value acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_max_i64_unaligned_release(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_max_i64_unaligned_release:
+; -O0: subs x10, x9, x8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel x8, x9, x8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i64_unaligned_release:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i64 %value release, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_max_i64_unaligned_acq_rel(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_max_i64_unaligned_acq_rel:
+; -O0: subs x10, x9, x8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel x8, x9, x8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i64_unaligned_acq_rel:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i64 %value acq_rel, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_max_i64_unaligned_seq_cst(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_max_i64_unaligned_seq_cst:
+; -O0: subs x10, x9, x8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel x8, x9, x8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i64_unaligned_seq_cst:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i64 %value seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_max_i128_unaligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_max_i128_unaligned_monotonic:
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x11
+; -O0: and w12, w12, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel w8, w8, w9, ne
+; -O0: and w12, w8, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel x9, x9, x11, ne
+; -O0: and w11, w8, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x8, x8, x10, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i128_unaligned_monotonic:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x20, x0
+; -O1: csel x8, x1, x19, lt
+; -O1: csel x9, x0, x20, lt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i128 %value monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_max_i128_unaligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_max_i128_unaligned_acquire:
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x11
+; -O0: and w12, w12, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel w8, w8, w9, ne
+; -O0: and w12, w8, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel x9, x9, x11, ne
+; -O0: and w11, w8, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x8, x8, x10, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i128_unaligned_acquire:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x20, x0
+; -O1: csel x8, x1, x19, lt
+; -O1: csel x9, x0, x20, lt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i128 %value acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_max_i128_unaligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_max_i128_unaligned_release:
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x11
+; -O0: and w12, w12, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel w8, w8, w9, ne
+; -O0: and w12, w8, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel x9, x9, x11, ne
+; -O0: and w11, w8, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x8, x8, x10, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i128_unaligned_release:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x20, x0
+; -O1: csel x8, x1, x19, lt
+; -O1: csel x9, x0, x20, lt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i128 %value release, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_max_i128_unaligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_max_i128_unaligned_acq_rel:
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x11
+; -O0: and w12, w12, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel w8, w8, w9, ne
+; -O0: and w12, w8, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel x9, x9, x11, ne
+; -O0: and w11, w8, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x8, x8, x10, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i128_unaligned_acq_rel:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x20, x0
+; -O1: csel x8, x1, x19, lt
+; -O1: csel x9, x0, x20, lt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i128 %value acq_rel, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_max_i128_unaligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_max_i128_unaligned_seq_cst:
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x11
+; -O0: and w12, w12, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel w8, w8, w9, ne
+; -O0: and w12, w8, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel x9, x9, x11, ne
+; -O0: and w11, w8, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x8, x8, x10, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i128_unaligned_seq_cst:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x20, x0
+; -O1: csel x8, x1, x19, lt
+; -O1: csel x9, x0, x20, lt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i128 %value seq_cst, align 1
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_min_i8_aligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_min_i8_aligned_monotonic:
+; CHECK: ldsminb w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_min_i8_aligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_min_i8_aligned_acquire:
+; CHECK: ldsminab w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_min_i8_aligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_min_i8_aligned_release:
+; CHECK: ldsminlb w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_min_i8_aligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_min_i8_aligned_acq_rel:
+; CHECK: ldsminalb w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_min_i8_aligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_min_i8_aligned_seq_cst:
+; CHECK: ldsminalb w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_min_i16_aligned_monotonic(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_min_i16_aligned_monotonic:
+; CHECK: ldsminh w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i16 %value monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_min_i16_aligned_acquire(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_min_i16_aligned_acquire:
+; CHECK: ldsminah w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i16 %value acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_min_i16_aligned_release(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_min_i16_aligned_release:
+; CHECK: ldsminlh w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i16 %value release, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_min_i16_aligned_acq_rel(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_min_i16_aligned_acq_rel:
+; CHECK: ldsminalh w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i16 %value acq_rel, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_min_i16_aligned_seq_cst(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_min_i16_aligned_seq_cst:
+; CHECK: ldsminalh w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i16 %value seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_min_i32_aligned_monotonic(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_min_i32_aligned_monotonic:
+; CHECK: ldsmin w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i32 %value monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_min_i32_aligned_acquire(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_min_i32_aligned_acquire:
+; CHECK: ldsmina w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i32 %value acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_min_i32_aligned_release(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_min_i32_aligned_release:
+; CHECK: ldsminl w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i32 %value release, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_min_i32_aligned_acq_rel(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_min_i32_aligned_acq_rel:
+; CHECK: ldsminal w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i32 %value acq_rel, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_min_i32_aligned_seq_cst(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_min_i32_aligned_seq_cst:
+; CHECK: ldsminal w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i32 %value seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_min_i64_aligned_monotonic(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_min_i64_aligned_monotonic:
+; CHECK: ldsmin x1, x0, [x0]
+ %r = atomicrmw min ptr %ptr, i64 %value monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_min_i64_aligned_acquire(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_min_i64_aligned_acquire:
+; CHECK: ldsmina x1, x0, [x0]
+ %r = atomicrmw min ptr %ptr, i64 %value acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_min_i64_aligned_release(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_min_i64_aligned_release:
+; CHECK: ldsminl x1, x0, [x0]
+ %r = atomicrmw min ptr %ptr, i64 %value release, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_min_i64_aligned_acq_rel(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_min_i64_aligned_acq_rel:
+; CHECK: ldsminal x1, x0, [x0]
+ %r = atomicrmw min ptr %ptr, i64 %value acq_rel, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_min_i64_aligned_seq_cst(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_min_i64_aligned_seq_cst:
+; CHECK: ldsminal x1, x0, [x0]
+ %r = atomicrmw min ptr %ptr, i64 %value seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_min_i128_aligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_min_i128_aligned_monotonic:
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x12
+; -O0: and w13, w13, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel w9, w9, w11, ne
+; -O0: and w13, w9, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel x2, x11, x12, ne
+; -O0: and w11, w9, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x9, x9, x10, ne
+; -O0: casp x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_min_i128_aligned_monotonic:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x2, x4
+; -O1: csel x9, x7, x3, ge
+; -O1: csel x8, x4, x2, ge
+; -O1: casp x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw min ptr %ptr, i128 %value monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_min_i128_aligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_min_i128_aligned_acquire:
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x12
+; -O0: and w13, w13, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel w9, w9, w11, ne
+; -O0: and w13, w9, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel x2, x11, x12, ne
+; -O0: and w11, w9, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x9, x9, x10, ne
+; -O0: caspa x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_min_i128_aligned_acquire:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x2, x4
+; -O1: csel x9, x7, x3, ge
+; -O1: csel x8, x4, x2, ge
+; -O1: caspa x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw min ptr %ptr, i128 %value acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_min_i128_aligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_min_i128_aligned_release:
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x12
+; -O0: and w13, w13, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel w9, w9, w11, ne
+; -O0: and w13, w9, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel x2, x11, x12, ne
+; -O0: and w11, w9, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x9, x9, x10, ne
+; -O0: caspl x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_min_i128_aligned_release:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x2, x4
+; -O1: csel x9, x7, x3, ge
+; -O1: csel x8, x4, x2, ge
+; -O1: caspl x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw min ptr %ptr, i128 %value release, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_min_i128_aligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_min_i128_aligned_acq_rel:
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x12
+; -O0: and w13, w13, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel w9, w9, w11, ne
+; -O0: and w13, w9, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel x2, x11, x12, ne
+; -O0: and w11, w9, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x9, x9, x10, ne
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_min_i128_aligned_acq_rel:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x2, x4
+; -O1: csel x9, x7, x3, ge
+; -O1: csel x8, x4, x2, ge
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw min ptr %ptr, i128 %value acq_rel, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_min_i128_aligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_min_i128_aligned_seq_cst:
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x12
+; -O0: and w13, w13, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel w9, w9, w11, ne
+; -O0: and w13, w9, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel x2, x11, x12, ne
+; -O0: and w11, w9, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x9, x9, x10, ne
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_min_i128_aligned_seq_cst:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x2, x4
+; -O1: csel x9, x7, x3, ge
+; -O1: csel x8, x4, x2, ge
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw min ptr %ptr, i128 %value seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_min_i8_unaligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_min_i8_unaligned_monotonic:
+; CHECK: ldsminb w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_min_i8_unaligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_min_i8_unaligned_acquire:
+; CHECK: ldsminab w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_min_i8_unaligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_min_i8_unaligned_release:
+; CHECK: ldsminlb w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_min_i8_unaligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_min_i8_unaligned_acq_rel:
+; CHECK: ldsminalb w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_min_i8_unaligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_min_i8_unaligned_seq_cst:
+; CHECK: ldsminalb w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_min_i16_unaligned_monotonic(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_min_i16_unaligned_monotonic:
+; -O0: sxth w10, w9
+; -O0: subs w10, w10, w8, sxth
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i16_unaligned_monotonic:
+; -O1: sxth w8, w0
+; -O1: cmp w8, w19, sxth
+; -O1: csel w8, w0, w19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i16 %value monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_min_i16_unaligned_acquire(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_min_i16_unaligned_acquire:
+; -O0: sxth w10, w9
+; -O0: subs w10, w10, w8, sxth
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i16_unaligned_acquire:
+; -O1: sxth w8, w0
+; -O1: cmp w8, w19, sxth
+; -O1: csel w8, w0, w19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i16 %value acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_min_i16_unaligned_release(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_min_i16_unaligned_release:
+; -O0: sxth w10, w9
+; -O0: subs w10, w10, w8, sxth
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i16_unaligned_release:
+; -O1: sxth w8, w0
+; -O1: cmp w8, w19, sxth
+; -O1: csel w8, w0, w19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i16 %value release, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_min_i16_unaligned_acq_rel(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_min_i16_unaligned_acq_rel:
+; -O0: sxth w10, w9
+; -O0: subs w10, w10, w8, sxth
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i16_unaligned_acq_rel:
+; -O1: sxth w8, w0
+; -O1: cmp w8, w19, sxth
+; -O1: csel w8, w0, w19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i16 %value acq_rel, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_min_i16_unaligned_seq_cst(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_min_i16_unaligned_seq_cst:
+; -O0: sxth w10, w9
+; -O0: subs w10, w10, w8, sxth
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i16_unaligned_seq_cst:
+; -O1: sxth w8, w0
+; -O1: cmp w8, w19, sxth
+; -O1: csel w8, w0, w19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i16 %value seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_min_i32_unaligned_monotonic(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_min_i32_unaligned_monotonic:
+; -O0: subs w10, w9, w8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i32_unaligned_monotonic:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i32 %value monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_min_i32_unaligned_acquire(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_min_i32_unaligned_acquire:
+; -O0: subs w10, w9, w8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i32_unaligned_acquire:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i32 %value acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_min_i32_unaligned_release(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_min_i32_unaligned_release:
+; -O0: subs w10, w9, w8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i32_unaligned_release:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i32 %value release, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_min_i32_unaligned_acq_rel(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_min_i32_unaligned_acq_rel:
+; -O0: subs w10, w9, w8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i32_unaligned_acq_rel:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i32 %value acq_rel, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_min_i32_unaligned_seq_cst(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_min_i32_unaligned_seq_cst:
+; -O0: subs w10, w9, w8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i32_unaligned_seq_cst:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i32 %value seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_min_i64_unaligned_monotonic(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_min_i64_unaligned_monotonic:
+; -O0: subs x10, x9, x8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel x8, x9, x8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i64_unaligned_monotonic:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i64 %value monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_min_i64_unaligned_acquire(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_min_i64_unaligned_acquire:
+; -O0: subs x10, x9, x8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel x8, x9, x8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i64_unaligned_acquire:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i64 %value acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_min_i64_unaligned_release(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_min_i64_unaligned_release:
+; -O0: subs x10, x9, x8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel x8, x9, x8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i64_unaligned_release:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i64 %value release, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_min_i64_unaligned_acq_rel(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_min_i64_unaligned_acq_rel:
+; -O0: subs x10, x9, x8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel x8, x9, x8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i64_unaligned_acq_rel:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i64 %value acq_rel, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_min_i64_unaligned_seq_cst(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_min_i64_unaligned_seq_cst:
+; -O0: subs x10, x9, x8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel x8, x9, x8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i64_unaligned_seq_cst:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i64 %value seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_min_i128_unaligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_min_i128_unaligned_monotonic:
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x11
+; -O0: and w12, w12, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel w8, w8, w9, ne
+; -O0: and w12, w8, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel x9, x9, x11, ne
+; -O0: and w11, w8, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x8, x8, x10, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i128_unaligned_monotonic:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x20, x0
+; -O1: csel x8, x1, x19, ge
+; -O1: csel x9, x0, x20, ge
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i128 %value monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_min_i128_unaligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_min_i128_unaligned_acquire:
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x11
+; -O0: and w12, w12, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel w8, w8, w9, ne
+; -O0: and w12, w8, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel x9, x9, x11, ne
+; -O0: and w11, w8, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x8, x8, x10, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i128_unaligned_acquire:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x20, x0
+; -O1: csel x8, x1, x19, ge
+; -O1: csel x9, x0, x20, ge
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i128 %value acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_min_i128_unaligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_min_i128_unaligned_release:
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x11
+; -O0: and w12, w12, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel w8, w8, w9, ne
+; -O0: and w12, w8, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel x9, x9, x11, ne
+; -O0: and w11, w8, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x8, x8, x10, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i128_unaligned_release:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x20, x0
+; -O1: csel x8, x1, x19, ge
+; -O1: csel x9, x0, x20, ge
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i128 %value release, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_min_i128_unaligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_min_i128_unaligned_acq_rel:
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x11
+; -O0: and w12, w12, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel w8, w8, w9, ne
+; -O0: and w12, w8, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel x9, x9, x11, ne
+; -O0: and w11, w8, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x8, x8, x10, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i128_unaligned_acq_rel:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x20, x0
+; -O1: csel x8, x1, x19, ge
+; -O1: csel x9, x0, x20, ge
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i128 %value acq_rel, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_min_i128_unaligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_min_i128_unaligned_seq_cst:
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x11
+; -O0: and w12, w12, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel w8, w8, w9, ne
+; -O0: and w12, w8, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel x9, x9, x11, ne
+; -O0: and w11, w8, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x8, x8, x10, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i128_unaligned_seq_cst:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x20, x0
+; -O1: csel x8, x1, x19, ge
+; -O1: csel x9, x0, x20, ge
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i128 %value seq_cst, align 1
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_umax_i8_aligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umax_i8_aligned_monotonic:
+; CHECK: ldumaxb w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umax_i8_aligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umax_i8_aligned_acquire:
+; CHECK: ldumaxab w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umax_i8_aligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umax_i8_aligned_release:
+; CHECK: ldumaxlb w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umax_i8_aligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umax_i8_aligned_acq_rel:
+; CHECK: ldumaxalb w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umax_i8_aligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umax_i8_aligned_seq_cst:
+; CHECK: ldumaxalb w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_umax_i16_aligned_monotonic(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_umax_i16_aligned_monotonic:
+; CHECK: ldumaxh w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i16 %value monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umax_i16_aligned_acquire(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_umax_i16_aligned_acquire:
+; CHECK: ldumaxah w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i16 %value acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umax_i16_aligned_release(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_umax_i16_aligned_release:
+; CHECK: ldumaxlh w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i16 %value release, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umax_i16_aligned_acq_rel(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_umax_i16_aligned_acq_rel:
+; CHECK: ldumaxalh w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i16 %value acq_rel, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umax_i16_aligned_seq_cst(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_umax_i16_aligned_seq_cst:
+; CHECK: ldumaxalh w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i16 %value seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_umax_i32_aligned_monotonic(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_umax_i32_aligned_monotonic:
+; CHECK: ldumax w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i32 %value monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umax_i32_aligned_acquire(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_umax_i32_aligned_acquire:
+; CHECK: ldumaxa w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i32 %value acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umax_i32_aligned_release(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_umax_i32_aligned_release:
+; CHECK: ldumaxl w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i32 %value release, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umax_i32_aligned_acq_rel(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_umax_i32_aligned_acq_rel:
+; CHECK: ldumaxal w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i32 %value acq_rel, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umax_i32_aligned_seq_cst(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_umax_i32_aligned_seq_cst:
+; CHECK: ldumaxal w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i32 %value seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_umax_i64_aligned_monotonic(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_umax_i64_aligned_monotonic:
+; CHECK: ldumax x1, x0, [x0]
+ %r = atomicrmw umax ptr %ptr, i64 %value monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umax_i64_aligned_acquire(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_umax_i64_aligned_acquire:
+; CHECK: ldumaxa x1, x0, [x0]
+ %r = atomicrmw umax ptr %ptr, i64 %value acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umax_i64_aligned_release(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_umax_i64_aligned_release:
+; CHECK: ldumaxl x1, x0, [x0]
+ %r = atomicrmw umax ptr %ptr, i64 %value release, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umax_i64_aligned_acq_rel(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_umax_i64_aligned_acq_rel:
+; CHECK: ldumaxal x1, x0, [x0]
+ %r = atomicrmw umax ptr %ptr, i64 %value acq_rel, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umax_i64_aligned_seq_cst(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_umax_i64_aligned_seq_cst:
+; CHECK: ldumaxal x1, x0, [x0]
+ %r = atomicrmw umax ptr %ptr, i64 %value seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_umax_i128_aligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umax_i128_aligned_monotonic:
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x12
+; -O0: and w13, w13, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel w9, w9, w11, ne
+; -O0: and w13, w9, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel x2, x11, x12, ne
+; -O0: and w11, w9, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x9, x9, x10, ne
+; -O0: casp x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_umax_i128_aligned_monotonic:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x2, x4
+; -O1: csel x9, x7, x3, lo
+; -O1: csel x8, x4, x2, lo
+; -O1: casp x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw umax ptr %ptr, i128 %value monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umax_i128_aligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umax_i128_aligned_acquire:
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x12
+; -O0: and w13, w13, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel w9, w9, w11, ne
+; -O0: and w13, w9, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel x2, x11, x12, ne
+; -O0: and w11, w9, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x9, x9, x10, ne
+; -O0: caspa x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_umax_i128_aligned_acquire:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x2, x4
+; -O1: csel x9, x7, x3, lo
+; -O1: csel x8, x4, x2, lo
+; -O1: caspa x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw umax ptr %ptr, i128 %value acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umax_i128_aligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umax_i128_aligned_release:
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x12
+; -O0: and w13, w13, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel w9, w9, w11, ne
+; -O0: and w13, w9, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel x2, x11, x12, ne
+; -O0: and w11, w9, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x9, x9, x10, ne
+; -O0: caspl x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_umax_i128_aligned_release:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x2, x4
+; -O1: csel x9, x7, x3, lo
+; -O1: csel x8, x4, x2, lo
+; -O1: caspl x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw umax ptr %ptr, i128 %value release, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umax_i128_aligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umax_i128_aligned_acq_rel:
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x12
+; -O0: and w13, w13, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel w9, w9, w11, ne
+; -O0: and w13, w9, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel x2, x11, x12, ne
+; -O0: and w11, w9, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x9, x9, x10, ne
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_umax_i128_aligned_acq_rel:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x2, x4
+; -O1: csel x9, x7, x3, lo
+; -O1: csel x8, x4, x2, lo
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw umax ptr %ptr, i128 %value acq_rel, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umax_i128_aligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umax_i128_aligned_seq_cst:
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x12
+; -O0: and w13, w13, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel w9, w9, w11, ne
+; -O0: and w13, w9, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel x2, x11, x12, ne
+; -O0: and w11, w9, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x9, x9, x10, ne
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_umax_i128_aligned_seq_cst:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x2, x4
+; -O1: csel x9, x7, x3, lo
+; -O1: csel x8, x4, x2, lo
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw umax ptr %ptr, i128 %value seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_umax_i8_unaligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umax_i8_unaligned_monotonic:
+; CHECK: ldumaxb w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umax_i8_unaligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umax_i8_unaligned_acquire:
+; CHECK: ldumaxab w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umax_i8_unaligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umax_i8_unaligned_release:
+; CHECK: ldumaxlb w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umax_i8_unaligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umax_i8_unaligned_acq_rel:
+; CHECK: ldumaxalb w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umax_i8_unaligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umax_i8_unaligned_seq_cst:
+; CHECK: ldumaxalb w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_umax_i16_unaligned_monotonic(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_umax_i16_unaligned_monotonic:
+; -O0: subs w10, w10, w8, uxth
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i16_unaligned_monotonic:
+; -O1: and w8, w0, #0xffff
+; -O1: cmp w8, w19, uxth
+; -O1: csel w8, w0, w19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i16 %value monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umax_i16_unaligned_acquire(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_umax_i16_unaligned_acquire:
+; -O0: subs w10, w10, w8, uxth
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i16_unaligned_acquire:
+; -O1: and w8, w0, #0xffff
+; -O1: cmp w8, w19, uxth
+; -O1: csel w8, w0, w19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i16 %value acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umax_i16_unaligned_release(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_umax_i16_unaligned_release:
+; -O0: subs w10, w10, w8, uxth
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i16_unaligned_release:
+; -O1: and w8, w0, #0xffff
+; -O1: cmp w8, w19, uxth
+; -O1: csel w8, w0, w19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i16 %value release, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umax_i16_unaligned_acq_rel(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_umax_i16_unaligned_acq_rel:
+; -O0: subs w10, w10, w8, uxth
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i16_unaligned_acq_rel:
+; -O1: and w8, w0, #0xffff
+; -O1: cmp w8, w19, uxth
+; -O1: csel w8, w0, w19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i16 %value acq_rel, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umax_i16_unaligned_seq_cst(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_umax_i16_unaligned_seq_cst:
+; -O0: subs w10, w10, w8, uxth
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i16_unaligned_seq_cst:
+; -O1: and w8, w0, #0xffff
+; -O1: cmp w8, w19, uxth
+; -O1: csel w8, w0, w19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i16 %value seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_umax_i32_unaligned_monotonic(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_umax_i32_unaligned_monotonic:
+; -O0: subs w10, w9, w8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i32_unaligned_monotonic:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i32 %value monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umax_i32_unaligned_acquire(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_umax_i32_unaligned_acquire:
+; -O0: subs w10, w9, w8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i32_unaligned_acquire:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i32 %value acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umax_i32_unaligned_release(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_umax_i32_unaligned_release:
+; -O0: subs w10, w9, w8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i32_unaligned_release:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i32 %value release, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umax_i32_unaligned_acq_rel(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_umax_i32_unaligned_acq_rel:
+; -O0: subs w10, w9, w8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i32_unaligned_acq_rel:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i32 %value acq_rel, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umax_i32_unaligned_seq_cst(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_umax_i32_unaligned_seq_cst:
+; -O0: subs w10, w9, w8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i32_unaligned_seq_cst:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i32 %value seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_umax_i64_unaligned_monotonic(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_umax_i64_unaligned_monotonic:
+; -O0: subs x10, x9, x8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel x8, x9, x8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i64_unaligned_monotonic:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i64 %value monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umax_i64_unaligned_acquire(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_umax_i64_unaligned_acquire:
+; -O0: subs x10, x9, x8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel x8, x9, x8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i64_unaligned_acquire:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i64 %value acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umax_i64_unaligned_release(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_umax_i64_unaligned_release:
+; -O0: subs x10, x9, x8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel x8, x9, x8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i64_unaligned_release:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i64 %value release, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umax_i64_unaligned_acq_rel(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_umax_i64_unaligned_acq_rel:
+; -O0: subs x10, x9, x8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel x8, x9, x8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i64_unaligned_acq_rel:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i64 %value acq_rel, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umax_i64_unaligned_seq_cst(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_umax_i64_unaligned_seq_cst:
+; -O0: subs x10, x9, x8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel x8, x9, x8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i64_unaligned_seq_cst:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i64 %value seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_umax_i128_unaligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umax_i128_unaligned_monotonic:
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x11
+; -O0: and w12, w12, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel w8, w8, w9, ne
+; -O0: and w12, w8, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel x9, x9, x11, ne
+; -O0: and w11, w8, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x8, x8, x10, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i128_unaligned_monotonic:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x20, x0
+; -O1: csel x8, x1, x19, lo
+; -O1: csel x9, x0, x20, lo
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i128 %value monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umax_i128_unaligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umax_i128_unaligned_acquire:
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x11
+; -O0: and w12, w12, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel w8, w8, w9, ne
+; -O0: and w12, w8, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel x9, x9, x11, ne
+; -O0: and w11, w8, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x8, x8, x10, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i128_unaligned_acquire:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x20, x0
+; -O1: csel x8, x1, x19, lo
+; -O1: csel x9, x0, x20, lo
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i128 %value acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umax_i128_unaligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umax_i128_unaligned_release:
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x11
+; -O0: and w12, w12, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel w8, w8, w9, ne
+; -O0: and w12, w8, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel x9, x9, x11, ne
+; -O0: and w11, w8, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x8, x8, x10, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i128_unaligned_release:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x20, x0
+; -O1: csel x8, x1, x19, lo
+; -O1: csel x9, x0, x20, lo
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i128 %value release, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umax_i128_unaligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umax_i128_unaligned_acq_rel:
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x11
+; -O0: and w12, w12, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel w8, w8, w9, ne
+; -O0: and w12, w8, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel x9, x9, x11, ne
+; -O0: and w11, w8, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x8, x8, x10, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i128_unaligned_acq_rel:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x20, x0
+; -O1: csel x8, x1, x19, lo
+; -O1: csel x9, x0, x20, lo
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i128 %value acq_rel, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umax_i128_unaligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umax_i128_unaligned_seq_cst:
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x11
+; -O0: and w12, w12, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel w8, w8, w9, ne
+; -O0: and w12, w8, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel x9, x9, x11, ne
+; -O0: and w11, w8, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x8, x8, x10, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i128_unaligned_seq_cst:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x20, x0
+; -O1: csel x8, x1, x19, lo
+; -O1: csel x9, x0, x20, lo
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i128 %value seq_cst, align 1
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_umin_i8_aligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umin_i8_aligned_monotonic:
+; CHECK: lduminb w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umin_i8_aligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umin_i8_aligned_acquire:
+; CHECK: lduminab w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umin_i8_aligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umin_i8_aligned_release:
+; CHECK: lduminlb w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umin_i8_aligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umin_i8_aligned_acq_rel:
+; CHECK: lduminalb w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umin_i8_aligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umin_i8_aligned_seq_cst:
+; CHECK: lduminalb w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_umin_i16_aligned_monotonic(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_umin_i16_aligned_monotonic:
+; CHECK: lduminh w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i16 %value monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umin_i16_aligned_acquire(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_umin_i16_aligned_acquire:
+; CHECK: lduminah w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i16 %value acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umin_i16_aligned_release(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_umin_i16_aligned_release:
+; CHECK: lduminlh w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i16 %value release, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umin_i16_aligned_acq_rel(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_umin_i16_aligned_acq_rel:
+; CHECK: lduminalh w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i16 %value acq_rel, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umin_i16_aligned_seq_cst(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_umin_i16_aligned_seq_cst:
+; CHECK: lduminalh w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i16 %value seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_umin_i32_aligned_monotonic(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_umin_i32_aligned_monotonic:
+; CHECK: ldumin w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i32 %value monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umin_i32_aligned_acquire(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_umin_i32_aligned_acquire:
+; CHECK: ldumina w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i32 %value acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umin_i32_aligned_release(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_umin_i32_aligned_release:
+; CHECK: lduminl w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i32 %value release, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umin_i32_aligned_acq_rel(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_umin_i32_aligned_acq_rel:
+; CHECK: lduminal w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i32 %value acq_rel, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umin_i32_aligned_seq_cst(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_umin_i32_aligned_seq_cst:
+; CHECK: lduminal w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i32 %value seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_umin_i64_aligned_monotonic(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_umin_i64_aligned_monotonic:
+; CHECK: ldumin x1, x0, [x0]
+ %r = atomicrmw umin ptr %ptr, i64 %value monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umin_i64_aligned_acquire(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_umin_i64_aligned_acquire:
+; CHECK: ldumina x1, x0, [x0]
+ %r = atomicrmw umin ptr %ptr, i64 %value acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umin_i64_aligned_release(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_umin_i64_aligned_release:
+; CHECK: lduminl x1, x0, [x0]
+ %r = atomicrmw umin ptr %ptr, i64 %value release, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umin_i64_aligned_acq_rel(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_umin_i64_aligned_acq_rel:
+; CHECK: lduminal x1, x0, [x0]
+ %r = atomicrmw umin ptr %ptr, i64 %value acq_rel, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umin_i64_aligned_seq_cst(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_umin_i64_aligned_seq_cst:
+; CHECK: lduminal x1, x0, [x0]
+ %r = atomicrmw umin ptr %ptr, i64 %value seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_umin_i128_aligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umin_i128_aligned_monotonic:
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x12
+; -O0: and w13, w13, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel w9, w9, w11, ne
+; -O0: and w13, w9, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel x2, x11, x12, ne
+; -O0: and w11, w9, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x9, x9, x10, ne
+; -O0: casp x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_umin_i128_aligned_monotonic:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x2, x4
+; -O1: csel x9, x7, x3, hs
+; -O1: csel x8, x4, x2, hs
+; -O1: casp x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw umin ptr %ptr, i128 %value monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umin_i128_aligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umin_i128_aligned_acquire:
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x12
+; -O0: and w13, w13, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel w9, w9, w11, ne
+; -O0: and w13, w9, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel x2, x11, x12, ne
+; -O0: and w11, w9, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x9, x9, x10, ne
+; -O0: caspa x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_umin_i128_aligned_acquire:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x2, x4
+; -O1: csel x9, x7, x3, hs
+; -O1: csel x8, x4, x2, hs
+; -O1: caspa x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw umin ptr %ptr, i128 %value acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umin_i128_aligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umin_i128_aligned_release:
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x12
+; -O0: and w13, w13, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel w9, w9, w11, ne
+; -O0: and w13, w9, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel x2, x11, x12, ne
+; -O0: and w11, w9, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x9, x9, x10, ne
+; -O0: caspl x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_umin_i128_aligned_release:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x2, x4
+; -O1: csel x9, x7, x3, hs
+; -O1: csel x8, x4, x2, hs
+; -O1: caspl x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw umin ptr %ptr, i128 %value release, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umin_i128_aligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umin_i128_aligned_acq_rel:
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x12
+; -O0: and w13, w13, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel w9, w9, w11, ne
+; -O0: and w13, w9, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel x2, x11, x12, ne
+; -O0: and w11, w9, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x9, x9, x10, ne
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_umin_i128_aligned_acq_rel:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x2, x4
+; -O1: csel x9, x7, x3, hs
+; -O1: csel x8, x4, x2, hs
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw umin ptr %ptr, i128 %value acq_rel, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umin_i128_aligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umin_i128_aligned_seq_cst:
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x10
+; -O0: subs x9, x9, x12
+; -O0: and w13, w13, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel w9, w9, w11, ne
+; -O0: and w13, w9, #0x1
+; -O0: ands w13, w13, #0x1
+; -O0: csel x2, x11, x12, ne
+; -O0: and w11, w9, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x9, x9, x10, ne
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: eor x8, x10, x8
+; -O0: eor x11, x9, x11
+; -O0: orr x8, x8, x11
+; -O0: subs x8, x8, #0
+;
+; -O1-LABEL: atomicrmw_umin_i128_aligned_seq_cst:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x2, x4
+; -O1: csel x9, x7, x3, hs
+; -O1: csel x8, x4, x2, hs
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x5, x7
+; -O1: ccmp x4, x6, #0, eq
+ %r = atomicrmw umin ptr %ptr, i128 %value seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_umin_i8_unaligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umin_i8_unaligned_monotonic:
+; CHECK: lduminb w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umin_i8_unaligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umin_i8_unaligned_acquire:
+; CHECK: lduminab w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umin_i8_unaligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umin_i8_unaligned_release:
+; CHECK: lduminlb w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umin_i8_unaligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umin_i8_unaligned_acq_rel:
+; CHECK: lduminalb w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umin_i8_unaligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umin_i8_unaligned_seq_cst:
+; CHECK: lduminalb w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_umin_i16_unaligned_monotonic(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_umin_i16_unaligned_monotonic:
+; -O0: subs w10, w10, w8, uxth
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i16_unaligned_monotonic:
+; -O1: and w8, w0, #0xffff
+; -O1: cmp w8, w19, uxth
+; -O1: csel w8, w0, w19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i16 %value monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umin_i16_unaligned_acquire(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_umin_i16_unaligned_acquire:
+; -O0: subs w10, w10, w8, uxth
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i16_unaligned_acquire:
+; -O1: and w8, w0, #0xffff
+; -O1: cmp w8, w19, uxth
+; -O1: csel w8, w0, w19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i16 %value acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umin_i16_unaligned_release(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_umin_i16_unaligned_release:
+; -O0: subs w10, w10, w8, uxth
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i16_unaligned_release:
+; -O1: and w8, w0, #0xffff
+; -O1: cmp w8, w19, uxth
+; -O1: csel w8, w0, w19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i16 %value release, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umin_i16_unaligned_acq_rel(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_umin_i16_unaligned_acq_rel:
+; -O0: subs w10, w10, w8, uxth
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i16_unaligned_acq_rel:
+; -O1: and w8, w0, #0xffff
+; -O1: cmp w8, w19, uxth
+; -O1: csel w8, w0, w19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i16 %value acq_rel, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umin_i16_unaligned_seq_cst(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_umin_i16_unaligned_seq_cst:
+; -O0: subs w10, w10, w8, uxth
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i16_unaligned_seq_cst:
+; -O1: and w8, w0, #0xffff
+; -O1: cmp w8, w19, uxth
+; -O1: csel w8, w0, w19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i16 %value seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_umin_i32_unaligned_monotonic(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_umin_i32_unaligned_monotonic:
+; -O0: subs w10, w9, w8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i32_unaligned_monotonic:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i32 %value monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umin_i32_unaligned_acquire(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_umin_i32_unaligned_acquire:
+; -O0: subs w10, w9, w8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i32_unaligned_acquire:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i32 %value acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umin_i32_unaligned_release(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_umin_i32_unaligned_release:
+; -O0: subs w10, w9, w8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i32_unaligned_release:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i32 %value release, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umin_i32_unaligned_acq_rel(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_umin_i32_unaligned_acq_rel:
+; -O0: subs w10, w9, w8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i32_unaligned_acq_rel:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i32 %value acq_rel, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umin_i32_unaligned_seq_cst(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_umin_i32_unaligned_seq_cst:
+; -O0: subs w10, w9, w8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel w8, w9, w8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i32_unaligned_seq_cst:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i32 %value seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_umin_i64_unaligned_monotonic(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_umin_i64_unaligned_monotonic:
+; -O0: subs x10, x9, x8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel x8, x9, x8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i64_unaligned_monotonic:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i64 %value monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umin_i64_unaligned_acquire(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_umin_i64_unaligned_acquire:
+; -O0: subs x10, x9, x8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel x8, x9, x8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i64_unaligned_acquire:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i64 %value acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umin_i64_unaligned_release(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_umin_i64_unaligned_release:
+; -O0: subs x10, x9, x8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel x8, x9, x8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i64_unaligned_release:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i64 %value release, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umin_i64_unaligned_acq_rel(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_umin_i64_unaligned_acq_rel:
+; -O0: subs x10, x9, x8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel x8, x9, x8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i64_unaligned_acq_rel:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i64 %value acq_rel, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umin_i64_unaligned_seq_cst(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_umin_i64_unaligned_seq_cst:
+; -O0: subs x10, x9, x8
+; -O0: and w10, w10, #0x1
+; -O0: ands w10, w10, #0x1
+; -O0: csel x8, x9, x8, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i64_unaligned_seq_cst:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i64 %value seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_umin_i128_unaligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umin_i128_unaligned_monotonic:
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x11
+; -O0: and w12, w12, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel w8, w8, w9, ne
+; -O0: and w12, w8, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel x9, x9, x11, ne
+; -O0: and w11, w8, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x8, x8, x10, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i128_unaligned_monotonic:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x20, x0
+; -O1: csel x8, x1, x19, hs
+; -O1: csel x9, x0, x20, hs
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i128 %value monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umin_i128_unaligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umin_i128_unaligned_acquire:
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x11
+; -O0: and w12, w12, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel w8, w8, w9, ne
+; -O0: and w12, w8, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel x9, x9, x11, ne
+; -O0: and w11, w8, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x8, x8, x10, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i128_unaligned_acquire:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x20, x0
+; -O1: csel x8, x1, x19, hs
+; -O1: csel x9, x0, x20, hs
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i128 %value acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umin_i128_unaligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umin_i128_unaligned_release:
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x11
+; -O0: and w12, w12, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel w8, w8, w9, ne
+; -O0: and w12, w8, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel x9, x9, x11, ne
+; -O0: and w11, w8, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x8, x8, x10, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i128_unaligned_release:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x20, x0
+; -O1: csel x8, x1, x19, hs
+; -O1: csel x9, x0, x20, hs
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i128 %value release, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umin_i128_unaligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umin_i128_unaligned_acq_rel:
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x11
+; -O0: and w12, w12, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel w8, w8, w9, ne
+; -O0: and w12, w8, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel x9, x9, x11, ne
+; -O0: and w11, w8, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x8, x8, x10, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i128_unaligned_acq_rel:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x20, x0
+; -O1: csel x8, x1, x19, hs
+; -O1: csel x9, x0, x20, hs
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i128 %value acq_rel, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umin_i128_unaligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umin_i128_unaligned_seq_cst:
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x10
+; -O0: subs x8, x8, x11
+; -O0: and w12, w12, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel w8, w8, w9, ne
+; -O0: and w12, w8, #0x1
+; -O0: ands w12, w12, #0x1
+; -O0: csel x9, x9, x11, ne
+; -O0: and w11, w8, #0x1
+; -O0: ands w11, w11, #0x1
+; -O0: csel x8, x8, x10, ne
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i128_unaligned_seq_cst:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x20, x0
+; -O1: csel x8, x1, x19, hs
+; -O1: csel x9, x0, x20, hs
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i128 %value seq_cst, align 1
+ ret i128 %r
+}
diff --git a/llvm/test/CodeGen/AArch64/Atomics/aarch64-cmpxchg-lse2_lse128.ll b/llvm/test/CodeGen/AArch64/Atomics/aarch64-cmpxchg-lse2_lse128.ll
new file mode 100644
index 000000000000..f279d4310806
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/Atomics/aarch64-cmpxchg-lse2_lse128.ll
@@ -0,0 +1,2494 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --filter-out "\b(sp)\b" --filter "^\s*(ld[^r]|st[^r]|swp|cas|bl|add|and|eor|orn|orr|sub|mvn|sxt|cmp|ccmp|csel|dmb)"
+; The base test file was generated by ./llvm/test/CodeGen/AArch64/Atomics/generate-tests.py
+; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64 -mattr=+lse2,+lse128 -O0 | FileCheck %s --check-prefixes=CHECK,-O0
+; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64 -mattr=+lse2,+lse128 -O1 | FileCheck %s --check-prefixes=CHECK,-O1
+
+define dso_local i8 @cmpxchg_i8_aligned_monotonic_monotonic(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_monotonic_monotonic:
+; CHECK: casb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new monotonic monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_monotonic_monotonic_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_monotonic_monotonic_weak:
+; CHECK: casb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new monotonic monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_monotonic_acquire(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_monotonic_acquire:
+; CHECK: casab w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new monotonic acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_monotonic_acquire_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_monotonic_acquire_weak:
+; CHECK: casab w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new monotonic acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_monotonic_seq_cst(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_monotonic_seq_cst:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new monotonic seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_monotonic_seq_cst_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_monotonic_seq_cst_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new monotonic seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_acquire_monotonic(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_acquire_monotonic:
+; CHECK: casab w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new acquire monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_acquire_monotonic_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_acquire_monotonic_weak:
+; CHECK: casab w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new acquire monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_acquire_acquire(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_acquire_acquire:
+; CHECK: casab w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new acquire acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_acquire_acquire_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_acquire_acquire_weak:
+; CHECK: casab w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new acquire acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_acquire_seq_cst(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_acquire_seq_cst:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new acquire seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_acquire_seq_cst_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_acquire_seq_cst_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new acquire seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_release_monotonic(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_release_monotonic:
+; CHECK: caslb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new release monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_release_monotonic_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_release_monotonic_weak:
+; CHECK: caslb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new release monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_release_acquire(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_release_acquire:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new release acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_release_acquire_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_release_acquire_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new release acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_release_seq_cst(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_release_seq_cst:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new release seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_release_seq_cst_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_release_seq_cst_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new release seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_acq_rel_monotonic(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_acq_rel_monotonic:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new acq_rel monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_acq_rel_monotonic_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_acq_rel_monotonic_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new acq_rel monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_acq_rel_acquire(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_acq_rel_acquire:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new acq_rel acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_acq_rel_acquire_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_acq_rel_acquire_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new acq_rel acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_acq_rel_seq_cst(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_acq_rel_seq_cst:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new acq_rel seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_acq_rel_seq_cst_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_acq_rel_seq_cst_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new acq_rel seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_seq_cst_monotonic(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_seq_cst_monotonic:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new seq_cst monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_seq_cst_monotonic_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_seq_cst_monotonic_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new seq_cst monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_seq_cst_acquire(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_seq_cst_acquire:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new seq_cst acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_seq_cst_acquire_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_seq_cst_acquire_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new seq_cst acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_seq_cst_seq_cst(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_seq_cst_seq_cst:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new seq_cst seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_seq_cst_seq_cst_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_seq_cst_seq_cst_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new seq_cst seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_monotonic_monotonic(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_monotonic_monotonic:
+; CHECK: cash w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new monotonic monotonic, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_monotonic_monotonic_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_monotonic_monotonic_weak:
+; CHECK: cash w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new monotonic monotonic, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_monotonic_acquire(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_monotonic_acquire:
+; CHECK: casah w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new monotonic acquire, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_monotonic_acquire_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_monotonic_acquire_weak:
+; CHECK: casah w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new monotonic acquire, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_monotonic_seq_cst(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_monotonic_seq_cst:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new monotonic seq_cst, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_monotonic_seq_cst_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_monotonic_seq_cst_weak:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new monotonic seq_cst, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_acquire_monotonic(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_acquire_monotonic:
+; CHECK: casah w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new acquire monotonic, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_acquire_monotonic_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_acquire_monotonic_weak:
+; CHECK: casah w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new acquire monotonic, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_acquire_acquire(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_acquire_acquire:
+; CHECK: casah w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new acquire acquire, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_acquire_acquire_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_acquire_acquire_weak:
+; CHECK: casah w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new acquire acquire, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_acquire_seq_cst(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_acquire_seq_cst:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new acquire seq_cst, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_acquire_seq_cst_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_acquire_seq_cst_weak:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new acquire seq_cst, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_release_monotonic(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_release_monotonic:
+; CHECK: caslh w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new release monotonic, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_release_monotonic_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_release_monotonic_weak:
+; CHECK: caslh w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new release monotonic, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_release_acquire(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_release_acquire:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new release acquire, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_release_acquire_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_release_acquire_weak:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new release acquire, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_release_seq_cst(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_release_seq_cst:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new release seq_cst, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_release_seq_cst_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_release_seq_cst_weak:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new release seq_cst, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_acq_rel_monotonic(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_acq_rel_monotonic:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new acq_rel monotonic, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_acq_rel_monotonic_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_acq_rel_monotonic_weak:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new acq_rel monotonic, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_acq_rel_acquire(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_acq_rel_acquire:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new acq_rel acquire, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_acq_rel_acquire_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_acq_rel_acquire_weak:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new acq_rel acquire, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_acq_rel_seq_cst(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_acq_rel_seq_cst:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new acq_rel seq_cst, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_acq_rel_seq_cst_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_acq_rel_seq_cst_weak:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new acq_rel seq_cst, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_seq_cst_monotonic(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_seq_cst_monotonic:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new seq_cst monotonic, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_seq_cst_monotonic_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_seq_cst_monotonic_weak:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new seq_cst monotonic, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_seq_cst_acquire(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_seq_cst_acquire:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new seq_cst acquire, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_seq_cst_acquire_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_seq_cst_acquire_weak:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new seq_cst acquire, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_seq_cst_seq_cst(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_seq_cst_seq_cst:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new seq_cst seq_cst, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_seq_cst_seq_cst_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_seq_cst_seq_cst_weak:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new seq_cst seq_cst, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_monotonic_monotonic(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_monotonic_monotonic:
+; CHECK: cas w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new monotonic monotonic, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_monotonic_monotonic_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_monotonic_monotonic_weak:
+; CHECK: cas w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new monotonic monotonic, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_monotonic_acquire(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_monotonic_acquire:
+; CHECK: casa w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new monotonic acquire, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_monotonic_acquire_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_monotonic_acquire_weak:
+; CHECK: casa w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new monotonic acquire, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_monotonic_seq_cst(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_monotonic_seq_cst:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new monotonic seq_cst, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_monotonic_seq_cst_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_monotonic_seq_cst_weak:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new monotonic seq_cst, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_acquire_monotonic(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_acquire_monotonic:
+; CHECK: casa w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new acquire monotonic, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_acquire_monotonic_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_acquire_monotonic_weak:
+; CHECK: casa w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new acquire monotonic, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_acquire_acquire(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_acquire_acquire:
+; CHECK: casa w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new acquire acquire, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_acquire_acquire_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_acquire_acquire_weak:
+; CHECK: casa w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new acquire acquire, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_acquire_seq_cst(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_acquire_seq_cst:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new acquire seq_cst, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_acquire_seq_cst_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_acquire_seq_cst_weak:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new acquire seq_cst, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_release_monotonic(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_release_monotonic:
+; CHECK: casl w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new release monotonic, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_release_monotonic_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_release_monotonic_weak:
+; CHECK: casl w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new release monotonic, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_release_acquire(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_release_acquire:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new release acquire, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_release_acquire_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_release_acquire_weak:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new release acquire, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_release_seq_cst(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_release_seq_cst:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new release seq_cst, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_release_seq_cst_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_release_seq_cst_weak:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new release seq_cst, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_acq_rel_monotonic(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_acq_rel_monotonic:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new acq_rel monotonic, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_acq_rel_monotonic_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_acq_rel_monotonic_weak:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new acq_rel monotonic, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_acq_rel_acquire(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_acq_rel_acquire:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new acq_rel acquire, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_acq_rel_acquire_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_acq_rel_acquire_weak:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new acq_rel acquire, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_acq_rel_seq_cst(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_acq_rel_seq_cst:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new acq_rel seq_cst, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_acq_rel_seq_cst_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_acq_rel_seq_cst_weak:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new acq_rel seq_cst, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_seq_cst_monotonic(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_seq_cst_monotonic:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new seq_cst monotonic, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_seq_cst_monotonic_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_seq_cst_monotonic_weak:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new seq_cst monotonic, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_seq_cst_acquire(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_seq_cst_acquire:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new seq_cst acquire, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_seq_cst_acquire_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_seq_cst_acquire_weak:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new seq_cst acquire, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_seq_cst_seq_cst(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_seq_cst_seq_cst:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new seq_cst seq_cst, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_seq_cst_seq_cst_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_seq_cst_seq_cst_weak:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new seq_cst seq_cst, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_monotonic_monotonic(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_monotonic_monotonic:
+; CHECK: cas x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new monotonic monotonic, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_monotonic_monotonic_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_monotonic_monotonic_weak:
+; CHECK: cas x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new monotonic monotonic, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_monotonic_acquire(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_monotonic_acquire:
+; CHECK: casa x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new monotonic acquire, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_monotonic_acquire_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_monotonic_acquire_weak:
+; CHECK: casa x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new monotonic acquire, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_monotonic_seq_cst(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_monotonic_seq_cst:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new monotonic seq_cst, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_monotonic_seq_cst_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_monotonic_seq_cst_weak:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new monotonic seq_cst, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_acquire_monotonic(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_acquire_monotonic:
+; CHECK: casa x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new acquire monotonic, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_acquire_monotonic_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_acquire_monotonic_weak:
+; CHECK: casa x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new acquire monotonic, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_acquire_acquire(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_acquire_acquire:
+; CHECK: casa x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new acquire acquire, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_acquire_acquire_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_acquire_acquire_weak:
+; CHECK: casa x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new acquire acquire, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_acquire_seq_cst(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_acquire_seq_cst:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new acquire seq_cst, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_acquire_seq_cst_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_acquire_seq_cst_weak:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new acquire seq_cst, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_release_monotonic(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_release_monotonic:
+; CHECK: casl x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new release monotonic, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_release_monotonic_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_release_monotonic_weak:
+; CHECK: casl x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new release monotonic, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_release_acquire(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_release_acquire:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new release acquire, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_release_acquire_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_release_acquire_weak:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new release acquire, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_release_seq_cst(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_release_seq_cst:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new release seq_cst, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_release_seq_cst_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_release_seq_cst_weak:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new release seq_cst, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_acq_rel_monotonic(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_acq_rel_monotonic:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new acq_rel monotonic, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_acq_rel_monotonic_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_acq_rel_monotonic_weak:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new acq_rel monotonic, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_acq_rel_acquire(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_acq_rel_acquire:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new acq_rel acquire, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_acq_rel_acquire_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_acq_rel_acquire_weak:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new acq_rel acquire, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_acq_rel_seq_cst(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_acq_rel_seq_cst:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new acq_rel seq_cst, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_acq_rel_seq_cst_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_acq_rel_seq_cst_weak:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new acq_rel seq_cst, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_seq_cst_monotonic(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_seq_cst_monotonic:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new seq_cst monotonic, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_seq_cst_monotonic_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_seq_cst_monotonic_weak:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new seq_cst monotonic, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_seq_cst_acquire(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_seq_cst_acquire:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new seq_cst acquire, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_seq_cst_acquire_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_seq_cst_acquire_weak:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new seq_cst acquire, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_seq_cst_seq_cst(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_seq_cst_seq_cst:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new seq_cst seq_cst, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_seq_cst_seq_cst_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_seq_cst_seq_cst_weak:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new seq_cst seq_cst, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_monotonic_monotonic(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_monotonic_monotonic:
+; -O0: casp x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_monotonic_monotonic:
+; -O1: casp x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new monotonic monotonic, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_monotonic_monotonic_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_monotonic_monotonic_weak:
+; -O0: casp x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_monotonic_monotonic_weak:
+; -O1: casp x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new monotonic monotonic, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_monotonic_acquire(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_monotonic_acquire:
+; -O0: caspa x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_monotonic_acquire:
+; -O1: caspa x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new monotonic acquire, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_monotonic_acquire_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_monotonic_acquire_weak:
+; -O0: caspa x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_monotonic_acquire_weak:
+; -O1: caspa x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new monotonic acquire, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_monotonic_seq_cst(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_monotonic_seq_cst:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_monotonic_seq_cst:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new monotonic seq_cst, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_monotonic_seq_cst_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_monotonic_seq_cst_weak:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_monotonic_seq_cst_weak:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new monotonic seq_cst, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_acquire_monotonic(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_acquire_monotonic:
+; -O0: caspa x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_acquire_monotonic:
+; -O1: caspa x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new acquire monotonic, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_acquire_monotonic_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_acquire_monotonic_weak:
+; -O0: caspa x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_acquire_monotonic_weak:
+; -O1: caspa x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new acquire monotonic, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_acquire_acquire(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_acquire_acquire:
+; -O0: caspa x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_acquire_acquire:
+; -O1: caspa x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new acquire acquire, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_acquire_acquire_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_acquire_acquire_weak:
+; -O0: caspa x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_acquire_acquire_weak:
+; -O1: caspa x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new acquire acquire, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_acquire_seq_cst(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_acquire_seq_cst:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_acquire_seq_cst:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new acquire seq_cst, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_acquire_seq_cst_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_acquire_seq_cst_weak:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_acquire_seq_cst_weak:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new acquire seq_cst, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_release_monotonic(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_release_monotonic:
+; -O0: caspl x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_release_monotonic:
+; -O1: caspl x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new release monotonic, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_release_monotonic_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_release_monotonic_weak:
+; -O0: caspl x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_release_monotonic_weak:
+; -O1: caspl x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new release monotonic, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_release_acquire(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_release_acquire:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_release_acquire:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new release acquire, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_release_acquire_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_release_acquire_weak:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_release_acquire_weak:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new release acquire, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_release_seq_cst(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_release_seq_cst:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_release_seq_cst:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new release seq_cst, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_release_seq_cst_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_release_seq_cst_weak:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_release_seq_cst_weak:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new release seq_cst, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_acq_rel_monotonic(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_acq_rel_monotonic:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_acq_rel_monotonic:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new acq_rel monotonic, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_acq_rel_monotonic_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_acq_rel_monotonic_weak:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_acq_rel_monotonic_weak:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new acq_rel monotonic, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_acq_rel_acquire(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_acq_rel_acquire:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_acq_rel_acquire:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new acq_rel acquire, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_acq_rel_acquire_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_acq_rel_acquire_weak:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_acq_rel_acquire_weak:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new acq_rel acquire, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_acq_rel_seq_cst(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_acq_rel_seq_cst:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_acq_rel_seq_cst:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new acq_rel seq_cst, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_acq_rel_seq_cst_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_acq_rel_seq_cst_weak:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_acq_rel_seq_cst_weak:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new acq_rel seq_cst, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_seq_cst_monotonic(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_seq_cst_monotonic:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_seq_cst_monotonic:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new seq_cst monotonic, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_seq_cst_monotonic_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_seq_cst_monotonic_weak:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_seq_cst_monotonic_weak:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new seq_cst monotonic, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_seq_cst_acquire(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_seq_cst_acquire:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_seq_cst_acquire:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new seq_cst acquire, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_seq_cst_acquire_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_seq_cst_acquire_weak:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_seq_cst_acquire_weak:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new seq_cst acquire, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_seq_cst_seq_cst(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_seq_cst_seq_cst:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_seq_cst_seq_cst:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new seq_cst seq_cst, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_seq_cst_seq_cst_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_seq_cst_seq_cst_weak:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_seq_cst_seq_cst_weak:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new seq_cst seq_cst, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_monotonic_monotonic(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_monotonic_monotonic:
+; CHECK: casb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new monotonic monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_monotonic_monotonic_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_monotonic_monotonic_weak:
+; CHECK: casb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new monotonic monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_monotonic_acquire(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_monotonic_acquire:
+; CHECK: casab w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new monotonic acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_monotonic_acquire_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_monotonic_acquire_weak:
+; CHECK: casab w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new monotonic acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_monotonic_seq_cst(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_monotonic_seq_cst:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new monotonic seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_monotonic_seq_cst_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_monotonic_seq_cst_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new monotonic seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_acquire_monotonic(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_acquire_monotonic:
+; CHECK: casab w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new acquire monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_acquire_monotonic_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_acquire_monotonic_weak:
+; CHECK: casab w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new acquire monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_acquire_acquire(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_acquire_acquire:
+; CHECK: casab w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new acquire acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_acquire_acquire_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_acquire_acquire_weak:
+; CHECK: casab w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new acquire acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_acquire_seq_cst(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_acquire_seq_cst:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new acquire seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_acquire_seq_cst_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_acquire_seq_cst_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new acquire seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_release_monotonic(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_release_monotonic:
+; CHECK: caslb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new release monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_release_monotonic_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_release_monotonic_weak:
+; CHECK: caslb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new release monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_release_acquire(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_release_acquire:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new release acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_release_acquire_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_release_acquire_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new release acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_release_seq_cst(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_release_seq_cst:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new release seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_release_seq_cst_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_release_seq_cst_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new release seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_acq_rel_monotonic(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_acq_rel_monotonic:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new acq_rel monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_acq_rel_monotonic_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_acq_rel_monotonic_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new acq_rel monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_acq_rel_acquire(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_acq_rel_acquire:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new acq_rel acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_acq_rel_acquire_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_acq_rel_acquire_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new acq_rel acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_acq_rel_seq_cst(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_acq_rel_seq_cst:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new acq_rel seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_acq_rel_seq_cst_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_acq_rel_seq_cst_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new acq_rel seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_seq_cst_monotonic(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_seq_cst_monotonic:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new seq_cst monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_seq_cst_monotonic_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_seq_cst_monotonic_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new seq_cst monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_seq_cst_acquire(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_seq_cst_acquire:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new seq_cst acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_seq_cst_acquire_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_seq_cst_acquire_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new seq_cst acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_seq_cst_seq_cst(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_seq_cst_seq_cst:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new seq_cst seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_seq_cst_seq_cst_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_seq_cst_seq_cst_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new seq_cst seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_monotonic_monotonic(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_monotonic_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new monotonic monotonic, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_monotonic_monotonic_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_monotonic_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new monotonic monotonic, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_monotonic_acquire(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_monotonic_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new monotonic acquire, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_monotonic_acquire_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_monotonic_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new monotonic acquire, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_monotonic_seq_cst(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_monotonic_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new monotonic seq_cst, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_monotonic_seq_cst_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_monotonic_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new monotonic seq_cst, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_acquire_monotonic(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_acquire_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new acquire monotonic, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_acquire_monotonic_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_acquire_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new acquire monotonic, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_acquire_acquire(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_acquire_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new acquire acquire, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_acquire_acquire_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_acquire_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new acquire acquire, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_acquire_seq_cst(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_acquire_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new acquire seq_cst, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_acquire_seq_cst_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_acquire_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new acquire seq_cst, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_release_monotonic(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_release_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new release monotonic, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_release_monotonic_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_release_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new release monotonic, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_release_acquire(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_release_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new release acquire, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_release_acquire_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_release_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new release acquire, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_release_seq_cst(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_release_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new release seq_cst, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_release_seq_cst_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_release_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new release seq_cst, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_acq_rel_monotonic(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_acq_rel_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new acq_rel monotonic, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_acq_rel_monotonic_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_acq_rel_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new acq_rel monotonic, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_acq_rel_acquire(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_acq_rel_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new acq_rel acquire, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_acq_rel_acquire_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_acq_rel_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new acq_rel acquire, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_acq_rel_seq_cst(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_acq_rel_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new acq_rel seq_cst, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_acq_rel_seq_cst_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_acq_rel_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new acq_rel seq_cst, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_seq_cst_monotonic(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_seq_cst_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new seq_cst monotonic, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_seq_cst_monotonic_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_seq_cst_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new seq_cst monotonic, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_seq_cst_acquire(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_seq_cst_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new seq_cst acquire, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_seq_cst_acquire_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_seq_cst_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new seq_cst acquire, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_seq_cst_seq_cst(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_seq_cst_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new seq_cst seq_cst, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_seq_cst_seq_cst_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_seq_cst_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new seq_cst seq_cst, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_monotonic_monotonic(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_monotonic_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new monotonic monotonic, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_monotonic_monotonic_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_monotonic_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new monotonic monotonic, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_monotonic_acquire(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_monotonic_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new monotonic acquire, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_monotonic_acquire_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_monotonic_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new monotonic acquire, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_monotonic_seq_cst(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_monotonic_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new monotonic seq_cst, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_monotonic_seq_cst_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_monotonic_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new monotonic seq_cst, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_acquire_monotonic(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_acquire_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new acquire monotonic, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_acquire_monotonic_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_acquire_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new acquire monotonic, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_acquire_acquire(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_acquire_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new acquire acquire, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_acquire_acquire_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_acquire_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new acquire acquire, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_acquire_seq_cst(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_acquire_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new acquire seq_cst, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_acquire_seq_cst_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_acquire_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new acquire seq_cst, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_release_monotonic(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_release_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new release monotonic, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_release_monotonic_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_release_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new release monotonic, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_release_acquire(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_release_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new release acquire, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_release_acquire_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_release_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new release acquire, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_release_seq_cst(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_release_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new release seq_cst, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_release_seq_cst_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_release_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new release seq_cst, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_acq_rel_monotonic(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_acq_rel_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new acq_rel monotonic, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_acq_rel_monotonic_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_acq_rel_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new acq_rel monotonic, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_acq_rel_acquire(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_acq_rel_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new acq_rel acquire, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_acq_rel_acquire_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_acq_rel_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new acq_rel acquire, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_acq_rel_seq_cst(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_acq_rel_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new acq_rel seq_cst, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_acq_rel_seq_cst_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_acq_rel_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new acq_rel seq_cst, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_seq_cst_monotonic(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_seq_cst_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new seq_cst monotonic, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_seq_cst_monotonic_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_seq_cst_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new seq_cst monotonic, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_seq_cst_acquire(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_seq_cst_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new seq_cst acquire, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_seq_cst_acquire_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_seq_cst_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new seq_cst acquire, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_seq_cst_seq_cst(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_seq_cst_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new seq_cst seq_cst, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_seq_cst_seq_cst_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_seq_cst_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new seq_cst seq_cst, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_monotonic_monotonic(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_monotonic_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new monotonic monotonic, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_monotonic_monotonic_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_monotonic_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new monotonic monotonic, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_monotonic_acquire(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_monotonic_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new monotonic acquire, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_monotonic_acquire_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_monotonic_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new monotonic acquire, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_monotonic_seq_cst(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_monotonic_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new monotonic seq_cst, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_monotonic_seq_cst_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_monotonic_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new monotonic seq_cst, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_acquire_monotonic(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_acquire_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new acquire monotonic, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_acquire_monotonic_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_acquire_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new acquire monotonic, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_acquire_acquire(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_acquire_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new acquire acquire, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_acquire_acquire_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_acquire_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new acquire acquire, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_acquire_seq_cst(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_acquire_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new acquire seq_cst, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_acquire_seq_cst_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_acquire_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new acquire seq_cst, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_release_monotonic(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_release_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new release monotonic, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_release_monotonic_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_release_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new release monotonic, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_release_acquire(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_release_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new release acquire, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_release_acquire_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_release_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new release acquire, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_release_seq_cst(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_release_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new release seq_cst, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_release_seq_cst_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_release_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new release seq_cst, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_acq_rel_monotonic(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_acq_rel_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new acq_rel monotonic, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_acq_rel_monotonic_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_acq_rel_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new acq_rel monotonic, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_acq_rel_acquire(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_acq_rel_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new acq_rel acquire, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_acq_rel_acquire_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_acq_rel_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new acq_rel acquire, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_acq_rel_seq_cst(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_acq_rel_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new acq_rel seq_cst, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_acq_rel_seq_cst_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_acq_rel_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new acq_rel seq_cst, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_seq_cst_monotonic(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_seq_cst_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new seq_cst monotonic, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_seq_cst_monotonic_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_seq_cst_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new seq_cst monotonic, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_seq_cst_acquire(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_seq_cst_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new seq_cst acquire, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_seq_cst_acquire_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_seq_cst_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new seq_cst acquire, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_seq_cst_seq_cst(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_seq_cst_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new seq_cst seq_cst, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_seq_cst_seq_cst_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_seq_cst_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new seq_cst seq_cst, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_monotonic_monotonic(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_monotonic_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new monotonic monotonic, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_monotonic_monotonic_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_monotonic_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new monotonic monotonic, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_monotonic_acquire(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_monotonic_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new monotonic acquire, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_monotonic_acquire_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_monotonic_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new monotonic acquire, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_monotonic_seq_cst(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_monotonic_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new monotonic seq_cst, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_monotonic_seq_cst_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_monotonic_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new monotonic seq_cst, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_acquire_monotonic(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_acquire_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new acquire monotonic, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_acquire_monotonic_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_acquire_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new acquire monotonic, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_acquire_acquire(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_acquire_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new acquire acquire, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_acquire_acquire_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_acquire_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new acquire acquire, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_acquire_seq_cst(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_acquire_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new acquire seq_cst, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_acquire_seq_cst_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_acquire_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new acquire seq_cst, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_release_monotonic(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_release_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new release monotonic, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_release_monotonic_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_release_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new release monotonic, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_release_acquire(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_release_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new release acquire, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_release_acquire_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_release_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new release acquire, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_release_seq_cst(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_release_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new release seq_cst, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_release_seq_cst_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_release_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new release seq_cst, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_acq_rel_monotonic(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_acq_rel_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new acq_rel monotonic, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_acq_rel_monotonic_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_acq_rel_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new acq_rel monotonic, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_acq_rel_acquire(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_acq_rel_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new acq_rel acquire, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_acq_rel_acquire_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_acq_rel_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new acq_rel acquire, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_acq_rel_seq_cst(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_acq_rel_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new acq_rel seq_cst, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_acq_rel_seq_cst_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_acq_rel_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new acq_rel seq_cst, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_seq_cst_monotonic(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_seq_cst_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new seq_cst monotonic, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_seq_cst_monotonic_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_seq_cst_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new seq_cst monotonic, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_seq_cst_acquire(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_seq_cst_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new seq_cst acquire, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_seq_cst_acquire_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_seq_cst_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new seq_cst acquire, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_seq_cst_seq_cst(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_seq_cst_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new seq_cst seq_cst, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_seq_cst_seq_cst_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_seq_cst_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new seq_cst seq_cst, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
diff --git a/llvm/test/CodeGen/AArch64/Atomics/aarch64-fence.ll b/llvm/test/CodeGen/AArch64/Atomics/aarch64-fence.ll
index a0928b38b668..c7f0fca54056 100644
--- a/llvm/test/CodeGen/AArch64/Atomics/aarch64-fence.ll
+++ b/llvm/test/CodeGen/AArch64/Atomics/aarch64-fence.ll
@@ -14,6 +14,8 @@
; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64 -mattr=+lse2,+rcpc3 -O1 | FileCheck %s --check-prefixes=CHECK,-O1
; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64 -mattr=+lse128 -O0 | FileCheck %s --check-prefixes=CHECK,-O0
; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64 -mattr=+lse128 -O1 | FileCheck %s --check-prefixes=CHECK,-O1
+; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64 -mattr=+lse2,+lse128 -O0 | FileCheck %s --check-prefixes=CHECK,-O0
+; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64 -mattr=+lse2,+lse128 -O1 | FileCheck %s --check-prefixes=CHECK,-O1
define dso_local void @fence_acquire() {
; CHECK-LABEL: fence_acquire:
diff --git a/llvm/test/CodeGen/AArch64/Atomics/aarch64_be-atomic-load-lse2_lse128.ll b/llvm/test/CodeGen/AArch64/Atomics/aarch64_be-atomic-load-lse2_lse128.ll
new file mode 100644
index 000000000000..32c7507d1ce7
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/Atomics/aarch64_be-atomic-load-lse2_lse128.ll
@@ -0,0 +1,571 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --filter-out "\b(sp)\b" --filter "^\s*(ld|st[^r]|swp|cas|bl|add|and|eor|orn|orr|sub|mvn|sxt|cmp|ccmp|csel|dmb)"
+; The base test file was generated by ./llvm/test/CodeGen/AArch64/Atomics/generate-tests.py
+; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64_be -mattr=+lse2,+lse128 -O0 | FileCheck %s --check-prefixes=CHECK,-O0
+; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64_be -mattr=+lse2,+lse128 -O1 | FileCheck %s --check-prefixes=CHECK,-O1
+
+define dso_local i8 @load_atomic_i8_aligned_unordered(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i8_aligned_unordered:
+; CHECK: ldrb w0, [x0]
+ %r = load atomic i8, ptr %ptr unordered, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_aligned_unordered_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i8_aligned_unordered_const:
+; CHECK: ldrb w0, [x0]
+ %r = load atomic i8, ptr %ptr unordered, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_aligned_monotonic(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i8_aligned_monotonic:
+; CHECK: ldrb w0, [x0]
+ %r = load atomic i8, ptr %ptr monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_aligned_monotonic_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i8_aligned_monotonic_const:
+; CHECK: ldrb w0, [x0]
+ %r = load atomic i8, ptr %ptr monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_aligned_acquire(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i8_aligned_acquire:
+; CHECK: ldarb w0, [x0]
+ %r = load atomic i8, ptr %ptr acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_aligned_acquire_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i8_aligned_acquire_const:
+; CHECK: ldarb w0, [x0]
+ %r = load atomic i8, ptr %ptr acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_aligned_seq_cst(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i8_aligned_seq_cst:
+; CHECK: ldarb w0, [x0]
+ %r = load atomic i8, ptr %ptr seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_aligned_seq_cst_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i8_aligned_seq_cst_const:
+; CHECK: ldarb w0, [x0]
+ %r = load atomic i8, ptr %ptr seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @load_atomic_i16_aligned_unordered(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i16_aligned_unordered:
+; CHECK: ldrh w0, [x0]
+ %r = load atomic i16, ptr %ptr unordered, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_aligned_unordered_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i16_aligned_unordered_const:
+; CHECK: ldrh w0, [x0]
+ %r = load atomic i16, ptr %ptr unordered, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_aligned_monotonic(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i16_aligned_monotonic:
+; CHECK: ldrh w0, [x0]
+ %r = load atomic i16, ptr %ptr monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_aligned_monotonic_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i16_aligned_monotonic_const:
+; CHECK: ldrh w0, [x0]
+ %r = load atomic i16, ptr %ptr monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_aligned_acquire(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i16_aligned_acquire:
+; CHECK: ldarh w0, [x0]
+ %r = load atomic i16, ptr %ptr acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_aligned_acquire_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i16_aligned_acquire_const:
+; CHECK: ldarh w0, [x0]
+ %r = load atomic i16, ptr %ptr acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_aligned_seq_cst(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i16_aligned_seq_cst:
+; CHECK: ldarh w0, [x0]
+ %r = load atomic i16, ptr %ptr seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_aligned_seq_cst_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i16_aligned_seq_cst_const:
+; CHECK: ldarh w0, [x0]
+ %r = load atomic i16, ptr %ptr seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i32 @load_atomic_i32_aligned_unordered(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i32_aligned_unordered:
+; CHECK: ldr w0, [x0]
+ %r = load atomic i32, ptr %ptr unordered, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_aligned_unordered_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i32_aligned_unordered_const:
+; CHECK: ldr w0, [x0]
+ %r = load atomic i32, ptr %ptr unordered, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_aligned_monotonic(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i32_aligned_monotonic:
+; CHECK: ldr w0, [x0]
+ %r = load atomic i32, ptr %ptr monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_aligned_monotonic_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i32_aligned_monotonic_const:
+; CHECK: ldr w0, [x0]
+ %r = load atomic i32, ptr %ptr monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_aligned_acquire(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i32_aligned_acquire:
+; CHECK: ldar w0, [x0]
+ %r = load atomic i32, ptr %ptr acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_aligned_acquire_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i32_aligned_acquire_const:
+; CHECK: ldar w0, [x0]
+ %r = load atomic i32, ptr %ptr acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_aligned_seq_cst(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i32_aligned_seq_cst:
+; CHECK: ldar w0, [x0]
+ %r = load atomic i32, ptr %ptr seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_aligned_seq_cst_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i32_aligned_seq_cst_const:
+; CHECK: ldar w0, [x0]
+ %r = load atomic i32, ptr %ptr seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i64 @load_atomic_i64_aligned_unordered(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i64_aligned_unordered:
+; CHECK: ldr x0, [x0]
+ %r = load atomic i64, ptr %ptr unordered, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_aligned_unordered_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i64_aligned_unordered_const:
+; CHECK: ldr x0, [x0]
+ %r = load atomic i64, ptr %ptr unordered, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_aligned_monotonic(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i64_aligned_monotonic:
+; CHECK: ldr x0, [x0]
+ %r = load atomic i64, ptr %ptr monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_aligned_monotonic_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i64_aligned_monotonic_const:
+; CHECK: ldr x0, [x0]
+ %r = load atomic i64, ptr %ptr monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_aligned_acquire(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i64_aligned_acquire:
+; CHECK: ldar x0, [x0]
+ %r = load atomic i64, ptr %ptr acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_aligned_acquire_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i64_aligned_acquire_const:
+; CHECK: ldar x0, [x0]
+ %r = load atomic i64, ptr %ptr acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_aligned_seq_cst(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i64_aligned_seq_cst:
+; CHECK: ldar x0, [x0]
+ %r = load atomic i64, ptr %ptr seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_aligned_seq_cst_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i64_aligned_seq_cst_const:
+; CHECK: ldar x0, [x0]
+ %r = load atomic i64, ptr %ptr seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i128 @load_atomic_i128_aligned_unordered(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i128_aligned_unordered:
+; CHECK: ldp x1, x0, [x0]
+ %r = load atomic i128, ptr %ptr unordered, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_aligned_unordered_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i128_aligned_unordered_const:
+; CHECK: ldp x1, x0, [x0]
+ %r = load atomic i128, ptr %ptr unordered, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_aligned_monotonic(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i128_aligned_monotonic:
+; CHECK: ldp x1, x0, [x0]
+ %r = load atomic i128, ptr %ptr monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_aligned_monotonic_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i128_aligned_monotonic_const:
+; CHECK: ldp x1, x0, [x0]
+ %r = load atomic i128, ptr %ptr monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_aligned_acquire(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i128_aligned_acquire:
+; CHECK: ldp x1, x0, [x0]
+; CHECK: dmb ishld
+ %r = load atomic i128, ptr %ptr acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_aligned_acquire_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i128_aligned_acquire_const:
+; CHECK: ldp x1, x0, [x0]
+; CHECK: dmb ishld
+ %r = load atomic i128, ptr %ptr acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_aligned_seq_cst(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i128_aligned_seq_cst:
+; CHECK: ldp x1, x0, [x0]
+; CHECK: dmb ish
+ %r = load atomic i128, ptr %ptr seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_aligned_seq_cst_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i128_aligned_seq_cst_const:
+; CHECK: ldp x1, x0, [x0]
+; CHECK: dmb ish
+ %r = load atomic i128, ptr %ptr seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i8 @load_atomic_i8_unaligned_unordered(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i8_unaligned_unordered:
+; CHECK: ldrb w0, [x0]
+ %r = load atomic i8, ptr %ptr unordered, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_unaligned_unordered_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i8_unaligned_unordered_const:
+; CHECK: ldrb w0, [x0]
+ %r = load atomic i8, ptr %ptr unordered, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_unaligned_monotonic(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i8_unaligned_monotonic:
+; CHECK: ldrb w0, [x0]
+ %r = load atomic i8, ptr %ptr monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_unaligned_monotonic_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i8_unaligned_monotonic_const:
+; CHECK: ldrb w0, [x0]
+ %r = load atomic i8, ptr %ptr monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_unaligned_acquire(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i8_unaligned_acquire:
+; CHECK: ldarb w0, [x0]
+ %r = load atomic i8, ptr %ptr acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_unaligned_acquire_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i8_unaligned_acquire_const:
+; CHECK: ldarb w0, [x0]
+ %r = load atomic i8, ptr %ptr acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_unaligned_seq_cst(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i8_unaligned_seq_cst:
+; CHECK: ldarb w0, [x0]
+ %r = load atomic i8, ptr %ptr seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @load_atomic_i8_unaligned_seq_cst_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i8_unaligned_seq_cst_const:
+; CHECK: ldarb w0, [x0]
+ %r = load atomic i8, ptr %ptr seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @load_atomic_i16_unaligned_unordered(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i16_unaligned_unordered:
+; CHECK: bl __atomic_load
+ %r = load atomic i16, ptr %ptr unordered, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_unaligned_unordered_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i16_unaligned_unordered_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i16, ptr %ptr unordered, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_unaligned_monotonic(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i16_unaligned_monotonic:
+; CHECK: bl __atomic_load
+ %r = load atomic i16, ptr %ptr monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_unaligned_monotonic_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i16_unaligned_monotonic_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i16, ptr %ptr monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_unaligned_acquire(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i16_unaligned_acquire:
+; CHECK: bl __atomic_load
+ %r = load atomic i16, ptr %ptr acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_unaligned_acquire_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i16_unaligned_acquire_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i16, ptr %ptr acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_unaligned_seq_cst(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i16_unaligned_seq_cst:
+; CHECK: bl __atomic_load
+ %r = load atomic i16, ptr %ptr seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @load_atomic_i16_unaligned_seq_cst_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i16_unaligned_seq_cst_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i16, ptr %ptr seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i32 @load_atomic_i32_unaligned_unordered(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i32_unaligned_unordered:
+; CHECK: bl __atomic_load
+ %r = load atomic i32, ptr %ptr unordered, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_unaligned_unordered_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i32_unaligned_unordered_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i32, ptr %ptr unordered, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_unaligned_monotonic(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i32_unaligned_monotonic:
+; CHECK: bl __atomic_load
+ %r = load atomic i32, ptr %ptr monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_unaligned_monotonic_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i32_unaligned_monotonic_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i32, ptr %ptr monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_unaligned_acquire(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i32_unaligned_acquire:
+; CHECK: bl __atomic_load
+ %r = load atomic i32, ptr %ptr acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_unaligned_acquire_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i32_unaligned_acquire_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i32, ptr %ptr acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_unaligned_seq_cst(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i32_unaligned_seq_cst:
+; CHECK: bl __atomic_load
+ %r = load atomic i32, ptr %ptr seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @load_atomic_i32_unaligned_seq_cst_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i32_unaligned_seq_cst_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i32, ptr %ptr seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i64 @load_atomic_i64_unaligned_unordered(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i64_unaligned_unordered:
+; CHECK: bl __atomic_load
+ %r = load atomic i64, ptr %ptr unordered, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_unaligned_unordered_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i64_unaligned_unordered_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i64, ptr %ptr unordered, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_unaligned_monotonic(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i64_unaligned_monotonic:
+; CHECK: bl __atomic_load
+ %r = load atomic i64, ptr %ptr monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_unaligned_monotonic_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i64_unaligned_monotonic_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i64, ptr %ptr monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_unaligned_acquire(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i64_unaligned_acquire:
+; CHECK: bl __atomic_load
+ %r = load atomic i64, ptr %ptr acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_unaligned_acquire_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i64_unaligned_acquire_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i64, ptr %ptr acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_unaligned_seq_cst(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i64_unaligned_seq_cst:
+; CHECK: bl __atomic_load
+ %r = load atomic i64, ptr %ptr seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @load_atomic_i64_unaligned_seq_cst_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i64_unaligned_seq_cst_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i64, ptr %ptr seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i128 @load_atomic_i128_unaligned_unordered(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i128_unaligned_unordered:
+; CHECK: bl __atomic_load
+ %r = load atomic i128, ptr %ptr unordered, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_unaligned_unordered_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i128_unaligned_unordered_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i128, ptr %ptr unordered, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_unaligned_monotonic(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i128_unaligned_monotonic:
+; CHECK: bl __atomic_load
+ %r = load atomic i128, ptr %ptr monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_unaligned_monotonic_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i128_unaligned_monotonic_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i128, ptr %ptr monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_unaligned_acquire(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i128_unaligned_acquire:
+; CHECK: bl __atomic_load
+ %r = load atomic i128, ptr %ptr acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_unaligned_acquire_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i128_unaligned_acquire_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i128, ptr %ptr acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_unaligned_seq_cst(ptr %ptr) {
+; CHECK-LABEL: load_atomic_i128_unaligned_seq_cst:
+; CHECK: bl __atomic_load
+ %r = load atomic i128, ptr %ptr seq_cst, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @load_atomic_i128_unaligned_seq_cst_const(ptr readonly %ptr) {
+; CHECK-LABEL: load_atomic_i128_unaligned_seq_cst_const:
+; CHECK: bl __atomic_load
+ %r = load atomic i128, ptr %ptr seq_cst, align 1
+ ret i128 %r
+}
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; -O0: {{.*}}
+; -O1: {{.*}}
diff --git a/llvm/test/CodeGen/AArch64/Atomics/aarch64_be-atomic-store-lse2_lse128.ll b/llvm/test/CodeGen/AArch64/Atomics/aarch64_be-atomic-store-lse2_lse128.ll
new file mode 100644
index 000000000000..8ae016249fef
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/Atomics/aarch64_be-atomic-store-lse2_lse128.ll
@@ -0,0 +1,290 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --filter-out "\b(sp)\b" --filter "^\s*(ld[^r]|st|swp|cas|bl|add|and|eor|orn|orr|sub|mvn|sxt|cmp|ccmp|csel|dmb)"
+; The base test file was generated by ./llvm/test/CodeGen/AArch64/Atomics/generate-tests.py
+; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64_be -mattr=+lse2,+lse128 -O0 | FileCheck %s --check-prefixes=CHECK,-O0
+; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64_be -mattr=+lse2,+lse128 -O1 | FileCheck %s --check-prefixes=CHECK,-O1
+
+define dso_local void @store_atomic_i8_aligned_unordered(i8 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i8_aligned_unordered:
+; CHECK: strb w0, [x1]
+ store atomic i8 %value, ptr %ptr unordered, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i8_aligned_monotonic(i8 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i8_aligned_monotonic:
+; CHECK: strb w0, [x1]
+ store atomic i8 %value, ptr %ptr monotonic, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i8_aligned_release(i8 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i8_aligned_release:
+; CHECK: stlrb w0, [x1]
+ store atomic i8 %value, ptr %ptr release, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i8_aligned_seq_cst(i8 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i8_aligned_seq_cst:
+; CHECK: stlrb w0, [x1]
+ store atomic i8 %value, ptr %ptr seq_cst, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i16_aligned_unordered(i16 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i16_aligned_unordered:
+; CHECK: strh w0, [x1]
+ store atomic i16 %value, ptr %ptr unordered, align 2
+ ret void
+}
+
+define dso_local void @store_atomic_i16_aligned_monotonic(i16 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i16_aligned_monotonic:
+; CHECK: strh w0, [x1]
+ store atomic i16 %value, ptr %ptr monotonic, align 2
+ ret void
+}
+
+define dso_local void @store_atomic_i16_aligned_release(i16 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i16_aligned_release:
+; CHECK: stlrh w0, [x1]
+ store atomic i16 %value, ptr %ptr release, align 2
+ ret void
+}
+
+define dso_local void @store_atomic_i16_aligned_seq_cst(i16 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i16_aligned_seq_cst:
+; CHECK: stlrh w0, [x1]
+ store atomic i16 %value, ptr %ptr seq_cst, align 2
+ ret void
+}
+
+define dso_local void @store_atomic_i32_aligned_unordered(i32 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i32_aligned_unordered:
+; CHECK: str w0, [x1]
+ store atomic i32 %value, ptr %ptr unordered, align 4
+ ret void
+}
+
+define dso_local void @store_atomic_i32_aligned_monotonic(i32 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i32_aligned_monotonic:
+; CHECK: str w0, [x1]
+ store atomic i32 %value, ptr %ptr monotonic, align 4
+ ret void
+}
+
+define dso_local void @store_atomic_i32_aligned_release(i32 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i32_aligned_release:
+; CHECK: stlr w0, [x1]
+ store atomic i32 %value, ptr %ptr release, align 4
+ ret void
+}
+
+define dso_local void @store_atomic_i32_aligned_seq_cst(i32 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i32_aligned_seq_cst:
+; CHECK: stlr w0, [x1]
+ store atomic i32 %value, ptr %ptr seq_cst, align 4
+ ret void
+}
+
+define dso_local void @store_atomic_i64_aligned_unordered(i64 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i64_aligned_unordered:
+; CHECK: str x0, [x1]
+ store atomic i64 %value, ptr %ptr unordered, align 8
+ ret void
+}
+
+define dso_local void @store_atomic_i64_aligned_monotonic(i64 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i64_aligned_monotonic:
+; CHECK: str x0, [x1]
+ store atomic i64 %value, ptr %ptr monotonic, align 8
+ ret void
+}
+
+define dso_local void @store_atomic_i64_aligned_release(i64 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i64_aligned_release:
+; CHECK: stlr x0, [x1]
+ store atomic i64 %value, ptr %ptr release, align 8
+ ret void
+}
+
+define dso_local void @store_atomic_i64_aligned_seq_cst(i64 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i64_aligned_seq_cst:
+; CHECK: stlr x0, [x1]
+ store atomic i64 %value, ptr %ptr seq_cst, align 8
+ ret void
+}
+
+define dso_local void @store_atomic_i128_aligned_unordered(i128 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i128_aligned_unordered:
+; CHECK: stp x1, x0, [x2]
+ store atomic i128 %value, ptr %ptr unordered, align 16
+ ret void
+}
+
+define dso_local void @store_atomic_i128_aligned_monotonic(i128 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i128_aligned_monotonic:
+; CHECK: stp x1, x0, [x2]
+ store atomic i128 %value, ptr %ptr monotonic, align 16
+ ret void
+}
+
+define dso_local void @store_atomic_i128_aligned_release(i128 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i128_aligned_release:
+; CHECK: dmb ish
+; CHECK: stp x1, x0, [x2]
+ store atomic i128 %value, ptr %ptr release, align 16
+ ret void
+}
+
+define dso_local void @store_atomic_i128_aligned_seq_cst(i128 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i128_aligned_seq_cst:
+; CHECK: dmb ish
+; CHECK: stp x1, x0, [x2]
+; CHECK: dmb ish
+ store atomic i128 %value, ptr %ptr seq_cst, align 16
+ ret void
+}
+
+define dso_local void @store_atomic_i8_unaligned_unordered(i8 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i8_unaligned_unordered:
+; CHECK: strb w0, [x1]
+ store atomic i8 %value, ptr %ptr unordered, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i8_unaligned_monotonic(i8 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i8_unaligned_monotonic:
+; CHECK: strb w0, [x1]
+ store atomic i8 %value, ptr %ptr monotonic, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i8_unaligned_release(i8 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i8_unaligned_release:
+; CHECK: stlrb w0, [x1]
+ store atomic i8 %value, ptr %ptr release, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i8_unaligned_seq_cst(i8 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i8_unaligned_seq_cst:
+; CHECK: stlrb w0, [x1]
+ store atomic i8 %value, ptr %ptr seq_cst, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i16_unaligned_unordered(i16 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i16_unaligned_unordered:
+; CHECK: bl __atomic_store
+ store atomic i16 %value, ptr %ptr unordered, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i16_unaligned_monotonic(i16 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i16_unaligned_monotonic:
+; CHECK: bl __atomic_store
+ store atomic i16 %value, ptr %ptr monotonic, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i16_unaligned_release(i16 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i16_unaligned_release:
+; CHECK: bl __atomic_store
+ store atomic i16 %value, ptr %ptr release, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i16_unaligned_seq_cst(i16 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i16_unaligned_seq_cst:
+; CHECK: bl __atomic_store
+ store atomic i16 %value, ptr %ptr seq_cst, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i32_unaligned_unordered(i32 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i32_unaligned_unordered:
+; CHECK: bl __atomic_store
+ store atomic i32 %value, ptr %ptr unordered, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i32_unaligned_monotonic(i32 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i32_unaligned_monotonic:
+; CHECK: bl __atomic_store
+ store atomic i32 %value, ptr %ptr monotonic, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i32_unaligned_release(i32 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i32_unaligned_release:
+; CHECK: bl __atomic_store
+ store atomic i32 %value, ptr %ptr release, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i32_unaligned_seq_cst(i32 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i32_unaligned_seq_cst:
+; CHECK: bl __atomic_store
+ store atomic i32 %value, ptr %ptr seq_cst, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i64_unaligned_unordered(i64 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i64_unaligned_unordered:
+; CHECK: bl __atomic_store
+ store atomic i64 %value, ptr %ptr unordered, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i64_unaligned_monotonic(i64 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i64_unaligned_monotonic:
+; CHECK: bl __atomic_store
+ store atomic i64 %value, ptr %ptr monotonic, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i64_unaligned_release(i64 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i64_unaligned_release:
+; CHECK: bl __atomic_store
+ store atomic i64 %value, ptr %ptr release, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i64_unaligned_seq_cst(i64 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i64_unaligned_seq_cst:
+; CHECK: bl __atomic_store
+ store atomic i64 %value, ptr %ptr seq_cst, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i128_unaligned_unordered(i128 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i128_unaligned_unordered:
+; CHECK: bl __atomic_store
+ store atomic i128 %value, ptr %ptr unordered, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i128_unaligned_monotonic(i128 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i128_unaligned_monotonic:
+; CHECK: bl __atomic_store
+ store atomic i128 %value, ptr %ptr monotonic, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i128_unaligned_release(i128 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i128_unaligned_release:
+; CHECK: bl __atomic_store
+ store atomic i128 %value, ptr %ptr release, align 1
+ ret void
+}
+
+define dso_local void @store_atomic_i128_unaligned_seq_cst(i128 %value, ptr %ptr) {
+; CHECK-LABEL: store_atomic_i128_unaligned_seq_cst:
+; CHECK: bl __atomic_store
+ store atomic i128 %value, ptr %ptr seq_cst, align 1
+ ret void
+}
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; -O0: {{.*}}
+; -O1: {{.*}}
diff --git a/llvm/test/CodeGen/AArch64/Atomics/aarch64_be-atomicrmw-lse2_lse128.ll b/llvm/test/CodeGen/AArch64/Atomics/aarch64_be-atomicrmw-lse2_lse128.ll
new file mode 100644
index 000000000000..bb1702bc58ca
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/Atomics/aarch64_be-atomicrmw-lse2_lse128.ll
@@ -0,0 +1,6194 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --filter-out "\b(sp)\b" --filter "^\s*(ld[^r]|st[^r]|swp|cas|bl|add|and|eor|orn|orr|sub|mvn|sxt|cmp|ccmp|csel|dmb)"
+; The base test file was generated by ./llvm/test/CodeGen/AArch64/Atomics/generate-tests.py
+; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64_be -mattr=+lse2,+lse128 -O0 | FileCheck %s --check-prefixes=CHECK,-O0
+; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64_be -mattr=+lse2,+lse128 -O1 | FileCheck %s --check-prefixes=CHECK,-O1
+
+define dso_local i8 @atomicrmw_xchg_i8_aligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i8_aligned_monotonic:
+; CHECK: swpb w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xchg_i8_aligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i8_aligned_acquire:
+; CHECK: swpab w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xchg_i8_aligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i8_aligned_release:
+; CHECK: swplb w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xchg_i8_aligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i8_aligned_acq_rel:
+; CHECK: swpalb w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xchg_i8_aligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i8_aligned_seq_cst:
+; CHECK: swpalb w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_xchg_i16_aligned_monotonic(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i16_aligned_monotonic:
+; CHECK: swph w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i16 %value monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xchg_i16_aligned_acquire(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i16_aligned_acquire:
+; CHECK: swpah w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i16 %value acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xchg_i16_aligned_release(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i16_aligned_release:
+; CHECK: swplh w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i16 %value release, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xchg_i16_aligned_acq_rel(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i16_aligned_acq_rel:
+; CHECK: swpalh w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i16 %value acq_rel, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xchg_i16_aligned_seq_cst(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i16_aligned_seq_cst:
+; CHECK: swpalh w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i16 %value seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_xchg_i32_aligned_monotonic(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i32_aligned_monotonic:
+; CHECK: swp w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i32 %value monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xchg_i32_aligned_acquire(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i32_aligned_acquire:
+; CHECK: swpa w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i32 %value acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xchg_i32_aligned_release(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i32_aligned_release:
+; CHECK: swpl w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i32 %value release, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xchg_i32_aligned_acq_rel(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i32_aligned_acq_rel:
+; CHECK: swpal w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i32 %value acq_rel, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xchg_i32_aligned_seq_cst(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i32_aligned_seq_cst:
+; CHECK: swpal w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i32 %value seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_xchg_i64_aligned_monotonic(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i64_aligned_monotonic:
+; CHECK: swp x1, x0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i64 %value monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xchg_i64_aligned_acquire(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i64_aligned_acquire:
+; CHECK: swpa x1, x0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i64 %value acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xchg_i64_aligned_release(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i64_aligned_release:
+; CHECK: swpl x1, x0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i64 %value release, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xchg_i64_aligned_acq_rel(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i64_aligned_acq_rel:
+; CHECK: swpal x1, x0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i64 %value acq_rel, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xchg_i64_aligned_seq_cst(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i64_aligned_seq_cst:
+; CHECK: swpal x1, x0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i64 %value seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_xchg_i128_aligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xchg_i128_aligned_monotonic:
+; -O0: swpp x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_xchg_i128_aligned_monotonic:
+; -O1: swpp x2, x1, [x0]
+ %r = atomicrmw xchg ptr %ptr, i128 %value monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xchg_i128_aligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xchg_i128_aligned_acquire:
+; -O0: swppa x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_xchg_i128_aligned_acquire:
+; -O1: swppa x2, x1, [x0]
+ %r = atomicrmw xchg ptr %ptr, i128 %value acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xchg_i128_aligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xchg_i128_aligned_release:
+; -O0: swppl x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_xchg_i128_aligned_release:
+; -O1: swppl x2, x1, [x0]
+ %r = atomicrmw xchg ptr %ptr, i128 %value release, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xchg_i128_aligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xchg_i128_aligned_acq_rel:
+; -O0: swppal x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_xchg_i128_aligned_acq_rel:
+; -O1: swppal x2, x1, [x0]
+ %r = atomicrmw xchg ptr %ptr, i128 %value acq_rel, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xchg_i128_aligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xchg_i128_aligned_seq_cst:
+; -O0: swppal x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_xchg_i128_aligned_seq_cst:
+; -O1: swppal x2, x1, [x0]
+ %r = atomicrmw xchg ptr %ptr, i128 %value seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_xchg_i8_unaligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i8_unaligned_monotonic:
+; CHECK: swpb w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xchg_i8_unaligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i8_unaligned_acquire:
+; CHECK: swpab w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xchg_i8_unaligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i8_unaligned_release:
+; CHECK: swplb w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xchg_i8_unaligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i8_unaligned_acq_rel:
+; CHECK: swpalb w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xchg_i8_unaligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i8_unaligned_seq_cst:
+; CHECK: swpalb w1, w0, [x0]
+ %r = atomicrmw xchg ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_xchg_i16_unaligned_monotonic(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i16_unaligned_monotonic:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i16 %value monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xchg_i16_unaligned_acquire(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i16_unaligned_acquire:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i16 %value acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xchg_i16_unaligned_release(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i16_unaligned_release:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i16 %value release, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xchg_i16_unaligned_acq_rel(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i16_unaligned_acq_rel:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i16 %value acq_rel, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xchg_i16_unaligned_seq_cst(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i16_unaligned_seq_cst:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i16 %value seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_xchg_i32_unaligned_monotonic(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i32_unaligned_monotonic:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i32 %value monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xchg_i32_unaligned_acquire(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i32_unaligned_acquire:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i32 %value acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xchg_i32_unaligned_release(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i32_unaligned_release:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i32 %value release, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xchg_i32_unaligned_acq_rel(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i32_unaligned_acq_rel:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i32 %value acq_rel, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xchg_i32_unaligned_seq_cst(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i32_unaligned_seq_cst:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i32 %value seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_xchg_i64_unaligned_monotonic(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i64_unaligned_monotonic:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i64 %value monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xchg_i64_unaligned_acquire(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i64_unaligned_acquire:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i64 %value acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xchg_i64_unaligned_release(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i64_unaligned_release:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i64 %value release, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xchg_i64_unaligned_acq_rel(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i64_unaligned_acq_rel:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i64 %value acq_rel, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xchg_i64_unaligned_seq_cst(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i64_unaligned_seq_cst:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i64 %value seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_xchg_i128_unaligned_monotonic(ptr %ptr, i128 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i128_unaligned_monotonic:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i128 %value monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xchg_i128_unaligned_acquire(ptr %ptr, i128 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i128_unaligned_acquire:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i128 %value acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xchg_i128_unaligned_release(ptr %ptr, i128 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i128_unaligned_release:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i128 %value release, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xchg_i128_unaligned_acq_rel(ptr %ptr, i128 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i128_unaligned_acq_rel:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i128 %value acq_rel, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xchg_i128_unaligned_seq_cst(ptr %ptr, i128 %value) {
+; CHECK-LABEL: atomicrmw_xchg_i128_unaligned_seq_cst:
+; CHECK: bl __atomic_exchange
+ %r = atomicrmw xchg ptr %ptr, i128 %value seq_cst, align 1
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_add_i8_aligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_add_i8_aligned_monotonic:
+; CHECK: ldaddb w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_add_i8_aligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_add_i8_aligned_acquire:
+; CHECK: ldaddab w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_add_i8_aligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_add_i8_aligned_release:
+; CHECK: ldaddlb w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_add_i8_aligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_add_i8_aligned_acq_rel:
+; CHECK: ldaddalb w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_add_i8_aligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_add_i8_aligned_seq_cst:
+; CHECK: ldaddalb w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_add_i16_aligned_monotonic(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_add_i16_aligned_monotonic:
+; CHECK: ldaddh w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i16 %value monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_add_i16_aligned_acquire(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_add_i16_aligned_acquire:
+; CHECK: ldaddah w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i16 %value acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_add_i16_aligned_release(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_add_i16_aligned_release:
+; CHECK: ldaddlh w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i16 %value release, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_add_i16_aligned_acq_rel(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_add_i16_aligned_acq_rel:
+; CHECK: ldaddalh w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i16 %value acq_rel, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_add_i16_aligned_seq_cst(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_add_i16_aligned_seq_cst:
+; CHECK: ldaddalh w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i16 %value seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_add_i32_aligned_monotonic(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_add_i32_aligned_monotonic:
+; CHECK: ldadd w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i32 %value monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_add_i32_aligned_acquire(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_add_i32_aligned_acquire:
+; CHECK: ldadda w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i32 %value acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_add_i32_aligned_release(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_add_i32_aligned_release:
+; CHECK: ldaddl w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i32 %value release, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_add_i32_aligned_acq_rel(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_add_i32_aligned_acq_rel:
+; CHECK: ldaddal w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i32 %value acq_rel, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_add_i32_aligned_seq_cst(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_add_i32_aligned_seq_cst:
+; CHECK: ldaddal w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i32 %value seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_add_i64_aligned_monotonic(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_add_i64_aligned_monotonic:
+; CHECK: ldadd x1, x0, [x0]
+ %r = atomicrmw add ptr %ptr, i64 %value monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_add_i64_aligned_acquire(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_add_i64_aligned_acquire:
+; CHECK: ldadda x1, x0, [x0]
+ %r = atomicrmw add ptr %ptr, i64 %value acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_add_i64_aligned_release(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_add_i64_aligned_release:
+; CHECK: ldaddl x1, x0, [x0]
+ %r = atomicrmw add ptr %ptr, i64 %value release, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_add_i64_aligned_acq_rel(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_add_i64_aligned_acq_rel:
+; CHECK: ldaddal x1, x0, [x0]
+ %r = atomicrmw add ptr %ptr, i64 %value acq_rel, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_add_i64_aligned_seq_cst(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_add_i64_aligned_seq_cst:
+; CHECK: ldaddal x1, x0, [x0]
+ %r = atomicrmw add ptr %ptr, i64 %value seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_add_i128_aligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_add_i128_aligned_monotonic:
+; -O0: adds x9, x10, x9
+; -O0: casp x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_add_i128_aligned_monotonic:
+; -O1: ldp x4, x5, [x0]
+; -O1: adds x9, x7, x3
+; -O1: casp x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw add ptr %ptr, i128 %value monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_add_i128_aligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_add_i128_aligned_acquire:
+; -O0: adds x9, x10, x9
+; -O0: caspa x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_add_i128_aligned_acquire:
+; -O1: ldp x4, x5, [x0]
+; -O1: adds x9, x7, x3
+; -O1: caspa x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw add ptr %ptr, i128 %value acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_add_i128_aligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_add_i128_aligned_release:
+; -O0: adds x9, x10, x9
+; -O0: caspl x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_add_i128_aligned_release:
+; -O1: ldp x4, x5, [x0]
+; -O1: adds x9, x7, x3
+; -O1: caspl x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw add ptr %ptr, i128 %value release, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_add_i128_aligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_add_i128_aligned_acq_rel:
+; -O0: adds x9, x10, x9
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_add_i128_aligned_acq_rel:
+; -O1: ldp x4, x5, [x0]
+; -O1: adds x9, x7, x3
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw add ptr %ptr, i128 %value acq_rel, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_add_i128_aligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_add_i128_aligned_seq_cst:
+; -O0: adds x9, x10, x9
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_add_i128_aligned_seq_cst:
+; -O1: ldp x4, x5, [x0]
+; -O1: adds x9, x7, x3
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw add ptr %ptr, i128 %value seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_add_i8_unaligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_add_i8_unaligned_monotonic:
+; CHECK: ldaddb w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_add_i8_unaligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_add_i8_unaligned_acquire:
+; CHECK: ldaddab w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_add_i8_unaligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_add_i8_unaligned_release:
+; CHECK: ldaddlb w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_add_i8_unaligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_add_i8_unaligned_acq_rel:
+; CHECK: ldaddalb w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_add_i8_unaligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_add_i8_unaligned_seq_cst:
+; CHECK: ldaddalb w1, w0, [x0]
+ %r = atomicrmw add ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_add_i16_unaligned_monotonic(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_add_i16_unaligned_monotonic:
+; -O0: add w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i16_unaligned_monotonic:
+; -O1: add w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i16 %value monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_add_i16_unaligned_acquire(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_add_i16_unaligned_acquire:
+; -O0: add w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i16_unaligned_acquire:
+; -O1: add w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i16 %value acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_add_i16_unaligned_release(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_add_i16_unaligned_release:
+; -O0: add w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i16_unaligned_release:
+; -O1: add w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i16 %value release, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_add_i16_unaligned_acq_rel(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_add_i16_unaligned_acq_rel:
+; -O0: add w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i16_unaligned_acq_rel:
+; -O1: add w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i16 %value acq_rel, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_add_i16_unaligned_seq_cst(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_add_i16_unaligned_seq_cst:
+; -O0: add w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i16_unaligned_seq_cst:
+; -O1: add w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i16 %value seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_add_i32_unaligned_monotonic(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_add_i32_unaligned_monotonic:
+; -O0: add w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i32_unaligned_monotonic:
+; -O1: add w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i32 %value monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_add_i32_unaligned_acquire(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_add_i32_unaligned_acquire:
+; -O0: add w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i32_unaligned_acquire:
+; -O1: add w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i32 %value acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_add_i32_unaligned_release(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_add_i32_unaligned_release:
+; -O0: add w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i32_unaligned_release:
+; -O1: add w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i32 %value release, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_add_i32_unaligned_acq_rel(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_add_i32_unaligned_acq_rel:
+; -O0: add w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i32_unaligned_acq_rel:
+; -O1: add w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i32 %value acq_rel, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_add_i32_unaligned_seq_cst(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_add_i32_unaligned_seq_cst:
+; -O0: add w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i32_unaligned_seq_cst:
+; -O1: add w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i32 %value seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_add_i64_unaligned_monotonic(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_add_i64_unaligned_monotonic:
+; -O0: add x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i64_unaligned_monotonic:
+; -O1: add x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i64 %value monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_add_i64_unaligned_acquire(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_add_i64_unaligned_acquire:
+; -O0: add x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i64_unaligned_acquire:
+; -O1: add x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i64 %value acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_add_i64_unaligned_release(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_add_i64_unaligned_release:
+; -O0: add x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i64_unaligned_release:
+; -O1: add x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i64 %value release, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_add_i64_unaligned_acq_rel(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_add_i64_unaligned_acq_rel:
+; -O0: add x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i64_unaligned_acq_rel:
+; -O1: add x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i64 %value acq_rel, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_add_i64_unaligned_seq_cst(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_add_i64_unaligned_seq_cst:
+; -O0: add x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i64_unaligned_seq_cst:
+; -O1: add x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i64 %value seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_add_i128_unaligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_add_i128_unaligned_monotonic:
+; -O0: adds x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i128_unaligned_monotonic:
+; -O1: ldp x0, x1, [x0]
+; -O1: adds x8, x1, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i128 %value monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_add_i128_unaligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_add_i128_unaligned_acquire:
+; -O0: adds x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i128_unaligned_acquire:
+; -O1: ldp x0, x1, [x0]
+; -O1: adds x8, x1, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i128 %value acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_add_i128_unaligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_add_i128_unaligned_release:
+; -O0: adds x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i128_unaligned_release:
+; -O1: ldp x0, x1, [x0]
+; -O1: adds x8, x1, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i128 %value release, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_add_i128_unaligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_add_i128_unaligned_acq_rel:
+; -O0: adds x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i128_unaligned_acq_rel:
+; -O1: ldp x0, x1, [x0]
+; -O1: adds x8, x1, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i128 %value acq_rel, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_add_i128_unaligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_add_i128_unaligned_seq_cst:
+; -O0: adds x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_add_i128_unaligned_seq_cst:
+; -O1: ldp x0, x1, [x0]
+; -O1: adds x8, x1, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw add ptr %ptr, i128 %value seq_cst, align 1
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_sub_i8_aligned_monotonic(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_sub_i8_aligned_monotonic:
+; -O0: subs w8, w8, w1
+; -O0: ldaddb w8, w0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i8_aligned_monotonic:
+; -O1: ldaddb w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_sub_i8_aligned_acquire(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_sub_i8_aligned_acquire:
+; -O0: subs w8, w8, w1
+; -O0: ldaddab w8, w0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i8_aligned_acquire:
+; -O1: ldaddab w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_sub_i8_aligned_release(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_sub_i8_aligned_release:
+; -O0: subs w8, w8, w1
+; -O0: ldaddlb w8, w0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i8_aligned_release:
+; -O1: ldaddlb w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_sub_i8_aligned_acq_rel(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_sub_i8_aligned_acq_rel:
+; -O0: subs w8, w8, w1
+; -O0: ldaddalb w8, w0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i8_aligned_acq_rel:
+; -O1: ldaddalb w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_sub_i8_aligned_seq_cst(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_sub_i8_aligned_seq_cst:
+; -O0: subs w8, w8, w1
+; -O0: ldaddalb w8, w0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i8_aligned_seq_cst:
+; -O1: ldaddalb w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_sub_i16_aligned_monotonic(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_sub_i16_aligned_monotonic:
+; -O0: subs w8, w8, w1
+; -O0: ldaddh w8, w0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i16_aligned_monotonic:
+; -O1: ldaddh w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i16 %value monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_sub_i16_aligned_acquire(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_sub_i16_aligned_acquire:
+; -O0: subs w8, w8, w1
+; -O0: ldaddah w8, w0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i16_aligned_acquire:
+; -O1: ldaddah w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i16 %value acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_sub_i16_aligned_release(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_sub_i16_aligned_release:
+; -O0: subs w8, w8, w1
+; -O0: ldaddlh w8, w0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i16_aligned_release:
+; -O1: ldaddlh w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i16 %value release, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_sub_i16_aligned_acq_rel(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_sub_i16_aligned_acq_rel:
+; -O0: subs w8, w8, w1
+; -O0: ldaddalh w8, w0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i16_aligned_acq_rel:
+; -O1: ldaddalh w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i16 %value acq_rel, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_sub_i16_aligned_seq_cst(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_sub_i16_aligned_seq_cst:
+; -O0: subs w8, w8, w1
+; -O0: ldaddalh w8, w0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i16_aligned_seq_cst:
+; -O1: ldaddalh w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i16 %value seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_sub_i32_aligned_monotonic(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_sub_i32_aligned_monotonic:
+; -O0: subs w8, w8, w1
+; -O0: ldadd w8, w0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i32_aligned_monotonic:
+; -O1: ldadd w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i32 %value monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_sub_i32_aligned_acquire(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_sub_i32_aligned_acquire:
+; -O0: subs w8, w8, w1
+; -O0: ldadda w8, w0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i32_aligned_acquire:
+; -O1: ldadda w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i32 %value acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_sub_i32_aligned_release(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_sub_i32_aligned_release:
+; -O0: subs w8, w8, w1
+; -O0: ldaddl w8, w0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i32_aligned_release:
+; -O1: ldaddl w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i32 %value release, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_sub_i32_aligned_acq_rel(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_sub_i32_aligned_acq_rel:
+; -O0: subs w8, w8, w1
+; -O0: ldaddal w8, w0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i32_aligned_acq_rel:
+; -O1: ldaddal w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i32 %value acq_rel, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_sub_i32_aligned_seq_cst(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_sub_i32_aligned_seq_cst:
+; -O0: subs w8, w8, w1
+; -O0: ldaddal w8, w0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i32_aligned_seq_cst:
+; -O1: ldaddal w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i32 %value seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_sub_i64_aligned_monotonic(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_sub_i64_aligned_monotonic:
+; -O0: subs x8, x8, x1
+; -O0: ldadd x8, x0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i64_aligned_monotonic:
+; -O1: ldadd x8, x0, [x0]
+ %r = atomicrmw sub ptr %ptr, i64 %value monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_sub_i64_aligned_acquire(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_sub_i64_aligned_acquire:
+; -O0: subs x8, x8, x1
+; -O0: ldadda x8, x0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i64_aligned_acquire:
+; -O1: ldadda x8, x0, [x0]
+ %r = atomicrmw sub ptr %ptr, i64 %value acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_sub_i64_aligned_release(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_sub_i64_aligned_release:
+; -O0: subs x8, x8, x1
+; -O0: ldaddl x8, x0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i64_aligned_release:
+; -O1: ldaddl x8, x0, [x0]
+ %r = atomicrmw sub ptr %ptr, i64 %value release, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_sub_i64_aligned_acq_rel(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_sub_i64_aligned_acq_rel:
+; -O0: subs x8, x8, x1
+; -O0: ldaddal x8, x0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i64_aligned_acq_rel:
+; -O1: ldaddal x8, x0, [x0]
+ %r = atomicrmw sub ptr %ptr, i64 %value acq_rel, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_sub_i64_aligned_seq_cst(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_sub_i64_aligned_seq_cst:
+; -O0: subs x8, x8, x1
+; -O0: ldaddal x8, x0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i64_aligned_seq_cst:
+; -O1: ldaddal x8, x0, [x0]
+ %r = atomicrmw sub ptr %ptr, i64 %value seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_sub_i128_aligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_sub_i128_aligned_monotonic:
+; -O0: subs x9, x10, x9
+; -O0: casp x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_sub_i128_aligned_monotonic:
+; -O1: ldp x4, x5, [x0]
+; -O1: subs x9, x7, x3
+; -O1: casp x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw sub ptr %ptr, i128 %value monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_sub_i128_aligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_sub_i128_aligned_acquire:
+; -O0: subs x9, x10, x9
+; -O0: caspa x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_sub_i128_aligned_acquire:
+; -O1: ldp x4, x5, [x0]
+; -O1: subs x9, x7, x3
+; -O1: caspa x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw sub ptr %ptr, i128 %value acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_sub_i128_aligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_sub_i128_aligned_release:
+; -O0: subs x9, x10, x9
+; -O0: caspl x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_sub_i128_aligned_release:
+; -O1: ldp x4, x5, [x0]
+; -O1: subs x9, x7, x3
+; -O1: caspl x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw sub ptr %ptr, i128 %value release, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_sub_i128_aligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_sub_i128_aligned_acq_rel:
+; -O0: subs x9, x10, x9
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_sub_i128_aligned_acq_rel:
+; -O1: ldp x4, x5, [x0]
+; -O1: subs x9, x7, x3
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw sub ptr %ptr, i128 %value acq_rel, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_sub_i128_aligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_sub_i128_aligned_seq_cst:
+; -O0: subs x9, x10, x9
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_sub_i128_aligned_seq_cst:
+; -O1: ldp x4, x5, [x0]
+; -O1: subs x9, x7, x3
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw sub ptr %ptr, i128 %value seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_sub_i8_unaligned_monotonic(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_sub_i8_unaligned_monotonic:
+; -O0: subs w8, w8, w1
+; -O0: ldaddb w8, w0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i8_unaligned_monotonic:
+; -O1: ldaddb w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_sub_i8_unaligned_acquire(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_sub_i8_unaligned_acquire:
+; -O0: subs w8, w8, w1
+; -O0: ldaddab w8, w0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i8_unaligned_acquire:
+; -O1: ldaddab w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_sub_i8_unaligned_release(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_sub_i8_unaligned_release:
+; -O0: subs w8, w8, w1
+; -O0: ldaddlb w8, w0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i8_unaligned_release:
+; -O1: ldaddlb w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_sub_i8_unaligned_acq_rel(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_sub_i8_unaligned_acq_rel:
+; -O0: subs w8, w8, w1
+; -O0: ldaddalb w8, w0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i8_unaligned_acq_rel:
+; -O1: ldaddalb w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_sub_i8_unaligned_seq_cst(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_sub_i8_unaligned_seq_cst:
+; -O0: subs w8, w8, w1
+; -O0: ldaddalb w8, w0, [x0]
+;
+; -O1-LABEL: atomicrmw_sub_i8_unaligned_seq_cst:
+; -O1: ldaddalb w8, w0, [x0]
+ %r = atomicrmw sub ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_sub_i16_unaligned_monotonic(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_sub_i16_unaligned_monotonic:
+; -O0: subs w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i16_unaligned_monotonic:
+; -O1: sub w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i16 %value monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_sub_i16_unaligned_acquire(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_sub_i16_unaligned_acquire:
+; -O0: subs w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i16_unaligned_acquire:
+; -O1: sub w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i16 %value acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_sub_i16_unaligned_release(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_sub_i16_unaligned_release:
+; -O0: subs w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i16_unaligned_release:
+; -O1: sub w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i16 %value release, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_sub_i16_unaligned_acq_rel(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_sub_i16_unaligned_acq_rel:
+; -O0: subs w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i16_unaligned_acq_rel:
+; -O1: sub w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i16 %value acq_rel, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_sub_i16_unaligned_seq_cst(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_sub_i16_unaligned_seq_cst:
+; -O0: subs w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i16_unaligned_seq_cst:
+; -O1: sub w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i16 %value seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_sub_i32_unaligned_monotonic(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_sub_i32_unaligned_monotonic:
+; -O0: subs w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i32_unaligned_monotonic:
+; -O1: sub w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i32 %value monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_sub_i32_unaligned_acquire(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_sub_i32_unaligned_acquire:
+; -O0: subs w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i32_unaligned_acquire:
+; -O1: sub w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i32 %value acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_sub_i32_unaligned_release(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_sub_i32_unaligned_release:
+; -O0: subs w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i32_unaligned_release:
+; -O1: sub w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i32 %value release, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_sub_i32_unaligned_acq_rel(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_sub_i32_unaligned_acq_rel:
+; -O0: subs w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i32_unaligned_acq_rel:
+; -O1: sub w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i32 %value acq_rel, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_sub_i32_unaligned_seq_cst(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_sub_i32_unaligned_seq_cst:
+; -O0: subs w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i32_unaligned_seq_cst:
+; -O1: sub w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i32 %value seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_sub_i64_unaligned_monotonic(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_sub_i64_unaligned_monotonic:
+; -O0: subs x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i64_unaligned_monotonic:
+; -O1: sub x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i64 %value monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_sub_i64_unaligned_acquire(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_sub_i64_unaligned_acquire:
+; -O0: subs x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i64_unaligned_acquire:
+; -O1: sub x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i64 %value acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_sub_i64_unaligned_release(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_sub_i64_unaligned_release:
+; -O0: subs x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i64_unaligned_release:
+; -O1: sub x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i64 %value release, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_sub_i64_unaligned_acq_rel(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_sub_i64_unaligned_acq_rel:
+; -O0: subs x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i64_unaligned_acq_rel:
+; -O1: sub x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i64 %value acq_rel, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_sub_i64_unaligned_seq_cst(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_sub_i64_unaligned_seq_cst:
+; -O0: subs x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i64_unaligned_seq_cst:
+; -O1: sub x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i64 %value seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_sub_i128_unaligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_sub_i128_unaligned_monotonic:
+; -O0: subs x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i128_unaligned_monotonic:
+; -O1: ldp x0, x1, [x0]
+; -O1: subs x8, x1, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i128 %value monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_sub_i128_unaligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_sub_i128_unaligned_acquire:
+; -O0: subs x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i128_unaligned_acquire:
+; -O1: ldp x0, x1, [x0]
+; -O1: subs x8, x1, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i128 %value acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_sub_i128_unaligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_sub_i128_unaligned_release:
+; -O0: subs x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i128_unaligned_release:
+; -O1: ldp x0, x1, [x0]
+; -O1: subs x8, x1, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i128 %value release, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_sub_i128_unaligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_sub_i128_unaligned_acq_rel:
+; -O0: subs x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i128_unaligned_acq_rel:
+; -O1: ldp x0, x1, [x0]
+; -O1: subs x8, x1, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i128 %value acq_rel, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_sub_i128_unaligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_sub_i128_unaligned_seq_cst:
+; -O0: subs x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_sub_i128_unaligned_seq_cst:
+; -O1: ldp x0, x1, [x0]
+; -O1: subs x8, x1, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw sub ptr %ptr, i128 %value seq_cst, align 1
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_and_i8_aligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_and_i8_aligned_monotonic:
+; CHECK: mvn w8, w1
+; CHECK: ldclrb w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_and_i8_aligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_and_i8_aligned_acquire:
+; CHECK: mvn w8, w1
+; CHECK: ldclrab w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_and_i8_aligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_and_i8_aligned_release:
+; CHECK: mvn w8, w1
+; CHECK: ldclrlb w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_and_i8_aligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_and_i8_aligned_acq_rel:
+; CHECK: mvn w8, w1
+; CHECK: ldclralb w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_and_i8_aligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_and_i8_aligned_seq_cst:
+; CHECK: mvn w8, w1
+; CHECK: ldclralb w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_and_i16_aligned_monotonic(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_and_i16_aligned_monotonic:
+; CHECK: mvn w8, w1
+; CHECK: ldclrh w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i16 %value monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_and_i16_aligned_acquire(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_and_i16_aligned_acquire:
+; CHECK: mvn w8, w1
+; CHECK: ldclrah w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i16 %value acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_and_i16_aligned_release(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_and_i16_aligned_release:
+; CHECK: mvn w8, w1
+; CHECK: ldclrlh w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i16 %value release, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_and_i16_aligned_acq_rel(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_and_i16_aligned_acq_rel:
+; CHECK: mvn w8, w1
+; CHECK: ldclralh w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i16 %value acq_rel, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_and_i16_aligned_seq_cst(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_and_i16_aligned_seq_cst:
+; CHECK: mvn w8, w1
+; CHECK: ldclralh w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i16 %value seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_and_i32_aligned_monotonic(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_and_i32_aligned_monotonic:
+; CHECK: mvn w8, w1
+; CHECK: ldclr w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i32 %value monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_and_i32_aligned_acquire(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_and_i32_aligned_acquire:
+; CHECK: mvn w8, w1
+; CHECK: ldclra w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i32 %value acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_and_i32_aligned_release(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_and_i32_aligned_release:
+; CHECK: mvn w8, w1
+; CHECK: ldclrl w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i32 %value release, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_and_i32_aligned_acq_rel(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_and_i32_aligned_acq_rel:
+; CHECK: mvn w8, w1
+; CHECK: ldclral w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i32 %value acq_rel, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_and_i32_aligned_seq_cst(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_and_i32_aligned_seq_cst:
+; CHECK: mvn w8, w1
+; CHECK: ldclral w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i32 %value seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_and_i64_aligned_monotonic(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_and_i64_aligned_monotonic:
+; CHECK: mvn x8, x1
+; CHECK: ldclr x8, x0, [x0]
+ %r = atomicrmw and ptr %ptr, i64 %value monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_and_i64_aligned_acquire(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_and_i64_aligned_acquire:
+; CHECK: mvn x8, x1
+; CHECK: ldclra x8, x0, [x0]
+ %r = atomicrmw and ptr %ptr, i64 %value acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_and_i64_aligned_release(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_and_i64_aligned_release:
+; CHECK: mvn x8, x1
+; CHECK: ldclrl x8, x0, [x0]
+ %r = atomicrmw and ptr %ptr, i64 %value release, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_and_i64_aligned_acq_rel(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_and_i64_aligned_acq_rel:
+; CHECK: mvn x8, x1
+; CHECK: ldclral x8, x0, [x0]
+ %r = atomicrmw and ptr %ptr, i64 %value acq_rel, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_and_i64_aligned_seq_cst(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_and_i64_aligned_seq_cst:
+; CHECK: mvn x8, x1
+; CHECK: ldclral x8, x0, [x0]
+ %r = atomicrmw and ptr %ptr, i64 %value seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_and_i128_aligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_and_i128_aligned_monotonic:
+; -O0: mvn x1, x3
+; -O0: mvn x0, x2
+; -O0: ldclrp x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_and_i128_aligned_monotonic:
+; -O1: mvn x1, x3
+; -O1: mvn x8, x2
+; -O1: ldclrp x8, x1, [x0]
+ %r = atomicrmw and ptr %ptr, i128 %value monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_and_i128_aligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_and_i128_aligned_acquire:
+; -O0: mvn x1, x3
+; -O0: mvn x0, x2
+; -O0: ldclrpa x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_and_i128_aligned_acquire:
+; -O1: mvn x1, x3
+; -O1: mvn x8, x2
+; -O1: ldclrpa x8, x1, [x0]
+ %r = atomicrmw and ptr %ptr, i128 %value acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_and_i128_aligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_and_i128_aligned_release:
+; -O0: mvn x1, x3
+; -O0: mvn x0, x2
+; -O0: ldclrpl x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_and_i128_aligned_release:
+; -O1: mvn x1, x3
+; -O1: mvn x8, x2
+; -O1: ldclrpl x8, x1, [x0]
+ %r = atomicrmw and ptr %ptr, i128 %value release, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_and_i128_aligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_and_i128_aligned_acq_rel:
+; -O0: mvn x1, x3
+; -O0: mvn x0, x2
+; -O0: ldclrpal x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_and_i128_aligned_acq_rel:
+; -O1: mvn x1, x3
+; -O1: mvn x8, x2
+; -O1: ldclrpal x8, x1, [x0]
+ %r = atomicrmw and ptr %ptr, i128 %value acq_rel, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_and_i128_aligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_and_i128_aligned_seq_cst:
+; -O0: mvn x1, x3
+; -O0: mvn x0, x2
+; -O0: ldclrpal x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_and_i128_aligned_seq_cst:
+; -O1: mvn x1, x3
+; -O1: mvn x8, x2
+; -O1: ldclrpal x8, x1, [x0]
+ %r = atomicrmw and ptr %ptr, i128 %value seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_and_i8_unaligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_and_i8_unaligned_monotonic:
+; CHECK: mvn w8, w1
+; CHECK: ldclrb w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_and_i8_unaligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_and_i8_unaligned_acquire:
+; CHECK: mvn w8, w1
+; CHECK: ldclrab w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_and_i8_unaligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_and_i8_unaligned_release:
+; CHECK: mvn w8, w1
+; CHECK: ldclrlb w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_and_i8_unaligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_and_i8_unaligned_acq_rel:
+; CHECK: mvn w8, w1
+; CHECK: ldclralb w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_and_i8_unaligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_and_i8_unaligned_seq_cst:
+; CHECK: mvn w8, w1
+; CHECK: ldclralb w8, w0, [x0]
+ %r = atomicrmw and ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_and_i16_unaligned_monotonic(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_and_i16_unaligned_monotonic:
+; -O0: and w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i16_unaligned_monotonic:
+; -O1: and w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i16 %value monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_and_i16_unaligned_acquire(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_and_i16_unaligned_acquire:
+; -O0: and w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i16_unaligned_acquire:
+; -O1: and w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i16 %value acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_and_i16_unaligned_release(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_and_i16_unaligned_release:
+; -O0: and w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i16_unaligned_release:
+; -O1: and w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i16 %value release, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_and_i16_unaligned_acq_rel(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_and_i16_unaligned_acq_rel:
+; -O0: and w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i16_unaligned_acq_rel:
+; -O1: and w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i16 %value acq_rel, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_and_i16_unaligned_seq_cst(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_and_i16_unaligned_seq_cst:
+; -O0: and w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i16_unaligned_seq_cst:
+; -O1: and w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i16 %value seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_and_i32_unaligned_monotonic(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_and_i32_unaligned_monotonic:
+; -O0: and w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i32_unaligned_monotonic:
+; -O1: and w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i32 %value monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_and_i32_unaligned_acquire(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_and_i32_unaligned_acquire:
+; -O0: and w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i32_unaligned_acquire:
+; -O1: and w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i32 %value acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_and_i32_unaligned_release(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_and_i32_unaligned_release:
+; -O0: and w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i32_unaligned_release:
+; -O1: and w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i32 %value release, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_and_i32_unaligned_acq_rel(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_and_i32_unaligned_acq_rel:
+; -O0: and w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i32_unaligned_acq_rel:
+; -O1: and w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i32 %value acq_rel, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_and_i32_unaligned_seq_cst(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_and_i32_unaligned_seq_cst:
+; -O0: and w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i32_unaligned_seq_cst:
+; -O1: and w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i32 %value seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_and_i64_unaligned_monotonic(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_and_i64_unaligned_monotonic:
+; -O0: and x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i64_unaligned_monotonic:
+; -O1: and x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i64 %value monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_and_i64_unaligned_acquire(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_and_i64_unaligned_acquire:
+; -O0: and x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i64_unaligned_acquire:
+; -O1: and x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i64 %value acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_and_i64_unaligned_release(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_and_i64_unaligned_release:
+; -O0: and x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i64_unaligned_release:
+; -O1: and x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i64 %value release, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_and_i64_unaligned_acq_rel(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_and_i64_unaligned_acq_rel:
+; -O0: and x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i64_unaligned_acq_rel:
+; -O1: and x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i64 %value acq_rel, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_and_i64_unaligned_seq_cst(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_and_i64_unaligned_seq_cst:
+; -O0: and x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i64_unaligned_seq_cst:
+; -O1: and x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i64 %value seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_and_i128_unaligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_and_i128_unaligned_monotonic:
+; -O0: and x8, x11, x8
+; -O0: and x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i128_unaligned_monotonic:
+; -O1: ldp x0, x1, [x0]
+; -O1: and x8, x1, x19
+; -O1: and x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i128 %value monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_and_i128_unaligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_and_i128_unaligned_acquire:
+; -O0: and x8, x11, x8
+; -O0: and x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i128_unaligned_acquire:
+; -O1: ldp x0, x1, [x0]
+; -O1: and x8, x1, x19
+; -O1: and x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i128 %value acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_and_i128_unaligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_and_i128_unaligned_release:
+; -O0: and x8, x11, x8
+; -O0: and x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i128_unaligned_release:
+; -O1: ldp x0, x1, [x0]
+; -O1: and x8, x1, x19
+; -O1: and x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i128 %value release, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_and_i128_unaligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_and_i128_unaligned_acq_rel:
+; -O0: and x8, x11, x8
+; -O0: and x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i128_unaligned_acq_rel:
+; -O1: ldp x0, x1, [x0]
+; -O1: and x8, x1, x19
+; -O1: and x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i128 %value acq_rel, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_and_i128_unaligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_and_i128_unaligned_seq_cst:
+; -O0: and x8, x11, x8
+; -O0: and x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_and_i128_unaligned_seq_cst:
+; -O1: ldp x0, x1, [x0]
+; -O1: and x8, x1, x19
+; -O1: and x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw and ptr %ptr, i128 %value seq_cst, align 1
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_nand_i8_aligned_monotonic(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_nand_i8_aligned_monotonic:
+; -O0: and w8, w9, w8
+; -O0: mvn w10, w8
+; -O0: casb w8, w10, [x11]
+; -O0: subs w9, w8, w9, uxtb
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i8_aligned_monotonic:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casb w9, w10, [x0]
+; -O1: cmp w9, w8, uxtb
+ %r = atomicrmw nand ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_nand_i8_aligned_acquire(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_nand_i8_aligned_acquire:
+; -O0: and w8, w9, w8
+; -O0: mvn w10, w8
+; -O0: casab w8, w10, [x11]
+; -O0: subs w9, w8, w9, uxtb
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i8_aligned_acquire:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casab w9, w10, [x0]
+; -O1: cmp w9, w8, uxtb
+ %r = atomicrmw nand ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_nand_i8_aligned_release(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_nand_i8_aligned_release:
+; -O0: and w8, w9, w8
+; -O0: mvn w10, w8
+; -O0: caslb w8, w10, [x11]
+; -O0: subs w9, w8, w9, uxtb
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i8_aligned_release:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: caslb w9, w10, [x0]
+; -O1: cmp w9, w8, uxtb
+ %r = atomicrmw nand ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_nand_i8_aligned_acq_rel(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_nand_i8_aligned_acq_rel:
+; -O0: and w8, w9, w8
+; -O0: mvn w10, w8
+; -O0: casalb w8, w10, [x11]
+; -O0: subs w9, w8, w9, uxtb
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i8_aligned_acq_rel:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casalb w9, w10, [x0]
+; -O1: cmp w9, w8, uxtb
+ %r = atomicrmw nand ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_nand_i8_aligned_seq_cst(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_nand_i8_aligned_seq_cst:
+; -O0: and w8, w9, w8
+; -O0: mvn w10, w8
+; -O0: casalb w8, w10, [x11]
+; -O0: subs w9, w8, w9, uxtb
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i8_aligned_seq_cst:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casalb w9, w10, [x0]
+; -O1: cmp w9, w8, uxtb
+ %r = atomicrmw nand ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_nand_i16_aligned_monotonic(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_nand_i16_aligned_monotonic:
+; -O0: and w8, w9, w8
+; -O0: mvn w10, w8
+; -O0: cash w8, w10, [x11]
+; -O0: subs w9, w8, w9, uxth
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i16_aligned_monotonic:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: cash w9, w10, [x0]
+; -O1: cmp w9, w8, uxth
+ %r = atomicrmw nand ptr %ptr, i16 %value monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_nand_i16_aligned_acquire(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_nand_i16_aligned_acquire:
+; -O0: and w8, w9, w8
+; -O0: mvn w10, w8
+; -O0: casah w8, w10, [x11]
+; -O0: subs w9, w8, w9, uxth
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i16_aligned_acquire:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casah w9, w10, [x0]
+; -O1: cmp w9, w8, uxth
+ %r = atomicrmw nand ptr %ptr, i16 %value acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_nand_i16_aligned_release(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_nand_i16_aligned_release:
+; -O0: and w8, w9, w8
+; -O0: mvn w10, w8
+; -O0: caslh w8, w10, [x11]
+; -O0: subs w9, w8, w9, uxth
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i16_aligned_release:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: caslh w9, w10, [x0]
+; -O1: cmp w9, w8, uxth
+ %r = atomicrmw nand ptr %ptr, i16 %value release, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_nand_i16_aligned_acq_rel(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_nand_i16_aligned_acq_rel:
+; -O0: and w8, w9, w8
+; -O0: mvn w10, w8
+; -O0: casalh w8, w10, [x11]
+; -O0: subs w9, w8, w9, uxth
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i16_aligned_acq_rel:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casalh w9, w10, [x0]
+; -O1: cmp w9, w8, uxth
+ %r = atomicrmw nand ptr %ptr, i16 %value acq_rel, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_nand_i16_aligned_seq_cst(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_nand_i16_aligned_seq_cst:
+; -O0: and w8, w9, w8
+; -O0: mvn w10, w8
+; -O0: casalh w8, w10, [x11]
+; -O0: subs w9, w8, w9, uxth
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i16_aligned_seq_cst:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casalh w9, w10, [x0]
+; -O1: cmp w9, w8, uxth
+ %r = atomicrmw nand ptr %ptr, i16 %value seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_nand_i32_aligned_monotonic(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_nand_i32_aligned_monotonic:
+; -O0: and w8, w9, w8
+; -O0: mvn w10, w8
+; -O0: cas w8, w10, [x11]
+; -O0: subs w9, w8, w9
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i32_aligned_monotonic:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: cas w9, w10, [x0]
+; -O1: cmp w9, w8
+ %r = atomicrmw nand ptr %ptr, i32 %value monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_nand_i32_aligned_acquire(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_nand_i32_aligned_acquire:
+; -O0: and w8, w9, w8
+; -O0: mvn w10, w8
+; -O0: casa w8, w10, [x11]
+; -O0: subs w9, w8, w9
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i32_aligned_acquire:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casa w9, w10, [x0]
+; -O1: cmp w9, w8
+ %r = atomicrmw nand ptr %ptr, i32 %value acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_nand_i32_aligned_release(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_nand_i32_aligned_release:
+; -O0: and w8, w9, w8
+; -O0: mvn w10, w8
+; -O0: casl w8, w10, [x11]
+; -O0: subs w9, w8, w9
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i32_aligned_release:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casl w9, w10, [x0]
+; -O1: cmp w9, w8
+ %r = atomicrmw nand ptr %ptr, i32 %value release, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_nand_i32_aligned_acq_rel(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_nand_i32_aligned_acq_rel:
+; -O0: and w8, w9, w8
+; -O0: mvn w10, w8
+; -O0: casal w8, w10, [x11]
+; -O0: subs w9, w8, w9
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i32_aligned_acq_rel:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casal w9, w10, [x0]
+; -O1: cmp w9, w8
+ %r = atomicrmw nand ptr %ptr, i32 %value acq_rel, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_nand_i32_aligned_seq_cst(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_nand_i32_aligned_seq_cst:
+; -O0: and w8, w9, w8
+; -O0: mvn w10, w8
+; -O0: casal w8, w10, [x11]
+; -O0: subs w9, w8, w9
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i32_aligned_seq_cst:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casal w9, w10, [x0]
+; -O1: cmp w9, w8
+ %r = atomicrmw nand ptr %ptr, i32 %value seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_nand_i64_aligned_monotonic(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_nand_i64_aligned_monotonic:
+; -O0: and x8, x9, x8
+; -O0: mvn x10, x8
+; -O0: cas x8, x10, [x11]
+; -O0: subs x9, x8, x9
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i64_aligned_monotonic:
+; -O1: and x10, x8, x1
+; -O1: mvn x10, x10
+; -O1: cas x9, x10, [x0]
+; -O1: cmp x9, x8
+ %r = atomicrmw nand ptr %ptr, i64 %value monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_nand_i64_aligned_acquire(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_nand_i64_aligned_acquire:
+; -O0: and x8, x9, x8
+; -O0: mvn x10, x8
+; -O0: casa x8, x10, [x11]
+; -O0: subs x9, x8, x9
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i64_aligned_acquire:
+; -O1: and x10, x8, x1
+; -O1: mvn x10, x10
+; -O1: casa x9, x10, [x0]
+; -O1: cmp x9, x8
+ %r = atomicrmw nand ptr %ptr, i64 %value acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_nand_i64_aligned_release(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_nand_i64_aligned_release:
+; -O0: and x8, x9, x8
+; -O0: mvn x10, x8
+; -O0: casl x8, x10, [x11]
+; -O0: subs x9, x8, x9
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i64_aligned_release:
+; -O1: and x10, x8, x1
+; -O1: mvn x10, x10
+; -O1: casl x9, x10, [x0]
+; -O1: cmp x9, x8
+ %r = atomicrmw nand ptr %ptr, i64 %value release, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_nand_i64_aligned_acq_rel(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_nand_i64_aligned_acq_rel:
+; -O0: and x8, x9, x8
+; -O0: mvn x10, x8
+; -O0: casal x8, x10, [x11]
+; -O0: subs x9, x8, x9
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i64_aligned_acq_rel:
+; -O1: and x10, x8, x1
+; -O1: mvn x10, x10
+; -O1: casal x9, x10, [x0]
+; -O1: cmp x9, x8
+ %r = atomicrmw nand ptr %ptr, i64 %value acq_rel, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_nand_i64_aligned_seq_cst(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_nand_i64_aligned_seq_cst:
+; -O0: and x8, x9, x8
+; -O0: mvn x10, x8
+; -O0: casal x8, x10, [x11]
+; -O0: subs x9, x8, x9
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i64_aligned_seq_cst:
+; -O1: and x10, x8, x1
+; -O1: mvn x10, x10
+; -O1: casal x9, x10, [x0]
+; -O1: cmp x9, x8
+ %r = atomicrmw nand ptr %ptr, i64 %value seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_nand_i128_aligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_nand_i128_aligned_monotonic:
+; -O0: and x9, x10, x9
+; -O0: and x12, x11, x12
+; -O0: mvn x2, x12
+; -O0: mvn x9, x9
+; -O0: casp x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_nand_i128_aligned_monotonic:
+; -O1: ldp x4, x5, [x0]
+; -O1: and x8, x4, x2
+; -O1: and x9, x7, x3
+; -O1: mvn x10, x8
+; -O1: mvn x11, x9
+; -O1: casp x4, x5, x10, x11, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw nand ptr %ptr, i128 %value monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_nand_i128_aligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_nand_i128_aligned_acquire:
+; -O0: and x9, x10, x9
+; -O0: and x12, x11, x12
+; -O0: mvn x2, x12
+; -O0: mvn x9, x9
+; -O0: caspa x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_nand_i128_aligned_acquire:
+; -O1: ldp x4, x5, [x0]
+; -O1: and x8, x4, x2
+; -O1: and x9, x7, x3
+; -O1: mvn x10, x8
+; -O1: mvn x11, x9
+; -O1: caspa x4, x5, x10, x11, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw nand ptr %ptr, i128 %value acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_nand_i128_aligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_nand_i128_aligned_release:
+; -O0: and x9, x10, x9
+; -O0: and x12, x11, x12
+; -O0: mvn x2, x12
+; -O0: mvn x9, x9
+; -O0: caspl x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_nand_i128_aligned_release:
+; -O1: ldp x4, x5, [x0]
+; -O1: and x8, x4, x2
+; -O1: and x9, x7, x3
+; -O1: mvn x10, x8
+; -O1: mvn x11, x9
+; -O1: caspl x4, x5, x10, x11, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw nand ptr %ptr, i128 %value release, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_nand_i128_aligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_nand_i128_aligned_acq_rel:
+; -O0: and x9, x10, x9
+; -O0: and x12, x11, x12
+; -O0: mvn x2, x12
+; -O0: mvn x9, x9
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_nand_i128_aligned_acq_rel:
+; -O1: ldp x4, x5, [x0]
+; -O1: and x8, x4, x2
+; -O1: and x9, x7, x3
+; -O1: mvn x10, x8
+; -O1: mvn x11, x9
+; -O1: caspal x4, x5, x10, x11, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw nand ptr %ptr, i128 %value acq_rel, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_nand_i128_aligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_nand_i128_aligned_seq_cst:
+; -O0: and x9, x10, x9
+; -O0: and x12, x11, x12
+; -O0: mvn x2, x12
+; -O0: mvn x9, x9
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_nand_i128_aligned_seq_cst:
+; -O1: ldp x4, x5, [x0]
+; -O1: and x8, x4, x2
+; -O1: and x9, x7, x3
+; -O1: mvn x10, x8
+; -O1: mvn x11, x9
+; -O1: caspal x4, x5, x10, x11, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw nand ptr %ptr, i128 %value seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_nand_i8_unaligned_monotonic(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_nand_i8_unaligned_monotonic:
+; -O0: and w8, w9, w8
+; -O0: mvn w10, w8
+; -O0: casb w8, w10, [x11]
+; -O0: subs w9, w8, w9, uxtb
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i8_unaligned_monotonic:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casb w9, w10, [x0]
+; -O1: cmp w9, w8, uxtb
+ %r = atomicrmw nand ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_nand_i8_unaligned_acquire(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_nand_i8_unaligned_acquire:
+; -O0: and w8, w9, w8
+; -O0: mvn w10, w8
+; -O0: casab w8, w10, [x11]
+; -O0: subs w9, w8, w9, uxtb
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i8_unaligned_acquire:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casab w9, w10, [x0]
+; -O1: cmp w9, w8, uxtb
+ %r = atomicrmw nand ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_nand_i8_unaligned_release(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_nand_i8_unaligned_release:
+; -O0: and w8, w9, w8
+; -O0: mvn w10, w8
+; -O0: caslb w8, w10, [x11]
+; -O0: subs w9, w8, w9, uxtb
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i8_unaligned_release:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: caslb w9, w10, [x0]
+; -O1: cmp w9, w8, uxtb
+ %r = atomicrmw nand ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_nand_i8_unaligned_acq_rel(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_nand_i8_unaligned_acq_rel:
+; -O0: and w8, w9, w8
+; -O0: mvn w10, w8
+; -O0: casalb w8, w10, [x11]
+; -O0: subs w9, w8, w9, uxtb
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i8_unaligned_acq_rel:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casalb w9, w10, [x0]
+; -O1: cmp w9, w8, uxtb
+ %r = atomicrmw nand ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_nand_i8_unaligned_seq_cst(ptr %ptr, i8 %value) {
+; -O0-LABEL: atomicrmw_nand_i8_unaligned_seq_cst:
+; -O0: and w8, w9, w8
+; -O0: mvn w10, w8
+; -O0: casalb w8, w10, [x11]
+; -O0: subs w9, w8, w9, uxtb
+; -O0: subs w9, w9, #1
+;
+; -O1-LABEL: atomicrmw_nand_i8_unaligned_seq_cst:
+; -O1: and w10, w8, w1
+; -O1: mvn w10, w10
+; -O1: casalb w9, w10, [x0]
+; -O1: cmp w9, w8, uxtb
+ %r = atomicrmw nand ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_nand_i16_unaligned_monotonic(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_nand_i16_unaligned_monotonic:
+; -O0: and w8, w9, w8
+; -O0: mvn w8, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i16_unaligned_monotonic:
+; -O1: and w8, w0, w19
+; -O1: mvn w8, w8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i16 %value monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_nand_i16_unaligned_acquire(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_nand_i16_unaligned_acquire:
+; -O0: and w8, w9, w8
+; -O0: mvn w8, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i16_unaligned_acquire:
+; -O1: and w8, w0, w19
+; -O1: mvn w8, w8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i16 %value acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_nand_i16_unaligned_release(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_nand_i16_unaligned_release:
+; -O0: and w8, w9, w8
+; -O0: mvn w8, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i16_unaligned_release:
+; -O1: and w8, w0, w19
+; -O1: mvn w8, w8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i16 %value release, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_nand_i16_unaligned_acq_rel(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_nand_i16_unaligned_acq_rel:
+; -O0: and w8, w9, w8
+; -O0: mvn w8, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i16_unaligned_acq_rel:
+; -O1: and w8, w0, w19
+; -O1: mvn w8, w8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i16 %value acq_rel, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_nand_i16_unaligned_seq_cst(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_nand_i16_unaligned_seq_cst:
+; -O0: and w8, w9, w8
+; -O0: mvn w8, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i16_unaligned_seq_cst:
+; -O1: and w8, w0, w19
+; -O1: mvn w8, w8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i16 %value seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_nand_i32_unaligned_monotonic(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_nand_i32_unaligned_monotonic:
+; -O0: and w8, w9, w8
+; -O0: mvn w8, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i32_unaligned_monotonic:
+; -O1: and w8, w0, w19
+; -O1: mvn w8, w8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i32 %value monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_nand_i32_unaligned_acquire(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_nand_i32_unaligned_acquire:
+; -O0: and w8, w9, w8
+; -O0: mvn w8, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i32_unaligned_acquire:
+; -O1: and w8, w0, w19
+; -O1: mvn w8, w8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i32 %value acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_nand_i32_unaligned_release(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_nand_i32_unaligned_release:
+; -O0: and w8, w9, w8
+; -O0: mvn w8, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i32_unaligned_release:
+; -O1: and w8, w0, w19
+; -O1: mvn w8, w8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i32 %value release, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_nand_i32_unaligned_acq_rel(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_nand_i32_unaligned_acq_rel:
+; -O0: and w8, w9, w8
+; -O0: mvn w8, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i32_unaligned_acq_rel:
+; -O1: and w8, w0, w19
+; -O1: mvn w8, w8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i32 %value acq_rel, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_nand_i32_unaligned_seq_cst(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_nand_i32_unaligned_seq_cst:
+; -O0: and w8, w9, w8
+; -O0: mvn w8, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i32_unaligned_seq_cst:
+; -O1: and w8, w0, w19
+; -O1: mvn w8, w8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i32 %value seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_nand_i64_unaligned_monotonic(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_nand_i64_unaligned_monotonic:
+; -O0: and x8, x9, x8
+; -O0: mvn x8, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i64_unaligned_monotonic:
+; -O1: and x8, x0, x19
+; -O1: mvn x8, x8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i64 %value monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_nand_i64_unaligned_acquire(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_nand_i64_unaligned_acquire:
+; -O0: and x8, x9, x8
+; -O0: mvn x8, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i64_unaligned_acquire:
+; -O1: and x8, x0, x19
+; -O1: mvn x8, x8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i64 %value acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_nand_i64_unaligned_release(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_nand_i64_unaligned_release:
+; -O0: and x8, x9, x8
+; -O0: mvn x8, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i64_unaligned_release:
+; -O1: and x8, x0, x19
+; -O1: mvn x8, x8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i64 %value release, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_nand_i64_unaligned_acq_rel(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_nand_i64_unaligned_acq_rel:
+; -O0: and x8, x9, x8
+; -O0: mvn x8, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i64_unaligned_acq_rel:
+; -O1: and x8, x0, x19
+; -O1: mvn x8, x8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i64 %value acq_rel, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_nand_i64_unaligned_seq_cst(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_nand_i64_unaligned_seq_cst:
+; -O0: and x8, x9, x8
+; -O0: mvn x8, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i64_unaligned_seq_cst:
+; -O1: and x8, x0, x19
+; -O1: mvn x8, x8
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i64 %value seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_nand_i128_unaligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_nand_i128_unaligned_monotonic:
+; -O0: and x9, x11, x9
+; -O0: and x8, x10, x8
+; -O0: mvn x8, x8
+; -O0: mvn x9, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i128_unaligned_monotonic:
+; -O1: ldp x0, x1, [x0]
+; -O1: and x8, x1, x19
+; -O1: and x9, x0, x20
+; -O1: mvn x8, x8
+; -O1: mvn x9, x9
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i128 %value monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_nand_i128_unaligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_nand_i128_unaligned_acquire:
+; -O0: and x9, x11, x9
+; -O0: and x8, x10, x8
+; -O0: mvn x8, x8
+; -O0: mvn x9, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i128_unaligned_acquire:
+; -O1: ldp x0, x1, [x0]
+; -O1: and x8, x1, x19
+; -O1: and x9, x0, x20
+; -O1: mvn x8, x8
+; -O1: mvn x9, x9
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i128 %value acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_nand_i128_unaligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_nand_i128_unaligned_release:
+; -O0: and x9, x11, x9
+; -O0: and x8, x10, x8
+; -O0: mvn x8, x8
+; -O0: mvn x9, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i128_unaligned_release:
+; -O1: ldp x0, x1, [x0]
+; -O1: and x8, x1, x19
+; -O1: and x9, x0, x20
+; -O1: mvn x8, x8
+; -O1: mvn x9, x9
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i128 %value release, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_nand_i128_unaligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_nand_i128_unaligned_acq_rel:
+; -O0: and x9, x11, x9
+; -O0: and x8, x10, x8
+; -O0: mvn x8, x8
+; -O0: mvn x9, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i128_unaligned_acq_rel:
+; -O1: ldp x0, x1, [x0]
+; -O1: and x8, x1, x19
+; -O1: and x9, x0, x20
+; -O1: mvn x8, x8
+; -O1: mvn x9, x9
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i128 %value acq_rel, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_nand_i128_unaligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_nand_i128_unaligned_seq_cst:
+; -O0: and x9, x11, x9
+; -O0: and x8, x10, x8
+; -O0: mvn x8, x8
+; -O0: mvn x9, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_nand_i128_unaligned_seq_cst:
+; -O1: ldp x0, x1, [x0]
+; -O1: and x8, x1, x19
+; -O1: and x9, x0, x20
+; -O1: mvn x8, x8
+; -O1: mvn x9, x9
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw nand ptr %ptr, i128 %value seq_cst, align 1
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_or_i8_aligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_or_i8_aligned_monotonic:
+; CHECK: ldsetb w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_or_i8_aligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_or_i8_aligned_acquire:
+; CHECK: ldsetab w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_or_i8_aligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_or_i8_aligned_release:
+; CHECK: ldsetlb w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_or_i8_aligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_or_i8_aligned_acq_rel:
+; CHECK: ldsetalb w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_or_i8_aligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_or_i8_aligned_seq_cst:
+; CHECK: ldsetalb w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_or_i16_aligned_monotonic(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_or_i16_aligned_monotonic:
+; CHECK: ldseth w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i16 %value monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_or_i16_aligned_acquire(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_or_i16_aligned_acquire:
+; CHECK: ldsetah w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i16 %value acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_or_i16_aligned_release(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_or_i16_aligned_release:
+; CHECK: ldsetlh w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i16 %value release, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_or_i16_aligned_acq_rel(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_or_i16_aligned_acq_rel:
+; CHECK: ldsetalh w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i16 %value acq_rel, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_or_i16_aligned_seq_cst(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_or_i16_aligned_seq_cst:
+; CHECK: ldsetalh w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i16 %value seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_or_i32_aligned_monotonic(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_or_i32_aligned_monotonic:
+; CHECK: ldset w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i32 %value monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_or_i32_aligned_acquire(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_or_i32_aligned_acquire:
+; CHECK: ldseta w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i32 %value acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_or_i32_aligned_release(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_or_i32_aligned_release:
+; CHECK: ldsetl w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i32 %value release, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_or_i32_aligned_acq_rel(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_or_i32_aligned_acq_rel:
+; CHECK: ldsetal w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i32 %value acq_rel, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_or_i32_aligned_seq_cst(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_or_i32_aligned_seq_cst:
+; CHECK: ldsetal w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i32 %value seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_or_i64_aligned_monotonic(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_or_i64_aligned_monotonic:
+; CHECK: ldset x1, x0, [x0]
+ %r = atomicrmw or ptr %ptr, i64 %value monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_or_i64_aligned_acquire(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_or_i64_aligned_acquire:
+; CHECK: ldseta x1, x0, [x0]
+ %r = atomicrmw or ptr %ptr, i64 %value acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_or_i64_aligned_release(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_or_i64_aligned_release:
+; CHECK: ldsetl x1, x0, [x0]
+ %r = atomicrmw or ptr %ptr, i64 %value release, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_or_i64_aligned_acq_rel(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_or_i64_aligned_acq_rel:
+; CHECK: ldsetal x1, x0, [x0]
+ %r = atomicrmw or ptr %ptr, i64 %value acq_rel, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_or_i64_aligned_seq_cst(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_or_i64_aligned_seq_cst:
+; CHECK: ldsetal x1, x0, [x0]
+ %r = atomicrmw or ptr %ptr, i64 %value seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_or_i128_aligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_or_i128_aligned_monotonic:
+; -O0: ldsetp x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_or_i128_aligned_monotonic:
+; -O1: ldsetp x2, x1, [x0]
+ %r = atomicrmw or ptr %ptr, i128 %value monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_or_i128_aligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_or_i128_aligned_acquire:
+; -O0: ldsetpa x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_or_i128_aligned_acquire:
+; -O1: ldsetpa x2, x1, [x0]
+ %r = atomicrmw or ptr %ptr, i128 %value acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_or_i128_aligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_or_i128_aligned_release:
+; -O0: ldsetpl x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_or_i128_aligned_release:
+; -O1: ldsetpl x2, x1, [x0]
+ %r = atomicrmw or ptr %ptr, i128 %value release, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_or_i128_aligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_or_i128_aligned_acq_rel:
+; -O0: ldsetpal x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_or_i128_aligned_acq_rel:
+; -O1: ldsetpal x2, x1, [x0]
+ %r = atomicrmw or ptr %ptr, i128 %value acq_rel, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_or_i128_aligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_or_i128_aligned_seq_cst:
+; -O0: ldsetpal x0, x1, [x8]
+;
+; -O1-LABEL: atomicrmw_or_i128_aligned_seq_cst:
+; -O1: ldsetpal x2, x1, [x0]
+ %r = atomicrmw or ptr %ptr, i128 %value seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_or_i8_unaligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_or_i8_unaligned_monotonic:
+; CHECK: ldsetb w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_or_i8_unaligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_or_i8_unaligned_acquire:
+; CHECK: ldsetab w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_or_i8_unaligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_or_i8_unaligned_release:
+; CHECK: ldsetlb w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_or_i8_unaligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_or_i8_unaligned_acq_rel:
+; CHECK: ldsetalb w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_or_i8_unaligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_or_i8_unaligned_seq_cst:
+; CHECK: ldsetalb w1, w0, [x0]
+ %r = atomicrmw or ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_or_i16_unaligned_monotonic(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_or_i16_unaligned_monotonic:
+; -O0: orr w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i16_unaligned_monotonic:
+; -O1: orr w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i16 %value monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_or_i16_unaligned_acquire(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_or_i16_unaligned_acquire:
+; -O0: orr w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i16_unaligned_acquire:
+; -O1: orr w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i16 %value acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_or_i16_unaligned_release(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_or_i16_unaligned_release:
+; -O0: orr w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i16_unaligned_release:
+; -O1: orr w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i16 %value release, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_or_i16_unaligned_acq_rel(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_or_i16_unaligned_acq_rel:
+; -O0: orr w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i16_unaligned_acq_rel:
+; -O1: orr w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i16 %value acq_rel, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_or_i16_unaligned_seq_cst(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_or_i16_unaligned_seq_cst:
+; -O0: orr w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i16_unaligned_seq_cst:
+; -O1: orr w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i16 %value seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_or_i32_unaligned_monotonic(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_or_i32_unaligned_monotonic:
+; -O0: orr w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i32_unaligned_monotonic:
+; -O1: orr w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i32 %value monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_or_i32_unaligned_acquire(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_or_i32_unaligned_acquire:
+; -O0: orr w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i32_unaligned_acquire:
+; -O1: orr w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i32 %value acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_or_i32_unaligned_release(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_or_i32_unaligned_release:
+; -O0: orr w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i32_unaligned_release:
+; -O1: orr w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i32 %value release, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_or_i32_unaligned_acq_rel(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_or_i32_unaligned_acq_rel:
+; -O0: orr w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i32_unaligned_acq_rel:
+; -O1: orr w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i32 %value acq_rel, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_or_i32_unaligned_seq_cst(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_or_i32_unaligned_seq_cst:
+; -O0: orr w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i32_unaligned_seq_cst:
+; -O1: orr w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i32 %value seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_or_i64_unaligned_monotonic(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_or_i64_unaligned_monotonic:
+; -O0: orr x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i64_unaligned_monotonic:
+; -O1: orr x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i64 %value monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_or_i64_unaligned_acquire(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_or_i64_unaligned_acquire:
+; -O0: orr x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i64_unaligned_acquire:
+; -O1: orr x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i64 %value acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_or_i64_unaligned_release(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_or_i64_unaligned_release:
+; -O0: orr x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i64_unaligned_release:
+; -O1: orr x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i64 %value release, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_or_i64_unaligned_acq_rel(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_or_i64_unaligned_acq_rel:
+; -O0: orr x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i64_unaligned_acq_rel:
+; -O1: orr x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i64 %value acq_rel, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_or_i64_unaligned_seq_cst(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_or_i64_unaligned_seq_cst:
+; -O0: orr x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i64_unaligned_seq_cst:
+; -O1: orr x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i64 %value seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_or_i128_unaligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_or_i128_unaligned_monotonic:
+; -O0: orr x8, x11, x8
+; -O0: orr x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i128_unaligned_monotonic:
+; -O1: ldp x0, x1, [x0]
+; -O1: orr x8, x1, x19
+; -O1: orr x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i128 %value monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_or_i128_unaligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_or_i128_unaligned_acquire:
+; -O0: orr x8, x11, x8
+; -O0: orr x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i128_unaligned_acquire:
+; -O1: ldp x0, x1, [x0]
+; -O1: orr x8, x1, x19
+; -O1: orr x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i128 %value acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_or_i128_unaligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_or_i128_unaligned_release:
+; -O0: orr x8, x11, x8
+; -O0: orr x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i128_unaligned_release:
+; -O1: ldp x0, x1, [x0]
+; -O1: orr x8, x1, x19
+; -O1: orr x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i128 %value release, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_or_i128_unaligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_or_i128_unaligned_acq_rel:
+; -O0: orr x8, x11, x8
+; -O0: orr x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i128_unaligned_acq_rel:
+; -O1: ldp x0, x1, [x0]
+; -O1: orr x8, x1, x19
+; -O1: orr x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i128 %value acq_rel, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_or_i128_unaligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_or_i128_unaligned_seq_cst:
+; -O0: orr x8, x11, x8
+; -O0: orr x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_or_i128_unaligned_seq_cst:
+; -O1: ldp x0, x1, [x0]
+; -O1: orr x8, x1, x19
+; -O1: orr x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw or ptr %ptr, i128 %value seq_cst, align 1
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_xor_i8_aligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xor_i8_aligned_monotonic:
+; CHECK: ldeorb w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xor_i8_aligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xor_i8_aligned_acquire:
+; CHECK: ldeorab w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xor_i8_aligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xor_i8_aligned_release:
+; CHECK: ldeorlb w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xor_i8_aligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xor_i8_aligned_acq_rel:
+; CHECK: ldeoralb w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xor_i8_aligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xor_i8_aligned_seq_cst:
+; CHECK: ldeoralb w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_xor_i16_aligned_monotonic(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xor_i16_aligned_monotonic:
+; CHECK: ldeorh w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i16 %value monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xor_i16_aligned_acquire(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xor_i16_aligned_acquire:
+; CHECK: ldeorah w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i16 %value acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xor_i16_aligned_release(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xor_i16_aligned_release:
+; CHECK: ldeorlh w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i16 %value release, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xor_i16_aligned_acq_rel(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xor_i16_aligned_acq_rel:
+; CHECK: ldeoralh w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i16 %value acq_rel, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xor_i16_aligned_seq_cst(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_xor_i16_aligned_seq_cst:
+; CHECK: ldeoralh w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i16 %value seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_xor_i32_aligned_monotonic(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xor_i32_aligned_monotonic:
+; CHECK: ldeor w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i32 %value monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xor_i32_aligned_acquire(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xor_i32_aligned_acquire:
+; CHECK: ldeora w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i32 %value acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xor_i32_aligned_release(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xor_i32_aligned_release:
+; CHECK: ldeorl w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i32 %value release, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xor_i32_aligned_acq_rel(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xor_i32_aligned_acq_rel:
+; CHECK: ldeoral w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i32 %value acq_rel, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xor_i32_aligned_seq_cst(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_xor_i32_aligned_seq_cst:
+; CHECK: ldeoral w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i32 %value seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_xor_i64_aligned_monotonic(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xor_i64_aligned_monotonic:
+; CHECK: ldeor x1, x0, [x0]
+ %r = atomicrmw xor ptr %ptr, i64 %value monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xor_i64_aligned_acquire(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xor_i64_aligned_acquire:
+; CHECK: ldeora x1, x0, [x0]
+ %r = atomicrmw xor ptr %ptr, i64 %value acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xor_i64_aligned_release(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xor_i64_aligned_release:
+; CHECK: ldeorl x1, x0, [x0]
+ %r = atomicrmw xor ptr %ptr, i64 %value release, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xor_i64_aligned_acq_rel(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xor_i64_aligned_acq_rel:
+; CHECK: ldeoral x1, x0, [x0]
+ %r = atomicrmw xor ptr %ptr, i64 %value acq_rel, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xor_i64_aligned_seq_cst(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_xor_i64_aligned_seq_cst:
+; CHECK: ldeoral x1, x0, [x0]
+ %r = atomicrmw xor ptr %ptr, i64 %value seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_xor_i128_aligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xor_i128_aligned_monotonic:
+; -O0: eor x2, x11, x12
+; -O0: eor x9, x10, x9
+; -O0: casp x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_xor_i128_aligned_monotonic:
+; -O1: ldp x4, x5, [x0]
+; -O1: eor x8, x4, x2
+; -O1: eor x9, x7, x3
+; -O1: casp x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw xor ptr %ptr, i128 %value monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xor_i128_aligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xor_i128_aligned_acquire:
+; -O0: eor x2, x11, x12
+; -O0: eor x9, x10, x9
+; -O0: caspa x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_xor_i128_aligned_acquire:
+; -O1: ldp x4, x5, [x0]
+; -O1: eor x8, x4, x2
+; -O1: eor x9, x7, x3
+; -O1: caspa x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw xor ptr %ptr, i128 %value acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xor_i128_aligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xor_i128_aligned_release:
+; -O0: eor x2, x11, x12
+; -O0: eor x9, x10, x9
+; -O0: caspl x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_xor_i128_aligned_release:
+; -O1: ldp x4, x5, [x0]
+; -O1: eor x8, x4, x2
+; -O1: eor x9, x7, x3
+; -O1: caspl x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw xor ptr %ptr, i128 %value release, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xor_i128_aligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xor_i128_aligned_acq_rel:
+; -O0: eor x2, x11, x12
+; -O0: eor x9, x10, x9
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_xor_i128_aligned_acq_rel:
+; -O1: ldp x4, x5, [x0]
+; -O1: eor x8, x4, x2
+; -O1: eor x9, x7, x3
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw xor ptr %ptr, i128 %value acq_rel, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xor_i128_aligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xor_i128_aligned_seq_cst:
+; -O0: eor x2, x11, x12
+; -O0: eor x9, x10, x9
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_xor_i128_aligned_seq_cst:
+; -O1: ldp x4, x5, [x0]
+; -O1: eor x8, x4, x2
+; -O1: eor x9, x7, x3
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw xor ptr %ptr, i128 %value seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_xor_i8_unaligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xor_i8_unaligned_monotonic:
+; CHECK: ldeorb w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xor_i8_unaligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xor_i8_unaligned_acquire:
+; CHECK: ldeorab w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xor_i8_unaligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xor_i8_unaligned_release:
+; CHECK: ldeorlb w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xor_i8_unaligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xor_i8_unaligned_acq_rel:
+; CHECK: ldeoralb w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_xor_i8_unaligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_xor_i8_unaligned_seq_cst:
+; CHECK: ldeoralb w1, w0, [x0]
+ %r = atomicrmw xor ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_xor_i16_unaligned_monotonic(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_xor_i16_unaligned_monotonic:
+; -O0: eor w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i16_unaligned_monotonic:
+; -O1: eor w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i16 %value monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xor_i16_unaligned_acquire(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_xor_i16_unaligned_acquire:
+; -O0: eor w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i16_unaligned_acquire:
+; -O1: eor w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i16 %value acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xor_i16_unaligned_release(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_xor_i16_unaligned_release:
+; -O0: eor w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i16_unaligned_release:
+; -O1: eor w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i16 %value release, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xor_i16_unaligned_acq_rel(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_xor_i16_unaligned_acq_rel:
+; -O0: eor w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i16_unaligned_acq_rel:
+; -O1: eor w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i16 %value acq_rel, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_xor_i16_unaligned_seq_cst(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_xor_i16_unaligned_seq_cst:
+; -O0: eor w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i16_unaligned_seq_cst:
+; -O1: eor w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i16 %value seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_xor_i32_unaligned_monotonic(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_xor_i32_unaligned_monotonic:
+; -O0: eor w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i32_unaligned_monotonic:
+; -O1: eor w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i32 %value monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xor_i32_unaligned_acquire(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_xor_i32_unaligned_acquire:
+; -O0: eor w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i32_unaligned_acquire:
+; -O1: eor w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i32 %value acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xor_i32_unaligned_release(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_xor_i32_unaligned_release:
+; -O0: eor w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i32_unaligned_release:
+; -O1: eor w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i32 %value release, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xor_i32_unaligned_acq_rel(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_xor_i32_unaligned_acq_rel:
+; -O0: eor w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i32_unaligned_acq_rel:
+; -O1: eor w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i32 %value acq_rel, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_xor_i32_unaligned_seq_cst(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_xor_i32_unaligned_seq_cst:
+; -O0: eor w8, w9, w8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i32_unaligned_seq_cst:
+; -O1: eor w8, w0, w19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i32 %value seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_xor_i64_unaligned_monotonic(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_xor_i64_unaligned_monotonic:
+; -O0: eor x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i64_unaligned_monotonic:
+; -O1: eor x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i64 %value monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xor_i64_unaligned_acquire(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_xor_i64_unaligned_acquire:
+; -O0: eor x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i64_unaligned_acquire:
+; -O1: eor x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i64 %value acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xor_i64_unaligned_release(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_xor_i64_unaligned_release:
+; -O0: eor x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i64_unaligned_release:
+; -O1: eor x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i64 %value release, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xor_i64_unaligned_acq_rel(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_xor_i64_unaligned_acq_rel:
+; -O0: eor x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i64_unaligned_acq_rel:
+; -O1: eor x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i64 %value acq_rel, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_xor_i64_unaligned_seq_cst(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_xor_i64_unaligned_seq_cst:
+; -O0: eor x8, x9, x8
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i64_unaligned_seq_cst:
+; -O1: eor x8, x0, x19
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i64 %value seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_xor_i128_unaligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xor_i128_unaligned_monotonic:
+; -O0: eor x8, x11, x8
+; -O0: eor x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i128_unaligned_monotonic:
+; -O1: ldp x0, x1, [x0]
+; -O1: eor x8, x1, x19
+; -O1: eor x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i128 %value monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xor_i128_unaligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xor_i128_unaligned_acquire:
+; -O0: eor x8, x11, x8
+; -O0: eor x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i128_unaligned_acquire:
+; -O1: ldp x0, x1, [x0]
+; -O1: eor x8, x1, x19
+; -O1: eor x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i128 %value acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xor_i128_unaligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xor_i128_unaligned_release:
+; -O0: eor x8, x11, x8
+; -O0: eor x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i128_unaligned_release:
+; -O1: ldp x0, x1, [x0]
+; -O1: eor x8, x1, x19
+; -O1: eor x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i128 %value release, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xor_i128_unaligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xor_i128_unaligned_acq_rel:
+; -O0: eor x8, x11, x8
+; -O0: eor x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i128_unaligned_acq_rel:
+; -O1: ldp x0, x1, [x0]
+; -O1: eor x8, x1, x19
+; -O1: eor x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i128 %value acq_rel, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_xor_i128_unaligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_xor_i128_unaligned_seq_cst:
+; -O0: eor x8, x11, x8
+; -O0: eor x9, x10, x9
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_xor_i128_unaligned_seq_cst:
+; -O1: ldp x0, x1, [x0]
+; -O1: eor x8, x1, x19
+; -O1: eor x9, x0, x20
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw xor ptr %ptr, i128 %value seq_cst, align 1
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_max_i8_aligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_max_i8_aligned_monotonic:
+; CHECK: ldsmaxb w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_max_i8_aligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_max_i8_aligned_acquire:
+; CHECK: ldsmaxab w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_max_i8_aligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_max_i8_aligned_release:
+; CHECK: ldsmaxlb w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_max_i8_aligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_max_i8_aligned_acq_rel:
+; CHECK: ldsmaxalb w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_max_i8_aligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_max_i8_aligned_seq_cst:
+; CHECK: ldsmaxalb w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_max_i16_aligned_monotonic(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_max_i16_aligned_monotonic:
+; CHECK: ldsmaxh w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i16 %value monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_max_i16_aligned_acquire(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_max_i16_aligned_acquire:
+; CHECK: ldsmaxah w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i16 %value acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_max_i16_aligned_release(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_max_i16_aligned_release:
+; CHECK: ldsmaxlh w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i16 %value release, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_max_i16_aligned_acq_rel(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_max_i16_aligned_acq_rel:
+; CHECK: ldsmaxalh w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i16 %value acq_rel, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_max_i16_aligned_seq_cst(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_max_i16_aligned_seq_cst:
+; CHECK: ldsmaxalh w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i16 %value seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_max_i32_aligned_monotonic(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_max_i32_aligned_monotonic:
+; CHECK: ldsmax w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i32 %value monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_max_i32_aligned_acquire(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_max_i32_aligned_acquire:
+; CHECK: ldsmaxa w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i32 %value acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_max_i32_aligned_release(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_max_i32_aligned_release:
+; CHECK: ldsmaxl w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i32 %value release, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_max_i32_aligned_acq_rel(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_max_i32_aligned_acq_rel:
+; CHECK: ldsmaxal w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i32 %value acq_rel, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_max_i32_aligned_seq_cst(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_max_i32_aligned_seq_cst:
+; CHECK: ldsmaxal w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i32 %value seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_max_i64_aligned_monotonic(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_max_i64_aligned_monotonic:
+; CHECK: ldsmax x1, x0, [x0]
+ %r = atomicrmw max ptr %ptr, i64 %value monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_max_i64_aligned_acquire(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_max_i64_aligned_acquire:
+; CHECK: ldsmaxa x1, x0, [x0]
+ %r = atomicrmw max ptr %ptr, i64 %value acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_max_i64_aligned_release(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_max_i64_aligned_release:
+; CHECK: ldsmaxl x1, x0, [x0]
+ %r = atomicrmw max ptr %ptr, i64 %value release, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_max_i64_aligned_acq_rel(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_max_i64_aligned_acq_rel:
+; CHECK: ldsmaxal x1, x0, [x0]
+ %r = atomicrmw max ptr %ptr, i64 %value acq_rel, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_max_i64_aligned_seq_cst(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_max_i64_aligned_seq_cst:
+; CHECK: ldsmaxal x1, x0, [x0]
+ %r = atomicrmw max ptr %ptr, i64 %value seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_max_i128_aligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_max_i128_aligned_monotonic:
+; -O0: subs x13, x9, x10
+; -O0: csel x9, x10, x9, lt
+; -O0: csel x2, x11, x12, lt
+; -O0: casp x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_max_i128_aligned_monotonic:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x3, x7
+; -O1: csel x9, x7, x3, lt
+; -O1: csel x8, x4, x2, lt
+; -O1: casp x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw max ptr %ptr, i128 %value monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_max_i128_aligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_max_i128_aligned_acquire:
+; -O0: subs x13, x9, x10
+; -O0: csel x9, x10, x9, lt
+; -O0: csel x2, x11, x12, lt
+; -O0: caspa x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_max_i128_aligned_acquire:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x3, x7
+; -O1: csel x9, x7, x3, lt
+; -O1: csel x8, x4, x2, lt
+; -O1: caspa x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw max ptr %ptr, i128 %value acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_max_i128_aligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_max_i128_aligned_release:
+; -O0: subs x13, x9, x10
+; -O0: csel x9, x10, x9, lt
+; -O0: csel x2, x11, x12, lt
+; -O0: caspl x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_max_i128_aligned_release:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x3, x7
+; -O1: csel x9, x7, x3, lt
+; -O1: csel x8, x4, x2, lt
+; -O1: caspl x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw max ptr %ptr, i128 %value release, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_max_i128_aligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_max_i128_aligned_acq_rel:
+; -O0: subs x13, x9, x10
+; -O0: csel x9, x10, x9, lt
+; -O0: csel x2, x11, x12, lt
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_max_i128_aligned_acq_rel:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x3, x7
+; -O1: csel x9, x7, x3, lt
+; -O1: csel x8, x4, x2, lt
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw max ptr %ptr, i128 %value acq_rel, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_max_i128_aligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_max_i128_aligned_seq_cst:
+; -O0: subs x13, x9, x10
+; -O0: csel x9, x10, x9, lt
+; -O0: csel x2, x11, x12, lt
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_max_i128_aligned_seq_cst:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x3, x7
+; -O1: csel x9, x7, x3, lt
+; -O1: csel x8, x4, x2, lt
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw max ptr %ptr, i128 %value seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_max_i8_unaligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_max_i8_unaligned_monotonic:
+; CHECK: ldsmaxb w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_max_i8_unaligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_max_i8_unaligned_acquire:
+; CHECK: ldsmaxab w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_max_i8_unaligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_max_i8_unaligned_release:
+; CHECK: ldsmaxlb w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_max_i8_unaligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_max_i8_unaligned_acq_rel:
+; CHECK: ldsmaxalb w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_max_i8_unaligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_max_i8_unaligned_seq_cst:
+; CHECK: ldsmaxalb w1, w0, [x0]
+ %r = atomicrmw max ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_max_i16_unaligned_monotonic(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_max_i16_unaligned_monotonic:
+; -O0: sxth w10, w9
+; -O0: subs w10, w10, w8, sxth
+; -O0: csel w8, w9, w8, gt
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i16_unaligned_monotonic:
+; -O1: sxth w8, w0
+; -O1: cmp w8, w19, sxth
+; -O1: csel w8, w0, w19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i16 %value monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_max_i16_unaligned_acquire(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_max_i16_unaligned_acquire:
+; -O0: sxth w10, w9
+; -O0: subs w10, w10, w8, sxth
+; -O0: csel w8, w9, w8, gt
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i16_unaligned_acquire:
+; -O1: sxth w8, w0
+; -O1: cmp w8, w19, sxth
+; -O1: csel w8, w0, w19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i16 %value acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_max_i16_unaligned_release(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_max_i16_unaligned_release:
+; -O0: sxth w10, w9
+; -O0: subs w10, w10, w8, sxth
+; -O0: csel w8, w9, w8, gt
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i16_unaligned_release:
+; -O1: sxth w8, w0
+; -O1: cmp w8, w19, sxth
+; -O1: csel w8, w0, w19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i16 %value release, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_max_i16_unaligned_acq_rel(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_max_i16_unaligned_acq_rel:
+; -O0: sxth w10, w9
+; -O0: subs w10, w10, w8, sxth
+; -O0: csel w8, w9, w8, gt
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i16_unaligned_acq_rel:
+; -O1: sxth w8, w0
+; -O1: cmp w8, w19, sxth
+; -O1: csel w8, w0, w19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i16 %value acq_rel, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_max_i16_unaligned_seq_cst(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_max_i16_unaligned_seq_cst:
+; -O0: sxth w10, w9
+; -O0: subs w10, w10, w8, sxth
+; -O0: csel w8, w9, w8, gt
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i16_unaligned_seq_cst:
+; -O1: sxth w8, w0
+; -O1: cmp w8, w19, sxth
+; -O1: csel w8, w0, w19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i16 %value seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_max_i32_unaligned_monotonic(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_max_i32_unaligned_monotonic:
+; -O0: subs w10, w9, w8
+; -O0: csel w8, w9, w8, gt
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i32_unaligned_monotonic:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i32 %value monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_max_i32_unaligned_acquire(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_max_i32_unaligned_acquire:
+; -O0: subs w10, w9, w8
+; -O0: csel w8, w9, w8, gt
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i32_unaligned_acquire:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i32 %value acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_max_i32_unaligned_release(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_max_i32_unaligned_release:
+; -O0: subs w10, w9, w8
+; -O0: csel w8, w9, w8, gt
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i32_unaligned_release:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i32 %value release, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_max_i32_unaligned_acq_rel(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_max_i32_unaligned_acq_rel:
+; -O0: subs w10, w9, w8
+; -O0: csel w8, w9, w8, gt
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i32_unaligned_acq_rel:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i32 %value acq_rel, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_max_i32_unaligned_seq_cst(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_max_i32_unaligned_seq_cst:
+; -O0: subs w10, w9, w8
+; -O0: csel w8, w9, w8, gt
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i32_unaligned_seq_cst:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i32 %value seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_max_i64_unaligned_monotonic(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_max_i64_unaligned_monotonic:
+; -O0: subs x10, x9, x8
+; -O0: csel x8, x9, x8, gt
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i64_unaligned_monotonic:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i64 %value monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_max_i64_unaligned_acquire(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_max_i64_unaligned_acquire:
+; -O0: subs x10, x9, x8
+; -O0: csel x8, x9, x8, gt
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i64_unaligned_acquire:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i64 %value acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_max_i64_unaligned_release(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_max_i64_unaligned_release:
+; -O0: subs x10, x9, x8
+; -O0: csel x8, x9, x8, gt
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i64_unaligned_release:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i64 %value release, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_max_i64_unaligned_acq_rel(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_max_i64_unaligned_acq_rel:
+; -O0: subs x10, x9, x8
+; -O0: csel x8, x9, x8, gt
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i64_unaligned_acq_rel:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i64 %value acq_rel, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_max_i64_unaligned_seq_cst(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_max_i64_unaligned_seq_cst:
+; -O0: subs x10, x9, x8
+; -O0: csel x8, x9, x8, gt
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i64_unaligned_seq_cst:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, gt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i64 %value seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_max_i128_unaligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_max_i128_unaligned_monotonic:
+; -O0: subs x12, x9, x10
+; -O0: csel x8, x11, x8, lt
+; -O0: csel x9, x10, x9, lt
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i128_unaligned_monotonic:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x19, x1
+; -O1: csel x8, x1, x19, lt
+; -O1: csel x9, x0, x20, lt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i128 %value monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_max_i128_unaligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_max_i128_unaligned_acquire:
+; -O0: subs x12, x9, x10
+; -O0: csel x8, x11, x8, lt
+; -O0: csel x9, x10, x9, lt
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i128_unaligned_acquire:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x19, x1
+; -O1: csel x8, x1, x19, lt
+; -O1: csel x9, x0, x20, lt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i128 %value acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_max_i128_unaligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_max_i128_unaligned_release:
+; -O0: subs x12, x9, x10
+; -O0: csel x8, x11, x8, lt
+; -O0: csel x9, x10, x9, lt
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i128_unaligned_release:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x19, x1
+; -O1: csel x8, x1, x19, lt
+; -O1: csel x9, x0, x20, lt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i128 %value release, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_max_i128_unaligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_max_i128_unaligned_acq_rel:
+; -O0: subs x12, x9, x10
+; -O0: csel x8, x11, x8, lt
+; -O0: csel x9, x10, x9, lt
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i128_unaligned_acq_rel:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x19, x1
+; -O1: csel x8, x1, x19, lt
+; -O1: csel x9, x0, x20, lt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i128 %value acq_rel, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_max_i128_unaligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_max_i128_unaligned_seq_cst:
+; -O0: subs x12, x9, x10
+; -O0: csel x8, x11, x8, lt
+; -O0: csel x9, x10, x9, lt
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_max_i128_unaligned_seq_cst:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x19, x1
+; -O1: csel x8, x1, x19, lt
+; -O1: csel x9, x0, x20, lt
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw max ptr %ptr, i128 %value seq_cst, align 1
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_min_i8_aligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_min_i8_aligned_monotonic:
+; CHECK: ldsminb w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_min_i8_aligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_min_i8_aligned_acquire:
+; CHECK: ldsminab w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_min_i8_aligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_min_i8_aligned_release:
+; CHECK: ldsminlb w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_min_i8_aligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_min_i8_aligned_acq_rel:
+; CHECK: ldsminalb w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_min_i8_aligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_min_i8_aligned_seq_cst:
+; CHECK: ldsminalb w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_min_i16_aligned_monotonic(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_min_i16_aligned_monotonic:
+; CHECK: ldsminh w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i16 %value monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_min_i16_aligned_acquire(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_min_i16_aligned_acquire:
+; CHECK: ldsminah w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i16 %value acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_min_i16_aligned_release(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_min_i16_aligned_release:
+; CHECK: ldsminlh w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i16 %value release, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_min_i16_aligned_acq_rel(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_min_i16_aligned_acq_rel:
+; CHECK: ldsminalh w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i16 %value acq_rel, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_min_i16_aligned_seq_cst(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_min_i16_aligned_seq_cst:
+; CHECK: ldsminalh w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i16 %value seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_min_i32_aligned_monotonic(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_min_i32_aligned_monotonic:
+; CHECK: ldsmin w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i32 %value monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_min_i32_aligned_acquire(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_min_i32_aligned_acquire:
+; CHECK: ldsmina w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i32 %value acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_min_i32_aligned_release(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_min_i32_aligned_release:
+; CHECK: ldsminl w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i32 %value release, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_min_i32_aligned_acq_rel(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_min_i32_aligned_acq_rel:
+; CHECK: ldsminal w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i32 %value acq_rel, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_min_i32_aligned_seq_cst(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_min_i32_aligned_seq_cst:
+; CHECK: ldsminal w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i32 %value seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_min_i64_aligned_monotonic(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_min_i64_aligned_monotonic:
+; CHECK: ldsmin x1, x0, [x0]
+ %r = atomicrmw min ptr %ptr, i64 %value monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_min_i64_aligned_acquire(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_min_i64_aligned_acquire:
+; CHECK: ldsmina x1, x0, [x0]
+ %r = atomicrmw min ptr %ptr, i64 %value acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_min_i64_aligned_release(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_min_i64_aligned_release:
+; CHECK: ldsminl x1, x0, [x0]
+ %r = atomicrmw min ptr %ptr, i64 %value release, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_min_i64_aligned_acq_rel(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_min_i64_aligned_acq_rel:
+; CHECK: ldsminal x1, x0, [x0]
+ %r = atomicrmw min ptr %ptr, i64 %value acq_rel, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_min_i64_aligned_seq_cst(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_min_i64_aligned_seq_cst:
+; CHECK: ldsminal x1, x0, [x0]
+ %r = atomicrmw min ptr %ptr, i64 %value seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_min_i128_aligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_min_i128_aligned_monotonic:
+; -O0: subs x13, x9, x10
+; -O0: csel x9, x10, x9, ge
+; -O0: csel x2, x11, x12, ge
+; -O0: casp x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_min_i128_aligned_monotonic:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x3, x7
+; -O1: csel x9, x7, x3, ge
+; -O1: csel x8, x4, x2, ge
+; -O1: casp x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw min ptr %ptr, i128 %value monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_min_i128_aligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_min_i128_aligned_acquire:
+; -O0: subs x13, x9, x10
+; -O0: csel x9, x10, x9, ge
+; -O0: csel x2, x11, x12, ge
+; -O0: caspa x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_min_i128_aligned_acquire:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x3, x7
+; -O1: csel x9, x7, x3, ge
+; -O1: csel x8, x4, x2, ge
+; -O1: caspa x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw min ptr %ptr, i128 %value acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_min_i128_aligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_min_i128_aligned_release:
+; -O0: subs x13, x9, x10
+; -O0: csel x9, x10, x9, ge
+; -O0: csel x2, x11, x12, ge
+; -O0: caspl x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_min_i128_aligned_release:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x3, x7
+; -O1: csel x9, x7, x3, ge
+; -O1: csel x8, x4, x2, ge
+; -O1: caspl x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw min ptr %ptr, i128 %value release, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_min_i128_aligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_min_i128_aligned_acq_rel:
+; -O0: subs x13, x9, x10
+; -O0: csel x9, x10, x9, ge
+; -O0: csel x2, x11, x12, ge
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_min_i128_aligned_acq_rel:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x3, x7
+; -O1: csel x9, x7, x3, ge
+; -O1: csel x8, x4, x2, ge
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw min ptr %ptr, i128 %value acq_rel, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_min_i128_aligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_min_i128_aligned_seq_cst:
+; -O0: subs x13, x9, x10
+; -O0: csel x9, x10, x9, ge
+; -O0: csel x2, x11, x12, ge
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_min_i128_aligned_seq_cst:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x3, x7
+; -O1: csel x9, x7, x3, ge
+; -O1: csel x8, x4, x2, ge
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw min ptr %ptr, i128 %value seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_min_i8_unaligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_min_i8_unaligned_monotonic:
+; CHECK: ldsminb w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_min_i8_unaligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_min_i8_unaligned_acquire:
+; CHECK: ldsminab w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_min_i8_unaligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_min_i8_unaligned_release:
+; CHECK: ldsminlb w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_min_i8_unaligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_min_i8_unaligned_acq_rel:
+; CHECK: ldsminalb w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_min_i8_unaligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_min_i8_unaligned_seq_cst:
+; CHECK: ldsminalb w1, w0, [x0]
+ %r = atomicrmw min ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_min_i16_unaligned_monotonic(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_min_i16_unaligned_monotonic:
+; -O0: sxth w10, w9
+; -O0: subs w10, w10, w8, sxth
+; -O0: csel w8, w9, w8, le
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i16_unaligned_monotonic:
+; -O1: sxth w8, w0
+; -O1: cmp w8, w19, sxth
+; -O1: csel w8, w0, w19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i16 %value monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_min_i16_unaligned_acquire(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_min_i16_unaligned_acquire:
+; -O0: sxth w10, w9
+; -O0: subs w10, w10, w8, sxth
+; -O0: csel w8, w9, w8, le
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i16_unaligned_acquire:
+; -O1: sxth w8, w0
+; -O1: cmp w8, w19, sxth
+; -O1: csel w8, w0, w19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i16 %value acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_min_i16_unaligned_release(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_min_i16_unaligned_release:
+; -O0: sxth w10, w9
+; -O0: subs w10, w10, w8, sxth
+; -O0: csel w8, w9, w8, le
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i16_unaligned_release:
+; -O1: sxth w8, w0
+; -O1: cmp w8, w19, sxth
+; -O1: csel w8, w0, w19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i16 %value release, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_min_i16_unaligned_acq_rel(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_min_i16_unaligned_acq_rel:
+; -O0: sxth w10, w9
+; -O0: subs w10, w10, w8, sxth
+; -O0: csel w8, w9, w8, le
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i16_unaligned_acq_rel:
+; -O1: sxth w8, w0
+; -O1: cmp w8, w19, sxth
+; -O1: csel w8, w0, w19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i16 %value acq_rel, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_min_i16_unaligned_seq_cst(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_min_i16_unaligned_seq_cst:
+; -O0: sxth w10, w9
+; -O0: subs w10, w10, w8, sxth
+; -O0: csel w8, w9, w8, le
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i16_unaligned_seq_cst:
+; -O1: sxth w8, w0
+; -O1: cmp w8, w19, sxth
+; -O1: csel w8, w0, w19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i16 %value seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_min_i32_unaligned_monotonic(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_min_i32_unaligned_monotonic:
+; -O0: subs w10, w9, w8
+; -O0: csel w8, w9, w8, le
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i32_unaligned_monotonic:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i32 %value monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_min_i32_unaligned_acquire(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_min_i32_unaligned_acquire:
+; -O0: subs w10, w9, w8
+; -O0: csel w8, w9, w8, le
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i32_unaligned_acquire:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i32 %value acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_min_i32_unaligned_release(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_min_i32_unaligned_release:
+; -O0: subs w10, w9, w8
+; -O0: csel w8, w9, w8, le
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i32_unaligned_release:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i32 %value release, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_min_i32_unaligned_acq_rel(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_min_i32_unaligned_acq_rel:
+; -O0: subs w10, w9, w8
+; -O0: csel w8, w9, w8, le
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i32_unaligned_acq_rel:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i32 %value acq_rel, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_min_i32_unaligned_seq_cst(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_min_i32_unaligned_seq_cst:
+; -O0: subs w10, w9, w8
+; -O0: csel w8, w9, w8, le
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i32_unaligned_seq_cst:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i32 %value seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_min_i64_unaligned_monotonic(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_min_i64_unaligned_monotonic:
+; -O0: subs x10, x9, x8
+; -O0: csel x8, x9, x8, le
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i64_unaligned_monotonic:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i64 %value monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_min_i64_unaligned_acquire(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_min_i64_unaligned_acquire:
+; -O0: subs x10, x9, x8
+; -O0: csel x8, x9, x8, le
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i64_unaligned_acquire:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i64 %value acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_min_i64_unaligned_release(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_min_i64_unaligned_release:
+; -O0: subs x10, x9, x8
+; -O0: csel x8, x9, x8, le
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i64_unaligned_release:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i64 %value release, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_min_i64_unaligned_acq_rel(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_min_i64_unaligned_acq_rel:
+; -O0: subs x10, x9, x8
+; -O0: csel x8, x9, x8, le
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i64_unaligned_acq_rel:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i64 %value acq_rel, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_min_i64_unaligned_seq_cst(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_min_i64_unaligned_seq_cst:
+; -O0: subs x10, x9, x8
+; -O0: csel x8, x9, x8, le
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i64_unaligned_seq_cst:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, le
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i64 %value seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_min_i128_unaligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_min_i128_unaligned_monotonic:
+; -O0: subs x12, x9, x10
+; -O0: csel x8, x11, x8, ge
+; -O0: csel x9, x10, x9, ge
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i128_unaligned_monotonic:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x19, x1
+; -O1: csel x8, x1, x19, ge
+; -O1: csel x9, x0, x20, ge
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i128 %value monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_min_i128_unaligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_min_i128_unaligned_acquire:
+; -O0: subs x12, x9, x10
+; -O0: csel x8, x11, x8, ge
+; -O0: csel x9, x10, x9, ge
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i128_unaligned_acquire:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x19, x1
+; -O1: csel x8, x1, x19, ge
+; -O1: csel x9, x0, x20, ge
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i128 %value acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_min_i128_unaligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_min_i128_unaligned_release:
+; -O0: subs x12, x9, x10
+; -O0: csel x8, x11, x8, ge
+; -O0: csel x9, x10, x9, ge
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i128_unaligned_release:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x19, x1
+; -O1: csel x8, x1, x19, ge
+; -O1: csel x9, x0, x20, ge
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i128 %value release, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_min_i128_unaligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_min_i128_unaligned_acq_rel:
+; -O0: subs x12, x9, x10
+; -O0: csel x8, x11, x8, ge
+; -O0: csel x9, x10, x9, ge
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i128_unaligned_acq_rel:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x19, x1
+; -O1: csel x8, x1, x19, ge
+; -O1: csel x9, x0, x20, ge
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i128 %value acq_rel, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_min_i128_unaligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_min_i128_unaligned_seq_cst:
+; -O0: subs x12, x9, x10
+; -O0: csel x8, x11, x8, ge
+; -O0: csel x9, x10, x9, ge
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_min_i128_unaligned_seq_cst:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x19, x1
+; -O1: csel x8, x1, x19, ge
+; -O1: csel x9, x0, x20, ge
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw min ptr %ptr, i128 %value seq_cst, align 1
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_umax_i8_aligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umax_i8_aligned_monotonic:
+; CHECK: ldumaxb w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umax_i8_aligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umax_i8_aligned_acquire:
+; CHECK: ldumaxab w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umax_i8_aligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umax_i8_aligned_release:
+; CHECK: ldumaxlb w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umax_i8_aligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umax_i8_aligned_acq_rel:
+; CHECK: ldumaxalb w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umax_i8_aligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umax_i8_aligned_seq_cst:
+; CHECK: ldumaxalb w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_umax_i16_aligned_monotonic(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_umax_i16_aligned_monotonic:
+; CHECK: ldumaxh w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i16 %value monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umax_i16_aligned_acquire(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_umax_i16_aligned_acquire:
+; CHECK: ldumaxah w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i16 %value acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umax_i16_aligned_release(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_umax_i16_aligned_release:
+; CHECK: ldumaxlh w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i16 %value release, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umax_i16_aligned_acq_rel(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_umax_i16_aligned_acq_rel:
+; CHECK: ldumaxalh w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i16 %value acq_rel, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umax_i16_aligned_seq_cst(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_umax_i16_aligned_seq_cst:
+; CHECK: ldumaxalh w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i16 %value seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_umax_i32_aligned_monotonic(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_umax_i32_aligned_monotonic:
+; CHECK: ldumax w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i32 %value monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umax_i32_aligned_acquire(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_umax_i32_aligned_acquire:
+; CHECK: ldumaxa w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i32 %value acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umax_i32_aligned_release(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_umax_i32_aligned_release:
+; CHECK: ldumaxl w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i32 %value release, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umax_i32_aligned_acq_rel(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_umax_i32_aligned_acq_rel:
+; CHECK: ldumaxal w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i32 %value acq_rel, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umax_i32_aligned_seq_cst(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_umax_i32_aligned_seq_cst:
+; CHECK: ldumaxal w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i32 %value seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_umax_i64_aligned_monotonic(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_umax_i64_aligned_monotonic:
+; CHECK: ldumax x1, x0, [x0]
+ %r = atomicrmw umax ptr %ptr, i64 %value monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umax_i64_aligned_acquire(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_umax_i64_aligned_acquire:
+; CHECK: ldumaxa x1, x0, [x0]
+ %r = atomicrmw umax ptr %ptr, i64 %value acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umax_i64_aligned_release(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_umax_i64_aligned_release:
+; CHECK: ldumaxl x1, x0, [x0]
+ %r = atomicrmw umax ptr %ptr, i64 %value release, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umax_i64_aligned_acq_rel(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_umax_i64_aligned_acq_rel:
+; CHECK: ldumaxal x1, x0, [x0]
+ %r = atomicrmw umax ptr %ptr, i64 %value acq_rel, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umax_i64_aligned_seq_cst(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_umax_i64_aligned_seq_cst:
+; CHECK: ldumaxal x1, x0, [x0]
+ %r = atomicrmw umax ptr %ptr, i64 %value seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_umax_i128_aligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umax_i128_aligned_monotonic:
+; -O0: subs x13, x9, x10
+; -O0: csel x9, x10, x9, lo
+; -O0: csel x2, x11, x12, lo
+; -O0: casp x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_umax_i128_aligned_monotonic:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x3, x7
+; -O1: csel x9, x7, x3, lo
+; -O1: csel x8, x4, x2, lo
+; -O1: casp x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw umax ptr %ptr, i128 %value monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umax_i128_aligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umax_i128_aligned_acquire:
+; -O0: subs x13, x9, x10
+; -O0: csel x9, x10, x9, lo
+; -O0: csel x2, x11, x12, lo
+; -O0: caspa x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_umax_i128_aligned_acquire:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x3, x7
+; -O1: csel x9, x7, x3, lo
+; -O1: csel x8, x4, x2, lo
+; -O1: caspa x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw umax ptr %ptr, i128 %value acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umax_i128_aligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umax_i128_aligned_release:
+; -O0: subs x13, x9, x10
+; -O0: csel x9, x10, x9, lo
+; -O0: csel x2, x11, x12, lo
+; -O0: caspl x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_umax_i128_aligned_release:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x3, x7
+; -O1: csel x9, x7, x3, lo
+; -O1: csel x8, x4, x2, lo
+; -O1: caspl x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw umax ptr %ptr, i128 %value release, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umax_i128_aligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umax_i128_aligned_acq_rel:
+; -O0: subs x13, x9, x10
+; -O0: csel x9, x10, x9, lo
+; -O0: csel x2, x11, x12, lo
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_umax_i128_aligned_acq_rel:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x3, x7
+; -O1: csel x9, x7, x3, lo
+; -O1: csel x8, x4, x2, lo
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw umax ptr %ptr, i128 %value acq_rel, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umax_i128_aligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umax_i128_aligned_seq_cst:
+; -O0: subs x13, x9, x10
+; -O0: csel x9, x10, x9, lo
+; -O0: csel x2, x11, x12, lo
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_umax_i128_aligned_seq_cst:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x3, x7
+; -O1: csel x9, x7, x3, lo
+; -O1: csel x8, x4, x2, lo
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw umax ptr %ptr, i128 %value seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_umax_i8_unaligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umax_i8_unaligned_monotonic:
+; CHECK: ldumaxb w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umax_i8_unaligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umax_i8_unaligned_acquire:
+; CHECK: ldumaxab w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umax_i8_unaligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umax_i8_unaligned_release:
+; CHECK: ldumaxlb w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umax_i8_unaligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umax_i8_unaligned_acq_rel:
+; CHECK: ldumaxalb w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umax_i8_unaligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umax_i8_unaligned_seq_cst:
+; CHECK: ldumaxalb w1, w0, [x0]
+ %r = atomicrmw umax ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_umax_i16_unaligned_monotonic(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_umax_i16_unaligned_monotonic:
+; -O0: and w10, w9, #0xffff
+; -O0: subs w10, w10, w8, uxth
+; -O0: csel w8, w9, w8, hi
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i16_unaligned_monotonic:
+; -O1: and w8, w0, #0xffff
+; -O1: cmp w8, w19, uxth
+; -O1: csel w8, w0, w19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i16 %value monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umax_i16_unaligned_acquire(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_umax_i16_unaligned_acquire:
+; -O0: and w10, w9, #0xffff
+; -O0: subs w10, w10, w8, uxth
+; -O0: csel w8, w9, w8, hi
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i16_unaligned_acquire:
+; -O1: and w8, w0, #0xffff
+; -O1: cmp w8, w19, uxth
+; -O1: csel w8, w0, w19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i16 %value acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umax_i16_unaligned_release(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_umax_i16_unaligned_release:
+; -O0: and w10, w9, #0xffff
+; -O0: subs w10, w10, w8, uxth
+; -O0: csel w8, w9, w8, hi
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i16_unaligned_release:
+; -O1: and w8, w0, #0xffff
+; -O1: cmp w8, w19, uxth
+; -O1: csel w8, w0, w19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i16 %value release, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umax_i16_unaligned_acq_rel(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_umax_i16_unaligned_acq_rel:
+; -O0: and w10, w9, #0xffff
+; -O0: subs w10, w10, w8, uxth
+; -O0: csel w8, w9, w8, hi
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i16_unaligned_acq_rel:
+; -O1: and w8, w0, #0xffff
+; -O1: cmp w8, w19, uxth
+; -O1: csel w8, w0, w19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i16 %value acq_rel, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umax_i16_unaligned_seq_cst(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_umax_i16_unaligned_seq_cst:
+; -O0: and w10, w9, #0xffff
+; -O0: subs w10, w10, w8, uxth
+; -O0: csel w8, w9, w8, hi
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i16_unaligned_seq_cst:
+; -O1: and w8, w0, #0xffff
+; -O1: cmp w8, w19, uxth
+; -O1: csel w8, w0, w19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i16 %value seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_umax_i32_unaligned_monotonic(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_umax_i32_unaligned_monotonic:
+; -O0: subs w10, w9, w8
+; -O0: csel w8, w9, w8, hi
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i32_unaligned_monotonic:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i32 %value monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umax_i32_unaligned_acquire(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_umax_i32_unaligned_acquire:
+; -O0: subs w10, w9, w8
+; -O0: csel w8, w9, w8, hi
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i32_unaligned_acquire:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i32 %value acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umax_i32_unaligned_release(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_umax_i32_unaligned_release:
+; -O0: subs w10, w9, w8
+; -O0: csel w8, w9, w8, hi
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i32_unaligned_release:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i32 %value release, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umax_i32_unaligned_acq_rel(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_umax_i32_unaligned_acq_rel:
+; -O0: subs w10, w9, w8
+; -O0: csel w8, w9, w8, hi
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i32_unaligned_acq_rel:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i32 %value acq_rel, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umax_i32_unaligned_seq_cst(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_umax_i32_unaligned_seq_cst:
+; -O0: subs w10, w9, w8
+; -O0: csel w8, w9, w8, hi
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i32_unaligned_seq_cst:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i32 %value seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_umax_i64_unaligned_monotonic(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_umax_i64_unaligned_monotonic:
+; -O0: subs x10, x9, x8
+; -O0: csel x8, x9, x8, hi
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i64_unaligned_monotonic:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i64 %value monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umax_i64_unaligned_acquire(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_umax_i64_unaligned_acquire:
+; -O0: subs x10, x9, x8
+; -O0: csel x8, x9, x8, hi
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i64_unaligned_acquire:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i64 %value acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umax_i64_unaligned_release(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_umax_i64_unaligned_release:
+; -O0: subs x10, x9, x8
+; -O0: csel x8, x9, x8, hi
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i64_unaligned_release:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i64 %value release, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umax_i64_unaligned_acq_rel(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_umax_i64_unaligned_acq_rel:
+; -O0: subs x10, x9, x8
+; -O0: csel x8, x9, x8, hi
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i64_unaligned_acq_rel:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i64 %value acq_rel, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umax_i64_unaligned_seq_cst(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_umax_i64_unaligned_seq_cst:
+; -O0: subs x10, x9, x8
+; -O0: csel x8, x9, x8, hi
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i64_unaligned_seq_cst:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, hi
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i64 %value seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_umax_i128_unaligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umax_i128_unaligned_monotonic:
+; -O0: subs x12, x9, x10
+; -O0: csel x8, x11, x8, lo
+; -O0: csel x9, x10, x9, lo
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i128_unaligned_monotonic:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x19, x1
+; -O1: csel x8, x1, x19, lo
+; -O1: csel x9, x0, x20, lo
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i128 %value monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umax_i128_unaligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umax_i128_unaligned_acquire:
+; -O0: subs x12, x9, x10
+; -O0: csel x8, x11, x8, lo
+; -O0: csel x9, x10, x9, lo
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i128_unaligned_acquire:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x19, x1
+; -O1: csel x8, x1, x19, lo
+; -O1: csel x9, x0, x20, lo
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i128 %value acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umax_i128_unaligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umax_i128_unaligned_release:
+; -O0: subs x12, x9, x10
+; -O0: csel x8, x11, x8, lo
+; -O0: csel x9, x10, x9, lo
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i128_unaligned_release:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x19, x1
+; -O1: csel x8, x1, x19, lo
+; -O1: csel x9, x0, x20, lo
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i128 %value release, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umax_i128_unaligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umax_i128_unaligned_acq_rel:
+; -O0: subs x12, x9, x10
+; -O0: csel x8, x11, x8, lo
+; -O0: csel x9, x10, x9, lo
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i128_unaligned_acq_rel:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x19, x1
+; -O1: csel x8, x1, x19, lo
+; -O1: csel x9, x0, x20, lo
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i128 %value acq_rel, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umax_i128_unaligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umax_i128_unaligned_seq_cst:
+; -O0: subs x12, x9, x10
+; -O0: csel x8, x11, x8, lo
+; -O0: csel x9, x10, x9, lo
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umax_i128_unaligned_seq_cst:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x19, x1
+; -O1: csel x8, x1, x19, lo
+; -O1: csel x9, x0, x20, lo
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umax ptr %ptr, i128 %value seq_cst, align 1
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_umin_i8_aligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umin_i8_aligned_monotonic:
+; CHECK: lduminb w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umin_i8_aligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umin_i8_aligned_acquire:
+; CHECK: lduminab w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umin_i8_aligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umin_i8_aligned_release:
+; CHECK: lduminlb w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umin_i8_aligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umin_i8_aligned_acq_rel:
+; CHECK: lduminalb w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umin_i8_aligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umin_i8_aligned_seq_cst:
+; CHECK: lduminalb w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_umin_i16_aligned_monotonic(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_umin_i16_aligned_monotonic:
+; CHECK: lduminh w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i16 %value monotonic, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umin_i16_aligned_acquire(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_umin_i16_aligned_acquire:
+; CHECK: lduminah w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i16 %value acquire, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umin_i16_aligned_release(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_umin_i16_aligned_release:
+; CHECK: lduminlh w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i16 %value release, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umin_i16_aligned_acq_rel(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_umin_i16_aligned_acq_rel:
+; CHECK: lduminalh w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i16 %value acq_rel, align 2
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umin_i16_aligned_seq_cst(ptr %ptr, i16 %value) {
+; CHECK-LABEL: atomicrmw_umin_i16_aligned_seq_cst:
+; CHECK: lduminalh w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i16 %value seq_cst, align 2
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_umin_i32_aligned_monotonic(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_umin_i32_aligned_monotonic:
+; CHECK: ldumin w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i32 %value monotonic, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umin_i32_aligned_acquire(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_umin_i32_aligned_acquire:
+; CHECK: ldumina w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i32 %value acquire, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umin_i32_aligned_release(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_umin_i32_aligned_release:
+; CHECK: lduminl w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i32 %value release, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umin_i32_aligned_acq_rel(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_umin_i32_aligned_acq_rel:
+; CHECK: lduminal w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i32 %value acq_rel, align 4
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umin_i32_aligned_seq_cst(ptr %ptr, i32 %value) {
+; CHECK-LABEL: atomicrmw_umin_i32_aligned_seq_cst:
+; CHECK: lduminal w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i32 %value seq_cst, align 4
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_umin_i64_aligned_monotonic(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_umin_i64_aligned_monotonic:
+; CHECK: ldumin x1, x0, [x0]
+ %r = atomicrmw umin ptr %ptr, i64 %value monotonic, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umin_i64_aligned_acquire(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_umin_i64_aligned_acquire:
+; CHECK: ldumina x1, x0, [x0]
+ %r = atomicrmw umin ptr %ptr, i64 %value acquire, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umin_i64_aligned_release(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_umin_i64_aligned_release:
+; CHECK: lduminl x1, x0, [x0]
+ %r = atomicrmw umin ptr %ptr, i64 %value release, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umin_i64_aligned_acq_rel(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_umin_i64_aligned_acq_rel:
+; CHECK: lduminal x1, x0, [x0]
+ %r = atomicrmw umin ptr %ptr, i64 %value acq_rel, align 8
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umin_i64_aligned_seq_cst(ptr %ptr, i64 %value) {
+; CHECK-LABEL: atomicrmw_umin_i64_aligned_seq_cst:
+; CHECK: lduminal x1, x0, [x0]
+ %r = atomicrmw umin ptr %ptr, i64 %value seq_cst, align 8
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_umin_i128_aligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umin_i128_aligned_monotonic:
+; -O0: subs x13, x9, x10
+; -O0: csel x9, x10, x9, hs
+; -O0: csel x2, x11, x12, hs
+; -O0: casp x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_umin_i128_aligned_monotonic:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x3, x7
+; -O1: csel x9, x7, x3, hs
+; -O1: csel x8, x4, x2, hs
+; -O1: casp x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw umin ptr %ptr, i128 %value monotonic, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umin_i128_aligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umin_i128_aligned_acquire:
+; -O0: subs x13, x9, x10
+; -O0: csel x9, x10, x9, hs
+; -O0: csel x2, x11, x12, hs
+; -O0: caspa x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_umin_i128_aligned_acquire:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x3, x7
+; -O1: csel x9, x7, x3, hs
+; -O1: csel x8, x4, x2, hs
+; -O1: caspa x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw umin ptr %ptr, i128 %value acquire, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umin_i128_aligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umin_i128_aligned_release:
+; -O0: subs x13, x9, x10
+; -O0: csel x9, x10, x9, hs
+; -O0: csel x2, x11, x12, hs
+; -O0: caspl x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_umin_i128_aligned_release:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x3, x7
+; -O1: csel x9, x7, x3, hs
+; -O1: csel x8, x4, x2, hs
+; -O1: caspl x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw umin ptr %ptr, i128 %value release, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umin_i128_aligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umin_i128_aligned_acq_rel:
+; -O0: subs x13, x9, x10
+; -O0: csel x9, x10, x9, hs
+; -O0: csel x2, x11, x12, hs
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_umin_i128_aligned_acq_rel:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x3, x7
+; -O1: csel x9, x7, x3, hs
+; -O1: csel x8, x4, x2, hs
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw umin ptr %ptr, i128 %value acq_rel, align 16
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umin_i128_aligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umin_i128_aligned_seq_cst:
+; -O0: subs x13, x9, x10
+; -O0: csel x9, x10, x9, hs
+; -O0: csel x2, x11, x12, hs
+; -O0: caspal x0, x1, x2, x3, [x8]
+; -O0: subs x11, x9, x11
+; -O0: ccmp x8, x10, #0, eq
+;
+; -O1-LABEL: atomicrmw_umin_i128_aligned_seq_cst:
+; -O1: ldp x4, x5, [x0]
+; -O1: cmp x3, x7
+; -O1: csel x9, x7, x3, hs
+; -O1: csel x8, x4, x2, hs
+; -O1: caspal x4, x5, x8, x9, [x0]
+; -O1: cmp x4, x6
+; -O1: ccmp x5, x7, #0, eq
+ %r = atomicrmw umin ptr %ptr, i128 %value seq_cst, align 16
+ ret i128 %r
+}
+
+define dso_local i8 @atomicrmw_umin_i8_unaligned_monotonic(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umin_i8_unaligned_monotonic:
+; CHECK: lduminb w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i8 %value monotonic, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umin_i8_unaligned_acquire(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umin_i8_unaligned_acquire:
+; CHECK: lduminab w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i8 %value acquire, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umin_i8_unaligned_release(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umin_i8_unaligned_release:
+; CHECK: lduminlb w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i8 %value release, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umin_i8_unaligned_acq_rel(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umin_i8_unaligned_acq_rel:
+; CHECK: lduminalb w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i8 %value acq_rel, align 1
+ ret i8 %r
+}
+
+define dso_local i8 @atomicrmw_umin_i8_unaligned_seq_cst(ptr %ptr, i8 %value) {
+; CHECK-LABEL: atomicrmw_umin_i8_unaligned_seq_cst:
+; CHECK: lduminalb w1, w0, [x0]
+ %r = atomicrmw umin ptr %ptr, i8 %value seq_cst, align 1
+ ret i8 %r
+}
+
+define dso_local i16 @atomicrmw_umin_i16_unaligned_monotonic(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_umin_i16_unaligned_monotonic:
+; -O0: and w10, w9, #0xffff
+; -O0: subs w10, w10, w8, uxth
+; -O0: csel w8, w9, w8, ls
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i16_unaligned_monotonic:
+; -O1: and w8, w0, #0xffff
+; -O1: cmp w8, w19, uxth
+; -O1: csel w8, w0, w19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i16 %value monotonic, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umin_i16_unaligned_acquire(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_umin_i16_unaligned_acquire:
+; -O0: and w10, w9, #0xffff
+; -O0: subs w10, w10, w8, uxth
+; -O0: csel w8, w9, w8, ls
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i16_unaligned_acquire:
+; -O1: and w8, w0, #0xffff
+; -O1: cmp w8, w19, uxth
+; -O1: csel w8, w0, w19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i16 %value acquire, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umin_i16_unaligned_release(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_umin_i16_unaligned_release:
+; -O0: and w10, w9, #0xffff
+; -O0: subs w10, w10, w8, uxth
+; -O0: csel w8, w9, w8, ls
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i16_unaligned_release:
+; -O1: and w8, w0, #0xffff
+; -O1: cmp w8, w19, uxth
+; -O1: csel w8, w0, w19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i16 %value release, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umin_i16_unaligned_acq_rel(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_umin_i16_unaligned_acq_rel:
+; -O0: and w10, w9, #0xffff
+; -O0: subs w10, w10, w8, uxth
+; -O0: csel w8, w9, w8, ls
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i16_unaligned_acq_rel:
+; -O1: and w8, w0, #0xffff
+; -O1: cmp w8, w19, uxth
+; -O1: csel w8, w0, w19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i16 %value acq_rel, align 1
+ ret i16 %r
+}
+
+define dso_local i16 @atomicrmw_umin_i16_unaligned_seq_cst(ptr %ptr, i16 %value) {
+; -O0-LABEL: atomicrmw_umin_i16_unaligned_seq_cst:
+; -O0: and w10, w9, #0xffff
+; -O0: subs w10, w10, w8, uxth
+; -O0: csel w8, w9, w8, ls
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i16_unaligned_seq_cst:
+; -O1: and w8, w0, #0xffff
+; -O1: cmp w8, w19, uxth
+; -O1: csel w8, w0, w19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i16 %value seq_cst, align 1
+ ret i16 %r
+}
+
+define dso_local i32 @atomicrmw_umin_i32_unaligned_monotonic(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_umin_i32_unaligned_monotonic:
+; -O0: subs w10, w9, w8
+; -O0: csel w8, w9, w8, ls
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i32_unaligned_monotonic:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i32 %value monotonic, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umin_i32_unaligned_acquire(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_umin_i32_unaligned_acquire:
+; -O0: subs w10, w9, w8
+; -O0: csel w8, w9, w8, ls
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i32_unaligned_acquire:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i32 %value acquire, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umin_i32_unaligned_release(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_umin_i32_unaligned_release:
+; -O0: subs w10, w9, w8
+; -O0: csel w8, w9, w8, ls
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i32_unaligned_release:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i32 %value release, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umin_i32_unaligned_acq_rel(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_umin_i32_unaligned_acq_rel:
+; -O0: subs w10, w9, w8
+; -O0: csel w8, w9, w8, ls
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i32_unaligned_acq_rel:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i32 %value acq_rel, align 1
+ ret i32 %r
+}
+
+define dso_local i32 @atomicrmw_umin_i32_unaligned_seq_cst(ptr %ptr, i32 %value) {
+; -O0-LABEL: atomicrmw_umin_i32_unaligned_seq_cst:
+; -O0: subs w10, w9, w8
+; -O0: csel w8, w9, w8, ls
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i32_unaligned_seq_cst:
+; -O1: cmp w0, w19
+; -O1: csel w8, w0, w19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i32 %value seq_cst, align 1
+ ret i32 %r
+}
+
+define dso_local i64 @atomicrmw_umin_i64_unaligned_monotonic(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_umin_i64_unaligned_monotonic:
+; -O0: subs x10, x9, x8
+; -O0: csel x8, x9, x8, ls
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i64_unaligned_monotonic:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i64 %value monotonic, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umin_i64_unaligned_acquire(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_umin_i64_unaligned_acquire:
+; -O0: subs x10, x9, x8
+; -O0: csel x8, x9, x8, ls
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i64_unaligned_acquire:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i64 %value acquire, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umin_i64_unaligned_release(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_umin_i64_unaligned_release:
+; -O0: subs x10, x9, x8
+; -O0: csel x8, x9, x8, ls
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i64_unaligned_release:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i64 %value release, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umin_i64_unaligned_acq_rel(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_umin_i64_unaligned_acq_rel:
+; -O0: subs x10, x9, x8
+; -O0: csel x8, x9, x8, ls
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i64_unaligned_acq_rel:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i64 %value acq_rel, align 1
+ ret i64 %r
+}
+
+define dso_local i64 @atomicrmw_umin_i64_unaligned_seq_cst(ptr %ptr, i64 %value) {
+; -O0-LABEL: atomicrmw_umin_i64_unaligned_seq_cst:
+; -O0: subs x10, x9, x8
+; -O0: csel x8, x9, x8, ls
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i64_unaligned_seq_cst:
+; -O1: cmp x0, x19
+; -O1: csel x8, x0, x19, ls
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i64 %value seq_cst, align 1
+ ret i64 %r
+}
+
+define dso_local i128 @atomicrmw_umin_i128_unaligned_monotonic(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umin_i128_unaligned_monotonic:
+; -O0: subs x12, x9, x10
+; -O0: csel x8, x11, x8, hs
+; -O0: csel x9, x10, x9, hs
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i128_unaligned_monotonic:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x19, x1
+; -O1: csel x8, x1, x19, hs
+; -O1: csel x9, x0, x20, hs
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i128 %value monotonic, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umin_i128_unaligned_acquire(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umin_i128_unaligned_acquire:
+; -O0: subs x12, x9, x10
+; -O0: csel x8, x11, x8, hs
+; -O0: csel x9, x10, x9, hs
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i128_unaligned_acquire:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x19, x1
+; -O1: csel x8, x1, x19, hs
+; -O1: csel x9, x0, x20, hs
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i128 %value acquire, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umin_i128_unaligned_release(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umin_i128_unaligned_release:
+; -O0: subs x12, x9, x10
+; -O0: csel x8, x11, x8, hs
+; -O0: csel x9, x10, x9, hs
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i128_unaligned_release:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x19, x1
+; -O1: csel x8, x1, x19, hs
+; -O1: csel x9, x0, x20, hs
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i128 %value release, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umin_i128_unaligned_acq_rel(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umin_i128_unaligned_acq_rel:
+; -O0: subs x12, x9, x10
+; -O0: csel x8, x11, x8, hs
+; -O0: csel x9, x10, x9, hs
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i128_unaligned_acq_rel:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x19, x1
+; -O1: csel x8, x1, x19, hs
+; -O1: csel x9, x0, x20, hs
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i128 %value acq_rel, align 1
+ ret i128 %r
+}
+
+define dso_local i128 @atomicrmw_umin_i128_unaligned_seq_cst(ptr %ptr, i128 %value) {
+; -O0-LABEL: atomicrmw_umin_i128_unaligned_seq_cst:
+; -O0: subs x12, x9, x10
+; -O0: csel x8, x11, x8, hs
+; -O0: csel x9, x10, x9, hs
+; -O0: bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_umin_i128_unaligned_seq_cst:
+; -O1: ldp x0, x1, [x0]
+; -O1: cmp x19, x1
+; -O1: csel x8, x1, x19, hs
+; -O1: csel x9, x0, x20, hs
+; -O1: bl __atomic_compare_exchange
+ %r = atomicrmw umin ptr %ptr, i128 %value seq_cst, align 1
+ ret i128 %r
+}
diff --git a/llvm/test/CodeGen/AArch64/Atomics/aarch64_be-cmpxchg-lse2_lse128.ll b/llvm/test/CodeGen/AArch64/Atomics/aarch64_be-cmpxchg-lse2_lse128.ll
new file mode 100644
index 000000000000..3e5dae3726b7
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/Atomics/aarch64_be-cmpxchg-lse2_lse128.ll
@@ -0,0 +1,2494 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --filter-out "\b(sp)\b" --filter "^\s*(ld[^r]|st[^r]|swp|cas|bl|add|and|eor|orn|orr|sub|mvn|sxt|cmp|ccmp|csel|dmb)"
+; The base test file was generated by ./llvm/test/CodeGen/AArch64/Atomics/generate-tests.py
+; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64_be -mattr=+lse2,+lse128 -O0 | FileCheck %s --check-prefixes=CHECK,-O0
+; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64_be -mattr=+lse2,+lse128 -O1 | FileCheck %s --check-prefixes=CHECK,-O1
+
+define dso_local i8 @cmpxchg_i8_aligned_monotonic_monotonic(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_monotonic_monotonic:
+; CHECK: casb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new monotonic monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_monotonic_monotonic_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_monotonic_monotonic_weak:
+; CHECK: casb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new monotonic monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_monotonic_acquire(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_monotonic_acquire:
+; CHECK: casab w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new monotonic acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_monotonic_acquire_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_monotonic_acquire_weak:
+; CHECK: casab w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new monotonic acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_monotonic_seq_cst(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_monotonic_seq_cst:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new monotonic seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_monotonic_seq_cst_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_monotonic_seq_cst_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new monotonic seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_acquire_monotonic(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_acquire_monotonic:
+; CHECK: casab w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new acquire monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_acquire_monotonic_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_acquire_monotonic_weak:
+; CHECK: casab w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new acquire monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_acquire_acquire(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_acquire_acquire:
+; CHECK: casab w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new acquire acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_acquire_acquire_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_acquire_acquire_weak:
+; CHECK: casab w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new acquire acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_acquire_seq_cst(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_acquire_seq_cst:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new acquire seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_acquire_seq_cst_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_acquire_seq_cst_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new acquire seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_release_monotonic(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_release_monotonic:
+; CHECK: caslb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new release monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_release_monotonic_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_release_monotonic_weak:
+; CHECK: caslb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new release monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_release_acquire(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_release_acquire:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new release acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_release_acquire_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_release_acquire_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new release acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_release_seq_cst(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_release_seq_cst:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new release seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_release_seq_cst_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_release_seq_cst_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new release seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_acq_rel_monotonic(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_acq_rel_monotonic:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new acq_rel monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_acq_rel_monotonic_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_acq_rel_monotonic_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new acq_rel monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_acq_rel_acquire(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_acq_rel_acquire:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new acq_rel acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_acq_rel_acquire_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_acq_rel_acquire_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new acq_rel acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_acq_rel_seq_cst(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_acq_rel_seq_cst:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new acq_rel seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_acq_rel_seq_cst_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_acq_rel_seq_cst_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new acq_rel seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_seq_cst_monotonic(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_seq_cst_monotonic:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new seq_cst monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_seq_cst_monotonic_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_seq_cst_monotonic_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new seq_cst monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_seq_cst_acquire(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_seq_cst_acquire:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new seq_cst acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_seq_cst_acquire_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_seq_cst_acquire_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new seq_cst acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_seq_cst_seq_cst(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_seq_cst_seq_cst:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new seq_cst seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_aligned_seq_cst_seq_cst_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_aligned_seq_cst_seq_cst_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new seq_cst seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_monotonic_monotonic(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_monotonic_monotonic:
+; CHECK: cash w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new monotonic monotonic, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_monotonic_monotonic_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_monotonic_monotonic_weak:
+; CHECK: cash w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new monotonic monotonic, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_monotonic_acquire(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_monotonic_acquire:
+; CHECK: casah w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new monotonic acquire, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_monotonic_acquire_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_monotonic_acquire_weak:
+; CHECK: casah w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new monotonic acquire, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_monotonic_seq_cst(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_monotonic_seq_cst:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new monotonic seq_cst, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_monotonic_seq_cst_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_monotonic_seq_cst_weak:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new monotonic seq_cst, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_acquire_monotonic(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_acquire_monotonic:
+; CHECK: casah w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new acquire monotonic, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_acquire_monotonic_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_acquire_monotonic_weak:
+; CHECK: casah w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new acquire monotonic, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_acquire_acquire(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_acquire_acquire:
+; CHECK: casah w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new acquire acquire, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_acquire_acquire_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_acquire_acquire_weak:
+; CHECK: casah w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new acquire acquire, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_acquire_seq_cst(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_acquire_seq_cst:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new acquire seq_cst, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_acquire_seq_cst_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_acquire_seq_cst_weak:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new acquire seq_cst, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_release_monotonic(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_release_monotonic:
+; CHECK: caslh w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new release monotonic, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_release_monotonic_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_release_monotonic_weak:
+; CHECK: caslh w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new release monotonic, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_release_acquire(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_release_acquire:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new release acquire, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_release_acquire_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_release_acquire_weak:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new release acquire, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_release_seq_cst(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_release_seq_cst:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new release seq_cst, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_release_seq_cst_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_release_seq_cst_weak:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new release seq_cst, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_acq_rel_monotonic(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_acq_rel_monotonic:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new acq_rel monotonic, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_acq_rel_monotonic_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_acq_rel_monotonic_weak:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new acq_rel monotonic, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_acq_rel_acquire(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_acq_rel_acquire:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new acq_rel acquire, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_acq_rel_acquire_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_acq_rel_acquire_weak:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new acq_rel acquire, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_acq_rel_seq_cst(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_acq_rel_seq_cst:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new acq_rel seq_cst, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_acq_rel_seq_cst_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_acq_rel_seq_cst_weak:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new acq_rel seq_cst, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_seq_cst_monotonic(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_seq_cst_monotonic:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new seq_cst monotonic, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_seq_cst_monotonic_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_seq_cst_monotonic_weak:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new seq_cst monotonic, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_seq_cst_acquire(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_seq_cst_acquire:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new seq_cst acquire, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_seq_cst_acquire_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_seq_cst_acquire_weak:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new seq_cst acquire, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_seq_cst_seq_cst(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_seq_cst_seq_cst:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new seq_cst seq_cst, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_aligned_seq_cst_seq_cst_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_aligned_seq_cst_seq_cst_weak:
+; CHECK: casalh w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new seq_cst seq_cst, align 2
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_monotonic_monotonic(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_monotonic_monotonic:
+; CHECK: cas w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new monotonic monotonic, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_monotonic_monotonic_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_monotonic_monotonic_weak:
+; CHECK: cas w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new monotonic monotonic, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_monotonic_acquire(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_monotonic_acquire:
+; CHECK: casa w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new monotonic acquire, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_monotonic_acquire_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_monotonic_acquire_weak:
+; CHECK: casa w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new monotonic acquire, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_monotonic_seq_cst(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_monotonic_seq_cst:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new monotonic seq_cst, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_monotonic_seq_cst_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_monotonic_seq_cst_weak:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new monotonic seq_cst, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_acquire_monotonic(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_acquire_monotonic:
+; CHECK: casa w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new acquire monotonic, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_acquire_monotonic_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_acquire_monotonic_weak:
+; CHECK: casa w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new acquire monotonic, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_acquire_acquire(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_acquire_acquire:
+; CHECK: casa w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new acquire acquire, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_acquire_acquire_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_acquire_acquire_weak:
+; CHECK: casa w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new acquire acquire, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_acquire_seq_cst(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_acquire_seq_cst:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new acquire seq_cst, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_acquire_seq_cst_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_acquire_seq_cst_weak:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new acquire seq_cst, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_release_monotonic(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_release_monotonic:
+; CHECK: casl w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new release monotonic, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_release_monotonic_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_release_monotonic_weak:
+; CHECK: casl w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new release monotonic, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_release_acquire(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_release_acquire:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new release acquire, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_release_acquire_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_release_acquire_weak:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new release acquire, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_release_seq_cst(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_release_seq_cst:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new release seq_cst, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_release_seq_cst_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_release_seq_cst_weak:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new release seq_cst, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_acq_rel_monotonic(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_acq_rel_monotonic:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new acq_rel monotonic, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_acq_rel_monotonic_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_acq_rel_monotonic_weak:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new acq_rel monotonic, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_acq_rel_acquire(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_acq_rel_acquire:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new acq_rel acquire, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_acq_rel_acquire_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_acq_rel_acquire_weak:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new acq_rel acquire, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_acq_rel_seq_cst(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_acq_rel_seq_cst:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new acq_rel seq_cst, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_acq_rel_seq_cst_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_acq_rel_seq_cst_weak:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new acq_rel seq_cst, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_seq_cst_monotonic(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_seq_cst_monotonic:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new seq_cst monotonic, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_seq_cst_monotonic_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_seq_cst_monotonic_weak:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new seq_cst monotonic, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_seq_cst_acquire(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_seq_cst_acquire:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new seq_cst acquire, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_seq_cst_acquire_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_seq_cst_acquire_weak:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new seq_cst acquire, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_seq_cst_seq_cst(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_seq_cst_seq_cst:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new seq_cst seq_cst, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_aligned_seq_cst_seq_cst_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_aligned_seq_cst_seq_cst_weak:
+; CHECK: casal w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new seq_cst seq_cst, align 4
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_monotonic_monotonic(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_monotonic_monotonic:
+; CHECK: cas x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new monotonic monotonic, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_monotonic_monotonic_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_monotonic_monotonic_weak:
+; CHECK: cas x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new monotonic monotonic, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_monotonic_acquire(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_monotonic_acquire:
+; CHECK: casa x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new monotonic acquire, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_monotonic_acquire_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_monotonic_acquire_weak:
+; CHECK: casa x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new monotonic acquire, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_monotonic_seq_cst(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_monotonic_seq_cst:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new monotonic seq_cst, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_monotonic_seq_cst_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_monotonic_seq_cst_weak:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new monotonic seq_cst, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_acquire_monotonic(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_acquire_monotonic:
+; CHECK: casa x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new acquire monotonic, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_acquire_monotonic_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_acquire_monotonic_weak:
+; CHECK: casa x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new acquire monotonic, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_acquire_acquire(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_acquire_acquire:
+; CHECK: casa x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new acquire acquire, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_acquire_acquire_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_acquire_acquire_weak:
+; CHECK: casa x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new acquire acquire, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_acquire_seq_cst(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_acquire_seq_cst:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new acquire seq_cst, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_acquire_seq_cst_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_acquire_seq_cst_weak:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new acquire seq_cst, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_release_monotonic(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_release_monotonic:
+; CHECK: casl x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new release monotonic, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_release_monotonic_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_release_monotonic_weak:
+; CHECK: casl x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new release monotonic, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_release_acquire(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_release_acquire:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new release acquire, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_release_acquire_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_release_acquire_weak:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new release acquire, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_release_seq_cst(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_release_seq_cst:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new release seq_cst, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_release_seq_cst_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_release_seq_cst_weak:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new release seq_cst, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_acq_rel_monotonic(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_acq_rel_monotonic:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new acq_rel monotonic, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_acq_rel_monotonic_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_acq_rel_monotonic_weak:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new acq_rel monotonic, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_acq_rel_acquire(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_acq_rel_acquire:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new acq_rel acquire, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_acq_rel_acquire_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_acq_rel_acquire_weak:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new acq_rel acquire, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_acq_rel_seq_cst(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_acq_rel_seq_cst:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new acq_rel seq_cst, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_acq_rel_seq_cst_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_acq_rel_seq_cst_weak:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new acq_rel seq_cst, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_seq_cst_monotonic(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_seq_cst_monotonic:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new seq_cst monotonic, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_seq_cst_monotonic_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_seq_cst_monotonic_weak:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new seq_cst monotonic, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_seq_cst_acquire(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_seq_cst_acquire:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new seq_cst acquire, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_seq_cst_acquire_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_seq_cst_acquire_weak:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new seq_cst acquire, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_seq_cst_seq_cst(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_seq_cst_seq_cst:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new seq_cst seq_cst, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_aligned_seq_cst_seq_cst_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_aligned_seq_cst_seq_cst_weak:
+; CHECK: casal x0, x1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new seq_cst seq_cst, align 8
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_monotonic_monotonic(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_monotonic_monotonic:
+; -O0: casp x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_monotonic_monotonic:
+; -O1: casp x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new monotonic monotonic, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_monotonic_monotonic_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_monotonic_monotonic_weak:
+; -O0: casp x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_monotonic_monotonic_weak:
+; -O1: casp x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new monotonic monotonic, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_monotonic_acquire(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_monotonic_acquire:
+; -O0: caspa x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_monotonic_acquire:
+; -O1: caspa x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new monotonic acquire, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_monotonic_acquire_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_monotonic_acquire_weak:
+; -O0: caspa x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_monotonic_acquire_weak:
+; -O1: caspa x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new monotonic acquire, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_monotonic_seq_cst(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_monotonic_seq_cst:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_monotonic_seq_cst:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new monotonic seq_cst, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_monotonic_seq_cst_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_monotonic_seq_cst_weak:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_monotonic_seq_cst_weak:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new monotonic seq_cst, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_acquire_monotonic(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_acquire_monotonic:
+; -O0: caspa x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_acquire_monotonic:
+; -O1: caspa x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new acquire monotonic, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_acquire_monotonic_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_acquire_monotonic_weak:
+; -O0: caspa x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_acquire_monotonic_weak:
+; -O1: caspa x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new acquire monotonic, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_acquire_acquire(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_acquire_acquire:
+; -O0: caspa x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_acquire_acquire:
+; -O1: caspa x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new acquire acquire, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_acquire_acquire_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_acquire_acquire_weak:
+; -O0: caspa x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_acquire_acquire_weak:
+; -O1: caspa x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new acquire acquire, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_acquire_seq_cst(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_acquire_seq_cst:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_acquire_seq_cst:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new acquire seq_cst, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_acquire_seq_cst_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_acquire_seq_cst_weak:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_acquire_seq_cst_weak:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new acquire seq_cst, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_release_monotonic(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_release_monotonic:
+; -O0: caspl x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_release_monotonic:
+; -O1: caspl x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new release monotonic, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_release_monotonic_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_release_monotonic_weak:
+; -O0: caspl x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_release_monotonic_weak:
+; -O1: caspl x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new release monotonic, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_release_acquire(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_release_acquire:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_release_acquire:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new release acquire, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_release_acquire_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_release_acquire_weak:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_release_acquire_weak:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new release acquire, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_release_seq_cst(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_release_seq_cst:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_release_seq_cst:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new release seq_cst, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_release_seq_cst_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_release_seq_cst_weak:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_release_seq_cst_weak:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new release seq_cst, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_acq_rel_monotonic(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_acq_rel_monotonic:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_acq_rel_monotonic:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new acq_rel monotonic, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_acq_rel_monotonic_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_acq_rel_monotonic_weak:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_acq_rel_monotonic_weak:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new acq_rel monotonic, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_acq_rel_acquire(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_acq_rel_acquire:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_acq_rel_acquire:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new acq_rel acquire, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_acq_rel_acquire_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_acq_rel_acquire_weak:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_acq_rel_acquire_weak:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new acq_rel acquire, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_acq_rel_seq_cst(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_acq_rel_seq_cst:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_acq_rel_seq_cst:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new acq_rel seq_cst, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_acq_rel_seq_cst_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_acq_rel_seq_cst_weak:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_acq_rel_seq_cst_weak:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new acq_rel seq_cst, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_seq_cst_monotonic(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_seq_cst_monotonic:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_seq_cst_monotonic:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new seq_cst monotonic, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_seq_cst_monotonic_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_seq_cst_monotonic_weak:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_seq_cst_monotonic_weak:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new seq_cst monotonic, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_seq_cst_acquire(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_seq_cst_acquire:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_seq_cst_acquire:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new seq_cst acquire, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_seq_cst_acquire_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_seq_cst_acquire_weak:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_seq_cst_acquire_weak:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new seq_cst acquire, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_seq_cst_seq_cst(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_seq_cst_seq_cst:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_seq_cst_seq_cst:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new seq_cst seq_cst, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_aligned_seq_cst_seq_cst_weak(i128 %expected, i128 %new, ptr %ptr) {
+; -O0-LABEL: cmpxchg_i128_aligned_seq_cst_seq_cst_weak:
+; -O0: caspal x2, x3, x0, x1, [x4]
+;
+; -O1-LABEL: cmpxchg_i128_aligned_seq_cst_seq_cst_weak:
+; -O1: caspal x0, x1, x2, x3, [x4]
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new seq_cst seq_cst, align 16
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_monotonic_monotonic(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_monotonic_monotonic:
+; CHECK: casb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new monotonic monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_monotonic_monotonic_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_monotonic_monotonic_weak:
+; CHECK: casb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new monotonic monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_monotonic_acquire(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_monotonic_acquire:
+; CHECK: casab w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new monotonic acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_monotonic_acquire_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_monotonic_acquire_weak:
+; CHECK: casab w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new monotonic acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_monotonic_seq_cst(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_monotonic_seq_cst:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new monotonic seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_monotonic_seq_cst_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_monotonic_seq_cst_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new monotonic seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_acquire_monotonic(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_acquire_monotonic:
+; CHECK: casab w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new acquire monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_acquire_monotonic_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_acquire_monotonic_weak:
+; CHECK: casab w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new acquire monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_acquire_acquire(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_acquire_acquire:
+; CHECK: casab w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new acquire acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_acquire_acquire_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_acquire_acquire_weak:
+; CHECK: casab w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new acquire acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_acquire_seq_cst(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_acquire_seq_cst:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new acquire seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_acquire_seq_cst_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_acquire_seq_cst_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new acquire seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_release_monotonic(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_release_monotonic:
+; CHECK: caslb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new release monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_release_monotonic_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_release_monotonic_weak:
+; CHECK: caslb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new release monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_release_acquire(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_release_acquire:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new release acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_release_acquire_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_release_acquire_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new release acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_release_seq_cst(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_release_seq_cst:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new release seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_release_seq_cst_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_release_seq_cst_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new release seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_acq_rel_monotonic(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_acq_rel_monotonic:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new acq_rel monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_acq_rel_monotonic_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_acq_rel_monotonic_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new acq_rel monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_acq_rel_acquire(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_acq_rel_acquire:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new acq_rel acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_acq_rel_acquire_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_acq_rel_acquire_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new acq_rel acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_acq_rel_seq_cst(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_acq_rel_seq_cst:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new acq_rel seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_acq_rel_seq_cst_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_acq_rel_seq_cst_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new acq_rel seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_seq_cst_monotonic(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_seq_cst_monotonic:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new seq_cst monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_seq_cst_monotonic_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_seq_cst_monotonic_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new seq_cst monotonic, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_seq_cst_acquire(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_seq_cst_acquire:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new seq_cst acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_seq_cst_acquire_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_seq_cst_acquire_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new seq_cst acquire, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_seq_cst_seq_cst(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_seq_cst_seq_cst:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg ptr %ptr, i8 %expected, i8 %new seq_cst seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i8 @cmpxchg_i8_unaligned_seq_cst_seq_cst_weak(i8 %expected, i8 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i8_unaligned_seq_cst_seq_cst_weak:
+; CHECK: casalb w0, w1, [x2]
+ %pair = cmpxchg weak ptr %ptr, i8 %expected, i8 %new seq_cst seq_cst, align 1
+ %r = extractvalue { i8, i1 } %pair, 0
+ ret i8 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_monotonic_monotonic(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_monotonic_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new monotonic monotonic, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_monotonic_monotonic_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_monotonic_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new monotonic monotonic, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_monotonic_acquire(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_monotonic_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new monotonic acquire, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_monotonic_acquire_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_monotonic_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new monotonic acquire, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_monotonic_seq_cst(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_monotonic_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new monotonic seq_cst, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_monotonic_seq_cst_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_monotonic_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new monotonic seq_cst, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_acquire_monotonic(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_acquire_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new acquire monotonic, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_acquire_monotonic_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_acquire_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new acquire monotonic, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_acquire_acquire(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_acquire_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new acquire acquire, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_acquire_acquire_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_acquire_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new acquire acquire, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_acquire_seq_cst(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_acquire_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new acquire seq_cst, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_acquire_seq_cst_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_acquire_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new acquire seq_cst, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_release_monotonic(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_release_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new release monotonic, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_release_monotonic_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_release_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new release monotonic, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_release_acquire(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_release_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new release acquire, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_release_acquire_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_release_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new release acquire, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_release_seq_cst(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_release_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new release seq_cst, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_release_seq_cst_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_release_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new release seq_cst, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_acq_rel_monotonic(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_acq_rel_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new acq_rel monotonic, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_acq_rel_monotonic_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_acq_rel_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new acq_rel monotonic, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_acq_rel_acquire(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_acq_rel_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new acq_rel acquire, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_acq_rel_acquire_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_acq_rel_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new acq_rel acquire, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_acq_rel_seq_cst(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_acq_rel_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new acq_rel seq_cst, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_acq_rel_seq_cst_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_acq_rel_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new acq_rel seq_cst, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_seq_cst_monotonic(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_seq_cst_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new seq_cst monotonic, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_seq_cst_monotonic_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_seq_cst_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new seq_cst monotonic, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_seq_cst_acquire(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_seq_cst_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new seq_cst acquire, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_seq_cst_acquire_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_seq_cst_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new seq_cst acquire, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_seq_cst_seq_cst(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_seq_cst_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i16 %expected, i16 %new seq_cst seq_cst, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i16 @cmpxchg_i16_unaligned_seq_cst_seq_cst_weak(i16 %expected, i16 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i16_unaligned_seq_cst_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i16 %expected, i16 %new seq_cst seq_cst, align 1
+ %r = extractvalue { i16, i1 } %pair, 0
+ ret i16 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_monotonic_monotonic(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_monotonic_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new monotonic monotonic, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_monotonic_monotonic_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_monotonic_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new monotonic monotonic, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_monotonic_acquire(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_monotonic_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new monotonic acquire, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_monotonic_acquire_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_monotonic_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new monotonic acquire, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_monotonic_seq_cst(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_monotonic_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new monotonic seq_cst, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_monotonic_seq_cst_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_monotonic_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new monotonic seq_cst, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_acquire_monotonic(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_acquire_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new acquire monotonic, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_acquire_monotonic_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_acquire_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new acquire monotonic, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_acquire_acquire(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_acquire_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new acquire acquire, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_acquire_acquire_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_acquire_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new acquire acquire, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_acquire_seq_cst(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_acquire_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new acquire seq_cst, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_acquire_seq_cst_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_acquire_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new acquire seq_cst, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_release_monotonic(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_release_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new release monotonic, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_release_monotonic_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_release_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new release monotonic, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_release_acquire(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_release_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new release acquire, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_release_acquire_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_release_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new release acquire, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_release_seq_cst(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_release_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new release seq_cst, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_release_seq_cst_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_release_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new release seq_cst, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_acq_rel_monotonic(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_acq_rel_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new acq_rel monotonic, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_acq_rel_monotonic_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_acq_rel_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new acq_rel monotonic, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_acq_rel_acquire(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_acq_rel_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new acq_rel acquire, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_acq_rel_acquire_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_acq_rel_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new acq_rel acquire, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_acq_rel_seq_cst(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_acq_rel_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new acq_rel seq_cst, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_acq_rel_seq_cst_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_acq_rel_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new acq_rel seq_cst, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_seq_cst_monotonic(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_seq_cst_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new seq_cst monotonic, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_seq_cst_monotonic_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_seq_cst_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new seq_cst monotonic, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_seq_cst_acquire(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_seq_cst_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new seq_cst acquire, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_seq_cst_acquire_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_seq_cst_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new seq_cst acquire, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_seq_cst_seq_cst(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_seq_cst_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i32 %expected, i32 %new seq_cst seq_cst, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i32 @cmpxchg_i32_unaligned_seq_cst_seq_cst_weak(i32 %expected, i32 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i32_unaligned_seq_cst_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i32 %expected, i32 %new seq_cst seq_cst, align 1
+ %r = extractvalue { i32, i1 } %pair, 0
+ ret i32 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_monotonic_monotonic(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_monotonic_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new monotonic monotonic, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_monotonic_monotonic_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_monotonic_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new monotonic monotonic, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_monotonic_acquire(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_monotonic_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new monotonic acquire, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_monotonic_acquire_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_monotonic_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new monotonic acquire, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_monotonic_seq_cst(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_monotonic_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new monotonic seq_cst, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_monotonic_seq_cst_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_monotonic_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new monotonic seq_cst, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_acquire_monotonic(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_acquire_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new acquire monotonic, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_acquire_monotonic_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_acquire_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new acquire monotonic, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_acquire_acquire(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_acquire_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new acquire acquire, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_acquire_acquire_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_acquire_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new acquire acquire, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_acquire_seq_cst(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_acquire_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new acquire seq_cst, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_acquire_seq_cst_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_acquire_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new acquire seq_cst, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_release_monotonic(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_release_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new release monotonic, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_release_monotonic_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_release_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new release monotonic, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_release_acquire(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_release_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new release acquire, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_release_acquire_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_release_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new release acquire, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_release_seq_cst(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_release_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new release seq_cst, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_release_seq_cst_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_release_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new release seq_cst, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_acq_rel_monotonic(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_acq_rel_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new acq_rel monotonic, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_acq_rel_monotonic_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_acq_rel_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new acq_rel monotonic, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_acq_rel_acquire(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_acq_rel_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new acq_rel acquire, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_acq_rel_acquire_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_acq_rel_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new acq_rel acquire, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_acq_rel_seq_cst(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_acq_rel_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new acq_rel seq_cst, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_acq_rel_seq_cst_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_acq_rel_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new acq_rel seq_cst, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_seq_cst_monotonic(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_seq_cst_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new seq_cst monotonic, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_seq_cst_monotonic_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_seq_cst_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new seq_cst monotonic, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_seq_cst_acquire(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_seq_cst_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new seq_cst acquire, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_seq_cst_acquire_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_seq_cst_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new seq_cst acquire, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_seq_cst_seq_cst(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_seq_cst_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i64 %expected, i64 %new seq_cst seq_cst, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i64 @cmpxchg_i64_unaligned_seq_cst_seq_cst_weak(i64 %expected, i64 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i64_unaligned_seq_cst_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i64 %expected, i64 %new seq_cst seq_cst, align 1
+ %r = extractvalue { i64, i1 } %pair, 0
+ ret i64 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_monotonic_monotonic(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_monotonic_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new monotonic monotonic, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_monotonic_monotonic_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_monotonic_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new monotonic monotonic, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_monotonic_acquire(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_monotonic_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new monotonic acquire, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_monotonic_acquire_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_monotonic_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new monotonic acquire, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_monotonic_seq_cst(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_monotonic_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new monotonic seq_cst, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_monotonic_seq_cst_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_monotonic_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new monotonic seq_cst, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_acquire_monotonic(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_acquire_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new acquire monotonic, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_acquire_monotonic_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_acquire_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new acquire monotonic, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_acquire_acquire(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_acquire_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new acquire acquire, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_acquire_acquire_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_acquire_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new acquire acquire, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_acquire_seq_cst(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_acquire_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new acquire seq_cst, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_acquire_seq_cst_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_acquire_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new acquire seq_cst, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_release_monotonic(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_release_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new release monotonic, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_release_monotonic_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_release_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new release monotonic, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_release_acquire(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_release_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new release acquire, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_release_acquire_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_release_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new release acquire, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_release_seq_cst(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_release_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new release seq_cst, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_release_seq_cst_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_release_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new release seq_cst, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_acq_rel_monotonic(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_acq_rel_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new acq_rel monotonic, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_acq_rel_monotonic_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_acq_rel_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new acq_rel monotonic, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_acq_rel_acquire(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_acq_rel_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new acq_rel acquire, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_acq_rel_acquire_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_acq_rel_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new acq_rel acquire, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_acq_rel_seq_cst(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_acq_rel_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new acq_rel seq_cst, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_acq_rel_seq_cst_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_acq_rel_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new acq_rel seq_cst, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_seq_cst_monotonic(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_seq_cst_monotonic:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new seq_cst monotonic, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_seq_cst_monotonic_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_seq_cst_monotonic_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new seq_cst monotonic, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_seq_cst_acquire(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_seq_cst_acquire:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new seq_cst acquire, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_seq_cst_acquire_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_seq_cst_acquire_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new seq_cst acquire, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_seq_cst_seq_cst(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_seq_cst_seq_cst:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg ptr %ptr, i128 %expected, i128 %new seq_cst seq_cst, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
+
+define dso_local i128 @cmpxchg_i128_unaligned_seq_cst_seq_cst_weak(i128 %expected, i128 %new, ptr %ptr) {
+; CHECK-LABEL: cmpxchg_i128_unaligned_seq_cst_seq_cst_weak:
+; CHECK: bl __atomic_compare_exchange
+ %pair = cmpxchg weak ptr %ptr, i128 %expected, i128 %new seq_cst seq_cst, align 1
+ %r = extractvalue { i128, i1 } %pair, 0
+ ret i128 %r
+}
diff --git a/llvm/test/CodeGen/AArch64/Atomics/aarch64_be-fence.ll b/llvm/test/CodeGen/AArch64/Atomics/aarch64_be-fence.ll
index 82c1042c64a5..a63e389745e4 100644
--- a/llvm/test/CodeGen/AArch64/Atomics/aarch64_be-fence.ll
+++ b/llvm/test/CodeGen/AArch64/Atomics/aarch64_be-fence.ll
@@ -14,6 +14,8 @@
; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64_be -mattr=+lse2,+rcpc3 -O1 | FileCheck %s --check-prefixes=CHECK,-O1
; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64_be -mattr=+lse128 -O0 | FileCheck %s --check-prefixes=CHECK,-O0
; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64_be -mattr=+lse128 -O1 | FileCheck %s --check-prefixes=CHECK,-O1
+; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64_be -mattr=+lse2,+lse128 -O0 | FileCheck %s --check-prefixes=CHECK,-O0
+; RUN: llc %s -o - -verify-machineinstrs -mtriple=aarch64_be -mattr=+lse2,+lse128 -O1 | FileCheck %s --check-prefixes=CHECK,-O1
define dso_local void @fence_acquire() {
; CHECK-LABEL: fence_acquire:
diff --git a/llvm/test/CodeGen/AArch64/Atomics/generate-tests.py b/llvm/test/CodeGen/AArch64/Atomics/generate-tests.py
index d0bc0a043520..02e51d23b67d 100755
--- a/llvm/test/CodeGen/AArch64/Atomics/generate-tests.py
+++ b/llvm/test/CodeGen/AArch64/Atomics/generate-tests.py
@@ -113,6 +113,7 @@ class Feature(enum.Flag):
outline_atomics = enum.auto() # -moutline-atomics
rcpc3 = enum.auto() # FEAT_LSE2 + FEAT_LRCPC3
lse128 = enum.auto() # FEAT_LSE128
+ lse2_lse128 = enum.auto() # FEAT_LSE2 + FEAT_LSE128
@property
def mattr(self):
@@ -122,6 +123,8 @@ def mattr(self):
return '+v8.1a'
if self == Feature.rcpc3:
return '+lse2,+rcpc3'
+ if self == Feature.lse2_lse128:
+ return '+lse2,+lse128'
return '+' + self.name
More information about the llvm-commits
mailing list