Skip to content

AArch64/ARM/PPC/X86: Add some atomic tests #92933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions llvm/test/CodeGen/AArch64/Atomics/aarch64-atomic-load-lse2.ll
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,119 @@ define dso_local i128 @load_atomic_i128_unaligned_seq_cst_const(ptr readonly %pt
%r = load atomic i128, ptr %ptr seq_cst, align 1
ret i128 %r
}

define dso_local half @load_atomic_f16_aligned_unordered(ptr %ptr) {
; CHECK-LABEL: load_atomic_f16_aligned_unordered:
; CHECK: ldrh w8, [x0]
%r = load atomic half, ptr %ptr unordered, align 2
ret half %r
}

define dso_local half @load_atomic_f16_aligned_unordered_const(ptr readonly %ptr) {
; CHECK-LABEL: load_atomic_f16_aligned_unordered_const:
; CHECK: ldrh w8, [x0]
%r = load atomic half, ptr %ptr unordered, align 2
ret half %r
}

define dso_local half @load_atomic_f16_aligned_monotonic(ptr %ptr) {
; CHECK-LABEL: load_atomic_f16_aligned_monotonic:
; CHECK: ldrh w8, [x0]
%r = load atomic half, ptr %ptr monotonic, align 2
ret half %r
}

define dso_local half @load_atomic_f16_aligned_monotonic_const(ptr readonly %ptr) {
; CHECK-LABEL: load_atomic_f16_aligned_monotonic_const:
; CHECK: ldrh w8, [x0]
%r = load atomic half, ptr %ptr monotonic, align 2
ret half %r
}

define dso_local half @load_atomic_f16_aligned_acquire(ptr %ptr) {
; CHECK-LABEL: load_atomic_f16_aligned_acquire:
; CHECK: ldarh w8, [x0]
%r = load atomic half, ptr %ptr acquire, align 2
ret half %r
}

define dso_local half @load_atomic_f16_aligned_acquire_const(ptr readonly %ptr) {
; CHECK-LABEL: load_atomic_f16_aligned_acquire_const:
; CHECK: ldarh w8, [x0]
%r = load atomic half, ptr %ptr acquire, align 2
ret half %r
}

define dso_local half @load_atomic_f16_aligned_seq_cst(ptr %ptr) {
; CHECK-LABEL: load_atomic_f16_aligned_seq_cst:
; CHECK: ldarh w8, [x0]
%r = load atomic half, ptr %ptr seq_cst, align 2
ret half %r
}

define dso_local half @load_atomic_f16_aligned_seq_cst_const(ptr readonly %ptr) {
; CHECK-LABEL: load_atomic_f16_aligned_seq_cst_const:
; CHECK: ldarh w8, [x0]
%r = load atomic half, ptr %ptr seq_cst, align 2
ret half %r
}

define dso_local bfloat @load_atomic_bf16_aligned_unordered(ptr %ptr) {
; CHECK-LABEL: load_atomic_bf16_aligned_unordered:
; CHECK: ldrh w8, [x0]
%r = load atomic bfloat, ptr %ptr unordered, align 2
ret bfloat %r
}

define dso_local bfloat @load_atomic_bf16_aligned_unordered_const(ptr readonly %ptr) {
; CHECK-LABEL: load_atomic_bf16_aligned_unordered_const:
; CHECK: ldrh w8, [x0]
%r = load atomic bfloat, ptr %ptr unordered, align 2
ret bfloat %r
}

define dso_local bfloat @load_atomic_bf16_aligned_monotonic(ptr %ptr) {
; CHECK-LABEL: load_atomic_bf16_aligned_monotonic:
; CHECK: ldrh w8, [x0]
%r = load atomic bfloat, ptr %ptr monotonic, align 2
ret bfloat %r
}

define dso_local bfloat @load_atomic_bf16_aligned_monotonic_const(ptr readonly %ptr) {
; CHECK-LABEL: load_atomic_bf16_aligned_monotonic_const:
; CHECK: ldrh w8, [x0]
%r = load atomic bfloat, ptr %ptr monotonic, align 2
ret bfloat %r
}

define dso_local bfloat @load_atomic_bf16_aligned_acquire(ptr %ptr) {
; CHECK-LABEL: load_atomic_bf16_aligned_acquire:
; CHECK: ldarh w8, [x0]
%r = load atomic bfloat, ptr %ptr acquire, align 2
ret bfloat %r
}

define dso_local bfloat @load_atomic_bf16_aligned_acquire_const(ptr readonly %ptr) {
; CHECK-LABEL: load_atomic_bf16_aligned_acquire_const:
; CHECK: ldarh w8, [x0]
%r = load atomic bfloat, ptr %ptr acquire, align 2
ret bfloat %r
}

define dso_local bfloat @load_atomic_bf16_aligned_seq_cst(ptr %ptr) {
; CHECK-LABEL: load_atomic_bf16_aligned_seq_cst:
; CHECK: ldarh w8, [x0]
%r = load atomic bfloat, ptr %ptr seq_cst, align 2
ret bfloat %r
}

define dso_local bfloat @load_atomic_bf16_aligned_seq_cst_const(ptr readonly %ptr) {
; CHECK-LABEL: load_atomic_bf16_aligned_seq_cst_const:
; CHECK: ldarh w8, [x0]
%r = load atomic bfloat, ptr %ptr seq_cst, align 2
ret bfloat %r
}

;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
; -O0: {{.*}}
; -O1: {{.*}}
90 changes: 90 additions & 0 deletions llvm/test/CodeGen/AArch64/relaxed-fp-atomics.ll
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,94 @@ define void @atomic_store_relaxed_f64(ptr %p, i32 %off32, i64 %off64, double %va
ret void
}

define half @atomic_load_relaxed_f16(ptr %p, i32 %off32, i64 %off64) #0 {
; CHECK-LABEL: atomic_load_relaxed_f16:
%ptr_unsigned = getelementptr half, ptr %p, i32 4095
%val_unsigned = load atomic half, ptr %ptr_unsigned monotonic, align 4
; CHECK: ldrh {{w[0-9]+}}, [x0, #8190]

%ptr_regoff = getelementptr half, ptr %p, i32 %off32
%val_regoff = load atomic half, ptr %ptr_regoff unordered, align 4
%tot1 = fadd half %val_unsigned, %val_regoff
; CHECK: ldrh {{w[0-9]+}}, [x0, w1, sxtw #1]

%ptr_regoff64 = getelementptr half, ptr %p, i64 %off64
%val_regoff64 = load atomic half, ptr %ptr_regoff64 monotonic, align 4
%tot2 = fadd half %tot1, %val_regoff64
; CHECK: ldrh {{w[0-9]+}}, [x0, x2, lsl #1]

%ptr_unscaled = getelementptr half, ptr %p, i32 -64
%val_unscaled = load atomic half, ptr %ptr_unscaled unordered, align 4
%tot3 = fadd half %tot2, %val_unscaled
; CHECK: ldurh {{w[0-9]+}}, [x0, #-128]

ret half %tot3
}

define bfloat @atomic_load_relaxed_bf16(ptr %p, i32 %off32, i64 %off64) #0 {
; CHECK-LABEL: atomic_load_relaxed_bf16:
%ptr_unsigned = getelementptr bfloat, ptr %p, i32 4095
%val_unsigned = load atomic bfloat, ptr %ptr_unsigned monotonic, align 4
; CHECK: ldrh {{w[0-9]+}}, [x0, #8190]

%ptr_regoff = getelementptr bfloat, ptr %p, i32 %off32
%val_regoff = load atomic bfloat, ptr %ptr_regoff unordered, align 4
%tot1 = fadd bfloat %val_unsigned, %val_regoff
; CHECK: ldrh {{w[0-9]+}}, [x0, w1, sxtw #1]

%ptr_regoff64 = getelementptr bfloat, ptr %p, i64 %off64
%val_regoff64 = load atomic bfloat, ptr %ptr_regoff64 monotonic, align 4
%tot2 = fadd bfloat %tot1, %val_regoff64
; CHECK: ldrh {{w[0-9]+}}, [x0, x2, lsl #1]

%ptr_unscaled = getelementptr bfloat, ptr %p, i32 -64
%val_unscaled = load atomic bfloat, ptr %ptr_unscaled unordered, align 4
%tot3 = fadd bfloat %tot2, %val_unscaled
; CHECK: ldurh {{w[0-9]+}}, [x0, #-128]

ret bfloat %tot3
}

define void @atomic_store_relaxed_f16(ptr %p, i32 %off32, i64 %off64, half %val) #0 {
; CHECK-LABEL: atomic_store_relaxed_f16:
%ptr_unsigned = getelementptr half, ptr %p, i32 4095
store atomic half %val, ptr %ptr_unsigned monotonic, align 4
; CHECK: strh {{w[0-9]+}}, [x0, #8190]

%ptr_regoff = getelementptr half, ptr %p, i32 %off32
store atomic half %val, ptr %ptr_regoff unordered, align 4
; CHECK: strh {{w[0-9]+}}, [x0, w1, sxtw #1]

%ptr_regoff64 = getelementptr half, ptr %p, i64 %off64
store atomic half %val, ptr %ptr_regoff64 monotonic, align 4
; CHECK: strh {{w[0-9]+}}, [x0, x2, lsl #1]

%ptr_unscaled = getelementptr half, ptr %p, i32 -64
store atomic half %val, ptr %ptr_unscaled unordered, align 4
; CHECK: sturh {{w[0-9]+}}, [x0, #-128]

ret void
}

define void @atomic_store_relaxed_bf16(ptr %p, i32 %off32, i64 %off64, bfloat %val) #0 {
; CHECK-LABEL: atomic_store_relaxed_bf16:
%ptr_unsigned = getelementptr bfloat, ptr %p, i32 4095
store atomic bfloat %val, ptr %ptr_unsigned monotonic, align 4
; CHECK: strh {{w[0-9]+}}, [x0, #8190]

%ptr_regoff = getelementptr bfloat, ptr %p, i32 %off32
store atomic bfloat %val, ptr %ptr_regoff unordered, align 4
; CHECK: strh {{w[0-9]+}}, [x0, w1, sxtw #1]

%ptr_regoff64 = getelementptr bfloat, ptr %p, i64 %off64
store atomic bfloat %val, ptr %ptr_regoff64 monotonic, align 4
; CHECK: strh {{w[0-9]+}}, [x0, x2, lsl #1]

%ptr_unscaled = getelementptr bfloat, ptr %p, i32 -64
store atomic bfloat %val, ptr %ptr_unscaled unordered, align 4
; CHECK: sturh {{w[0-9]+}}, [x0, #-128]

ret void
}

attributes #0 = { nounwind }
Loading
Loading