Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[AArch64][llvm] Pre-commit tests for #137703 (NFC) #137702

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 2 commits into from
Apr 30, 2025

Conversation

jthackray
Copy link
Contributor

Add pre-commit tests for lowering atomicrmw fminimum/fmaximum to AArch64 assembler, in a subsequent change.

@llvmbot
Copy link
Member

llvmbot commented Apr 28, 2025

@llvm/pr-subscribers-backend-aarch64

Author: Jonathan Thackray (jthackray)

Changes

Add pre-commit tests for lowering atomicrmw fminimum/fmaximum to AArch64 assembler, in a subsequent change.


Patch is 153.26 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/137702.diff

5 Files Affected:

  • (modified) llvm/test/CodeGen/AArch64/Atomics/aarch64-atomicrmw-lsfe.ll (+1204)
  • (modified) llvm/test/CodeGen/AArch64/Atomics/aarch64-atomicrmw-v8a_fp.ll (+960)
  • (modified) llvm/test/CodeGen/AArch64/Atomics/aarch64_be-atomicrmw-lsfe.ll (+1246)
  • (modified) llvm/test/CodeGen/AArch64/Atomics/aarch64_be-atomicrmw-v8a_fp.ll (+990)
  • (modified) llvm/test/CodeGen/AArch64/Atomics/generate-tests.py (+2)
diff --git a/llvm/test/CodeGen/AArch64/Atomics/aarch64-atomicrmw-lsfe.ll b/llvm/test/CodeGen/AArch64/Atomics/aarch64-atomicrmw-lsfe.ll
index ef1f11e71f433..7ee2a0bb19c0e 100644
--- a/llvm/test/CodeGen/AArch64/Atomics/aarch64-atomicrmw-lsfe.ll
+++ b/llvm/test/CodeGen/AArch64/Atomics/aarch64-atomicrmw-lsfe.ll
@@ -1598,3 +1598,1207 @@ define dso_local double @atomicrmw_fmin_double_unaligned_seq_cst(ptr %ptr, doubl
     %r = atomicrmw fmin ptr %ptr, double %value seq_cst, align 1
     ret double %r
 }
+
+define dso_local half @atomicrmw_fmaximum_half_aligned_monotonic(ptr %ptr, half %value) {
+; -O0-LABEL: atomicrmw_fmaximum_half_aligned_monotonic:
+; -O0:    ldaxrh w0, [x9]
+; -O0:    cmp w0, w10, uxth
+; -O0:    stlxrh w8, w11, [x9]
+; -O0:    subs w8, w8, w0, uxth
+;
+; -O1-LABEL: atomicrmw_fmaximum_half_aligned_monotonic:
+; -O1:    ldxrh w8, [x0]
+; -O1:    stxrh w9, w8, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, half %value monotonic, align 2
+    ret half %r
+}
+
+define dso_local void @atomicrmw_fmaximum_half_aligned_monotonic_unused(ptr %ptr, half %value) {
+; -O0-LABEL: atomicrmw_fmaximum_half_aligned_monotonic_unused:
+; -O0:    ldaxrh w0, [x9]
+; -O0:    cmp w0, w10, uxth
+; -O0:    stlxrh w8, w11, [x9]
+; -O0:    subs w8, w8, w0, uxth
+;
+; -O1-LABEL: atomicrmw_fmaximum_half_aligned_monotonic_unused:
+; -O1:    ldxrh w8, [x0]
+; -O1:    stxrh w9, w8, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, half %value monotonic, align 2
+    ret void
+}
+
+define dso_local half @atomicrmw_fmaximum_half_aligned_acquire(ptr %ptr, half %value) {
+; -O0-LABEL: atomicrmw_fmaximum_half_aligned_acquire:
+; -O0:    ldaxrh w0, [x9]
+; -O0:    cmp w0, w10, uxth
+; -O0:    stlxrh w8, w11, [x9]
+; -O0:    subs w8, w8, w0, uxth
+;
+; -O1-LABEL: atomicrmw_fmaximum_half_aligned_acquire:
+; -O1:    ldaxrh w8, [x0]
+; -O1:    stxrh w9, w8, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, half %value acquire, align 2
+    ret half %r
+}
+
+define dso_local half @atomicrmw_fmaximum_half_aligned_release(ptr %ptr, half %value) {
+; -O0-LABEL: atomicrmw_fmaximum_half_aligned_release:
+; -O0:    ldaxrh w0, [x9]
+; -O0:    cmp w0, w10, uxth
+; -O0:    stlxrh w8, w11, [x9]
+; -O0:    subs w8, w8, w0, uxth
+;
+; -O1-LABEL: atomicrmw_fmaximum_half_aligned_release:
+; -O1:    ldxrh w8, [x0]
+; -O1:    stlxrh w9, w8, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, half %value release, align 2
+    ret half %r
+}
+
+define dso_local void @atomicrmw_fmaximum_half_aligned_release_unused(ptr %ptr, half %value) {
+; -O0-LABEL: atomicrmw_fmaximum_half_aligned_release_unused:
+; -O0:    ldaxrh w0, [x9]
+; -O0:    cmp w0, w10, uxth
+; -O0:    stlxrh w8, w11, [x9]
+; -O0:    subs w8, w8, w0, uxth
+;
+; -O1-LABEL: atomicrmw_fmaximum_half_aligned_release_unused:
+; -O1:    ldxrh w8, [x0]
+; -O1:    stlxrh w9, w8, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, half %value release, align 2
+    ret void
+}
+
+define dso_local half @atomicrmw_fmaximum_half_aligned_acq_rel(ptr %ptr, half %value) {
+; -O0-LABEL: atomicrmw_fmaximum_half_aligned_acq_rel:
+; -O0:    ldaxrh w0, [x9]
+; -O0:    cmp w0, w10, uxth
+; -O0:    stlxrh w8, w11, [x9]
+; -O0:    subs w8, w8, w0, uxth
+;
+; -O1-LABEL: atomicrmw_fmaximum_half_aligned_acq_rel:
+; -O1:    ldaxrh w8, [x0]
+; -O1:    stlxrh w9, w8, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, half %value acq_rel, align 2
+    ret half %r
+}
+
+define dso_local half @atomicrmw_fmaximum_half_aligned_seq_cst(ptr %ptr, half %value) {
+; -O0-LABEL: atomicrmw_fmaximum_half_aligned_seq_cst:
+; -O0:    ldaxrh w0, [x9]
+; -O0:    cmp w0, w10, uxth
+; -O0:    stlxrh w8, w11, [x9]
+; -O0:    subs w8, w8, w0, uxth
+;
+; -O1-LABEL: atomicrmw_fmaximum_half_aligned_seq_cst:
+; -O1:    ldaxrh w8, [x0]
+; -O1:    stlxrh w9, w8, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, half %value seq_cst, align 2
+    ret half %r
+}
+
+define dso_local bfloat @atomicrmw_fmaximum_bfloat_aligned_monotonic(ptr %ptr, bfloat %value) {
+; -O0-LABEL: atomicrmw_fmaximum_bfloat_aligned_monotonic:
+; -O0:    add w8, w8, w9
+; -O0:    add w8, w8, w9
+; -O0:    ldaxrh w9, [x11]
+; -O0:    cmp w9, w8, uxth
+; -O0:    stlxrh w10, w12, [x11]
+; -O0:    subs w8, w9, w8, uxth
+; -O0:    subs w8, w8, #1
+;
+; -O1-LABEL: atomicrmw_fmaximum_bfloat_aligned_monotonic:
+; -O1:    ldxrh w9, [x0]
+; -O1:    add w9, w9, w8
+; -O1:    add w9, w10, w9
+; -O1:    stxrh w10, w9, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, bfloat %value monotonic, align 2
+    ret bfloat %r
+}
+
+define dso_local void @atomicrmw_fmaximum_bfloat_aligned_monotonic_unused(ptr %ptr, bfloat %value) {
+; -O0-LABEL: atomicrmw_fmaximum_bfloat_aligned_monotonic_unused:
+; -O0:    add w8, w8, w9
+; -O0:    add w8, w8, w9
+; -O0:    ldaxrh w9, [x11]
+; -O0:    cmp w9, w8, uxth
+; -O0:    stlxrh w10, w12, [x11]
+; -O0:    subs w8, w9, w8, uxth
+; -O0:    subs w8, w8, #1
+;
+; -O1-LABEL: atomicrmw_fmaximum_bfloat_aligned_monotonic_unused:
+; -O1:    ldxrh w9, [x0]
+; -O1:    add w9, w9, w8
+; -O1:    add w9, w10, w9
+; -O1:    stxrh w10, w9, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, bfloat %value monotonic, align 2
+    ret void
+}
+
+define dso_local bfloat @atomicrmw_fmaximum_bfloat_aligned_acquire(ptr %ptr, bfloat %value) {
+; -O0-LABEL: atomicrmw_fmaximum_bfloat_aligned_acquire:
+; -O0:    add w8, w8, w9
+; -O0:    add w8, w8, w9
+; -O0:    ldaxrh w9, [x11]
+; -O0:    cmp w9, w8, uxth
+; -O0:    stlxrh w10, w12, [x11]
+; -O0:    subs w8, w9, w8, uxth
+; -O0:    subs w8, w8, #1
+;
+; -O1-LABEL: atomicrmw_fmaximum_bfloat_aligned_acquire:
+; -O1:    ldaxrh w9, [x0]
+; -O1:    add w9, w9, w8
+; -O1:    add w9, w10, w9
+; -O1:    stxrh w10, w9, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, bfloat %value acquire, align 2
+    ret bfloat %r
+}
+
+define dso_local bfloat @atomicrmw_fmaximum_bfloat_aligned_release(ptr %ptr, bfloat %value) {
+; -O0-LABEL: atomicrmw_fmaximum_bfloat_aligned_release:
+; -O0:    add w8, w8, w9
+; -O0:    add w8, w8, w9
+; -O0:    ldaxrh w9, [x11]
+; -O0:    cmp w9, w8, uxth
+; -O0:    stlxrh w10, w12, [x11]
+; -O0:    subs w8, w9, w8, uxth
+; -O0:    subs w8, w8, #1
+;
+; -O1-LABEL: atomicrmw_fmaximum_bfloat_aligned_release:
+; -O1:    ldxrh w9, [x0]
+; -O1:    add w9, w9, w8
+; -O1:    add w9, w10, w9
+; -O1:    stlxrh w10, w9, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, bfloat %value release, align 2
+    ret bfloat %r
+}
+
+define dso_local void @atomicrmw_fmaximum_bfloat_aligned_release_unused(ptr %ptr, bfloat %value) {
+; -O0-LABEL: atomicrmw_fmaximum_bfloat_aligned_release_unused:
+; -O0:    add w8, w8, w9
+; -O0:    add w8, w8, w9
+; -O0:    ldaxrh w9, [x11]
+; -O0:    cmp w9, w8, uxth
+; -O0:    stlxrh w10, w12, [x11]
+; -O0:    subs w8, w9, w8, uxth
+; -O0:    subs w8, w8, #1
+;
+; -O1-LABEL: atomicrmw_fmaximum_bfloat_aligned_release_unused:
+; -O1:    ldxrh w9, [x0]
+; -O1:    add w9, w9, w8
+; -O1:    add w9, w10, w9
+; -O1:    stlxrh w10, w9, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, bfloat %value release, align 2
+    ret void
+}
+
+define dso_local bfloat @atomicrmw_fmaximum_bfloat_aligned_acq_rel(ptr %ptr, bfloat %value) {
+; -O0-LABEL: atomicrmw_fmaximum_bfloat_aligned_acq_rel:
+; -O0:    add w8, w8, w9
+; -O0:    add w8, w8, w9
+; -O0:    ldaxrh w9, [x11]
+; -O0:    cmp w9, w8, uxth
+; -O0:    stlxrh w10, w12, [x11]
+; -O0:    subs w8, w9, w8, uxth
+; -O0:    subs w8, w8, #1
+;
+; -O1-LABEL: atomicrmw_fmaximum_bfloat_aligned_acq_rel:
+; -O1:    ldaxrh w9, [x0]
+; -O1:    add w9, w9, w8
+; -O1:    add w9, w10, w9
+; -O1:    stlxrh w10, w9, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, bfloat %value acq_rel, align 2
+    ret bfloat %r
+}
+
+define dso_local bfloat @atomicrmw_fmaximum_bfloat_aligned_seq_cst(ptr %ptr, bfloat %value) {
+; -O0-LABEL: atomicrmw_fmaximum_bfloat_aligned_seq_cst:
+; -O0:    add w8, w8, w9
+; -O0:    add w8, w8, w9
+; -O0:    ldaxrh w9, [x11]
+; -O0:    cmp w9, w8, uxth
+; -O0:    stlxrh w10, w12, [x11]
+; -O0:    subs w8, w9, w8, uxth
+; -O0:    subs w8, w8, #1
+;
+; -O1-LABEL: atomicrmw_fmaximum_bfloat_aligned_seq_cst:
+; -O1:    ldaxrh w9, [x0]
+; -O1:    add w9, w9, w8
+; -O1:    add w9, w10, w9
+; -O1:    stlxrh w10, w9, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, bfloat %value seq_cst, align 2
+    ret bfloat %r
+}
+
+define dso_local float @atomicrmw_fmaximum_float_aligned_monotonic(ptr %ptr, float %value) {
+; -O0-LABEL: atomicrmw_fmaximum_float_aligned_monotonic:
+; -O0:    ldaxr w0, [x9]
+; -O0:    cmp w0, w10
+; -O0:    stlxr w8, w11, [x9]
+; -O0:    subs w8, w0, w8
+;
+; -O1-LABEL: atomicrmw_fmaximum_float_aligned_monotonic:
+; -O1:    ldxr w8, [x0]
+; -O1:    stxr w9, w8, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, float %value monotonic, align 4
+    ret float %r
+}
+
+define dso_local void @atomicrmw_fmaximum_float_aligned_monotonic_unused(ptr %ptr, float %value) {
+; -O0-LABEL: atomicrmw_fmaximum_float_aligned_monotonic_unused:
+; -O0:    ldaxr w0, [x9]
+; -O0:    cmp w0, w10
+; -O0:    stlxr w8, w11, [x9]
+; -O0:    subs w8, w0, w8
+;
+; -O1-LABEL: atomicrmw_fmaximum_float_aligned_monotonic_unused:
+; -O1:    ldxr w8, [x0]
+; -O1:    stxr w9, w8, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, float %value monotonic, align 4
+    ret void
+}
+
+define dso_local float @atomicrmw_fmaximum_float_aligned_acquire(ptr %ptr, float %value) {
+; -O0-LABEL: atomicrmw_fmaximum_float_aligned_acquire:
+; -O0:    ldaxr w0, [x9]
+; -O0:    cmp w0, w10
+; -O0:    stlxr w8, w11, [x9]
+; -O0:    subs w8, w0, w8
+;
+; -O1-LABEL: atomicrmw_fmaximum_float_aligned_acquire:
+; -O1:    ldaxr w8, [x0]
+; -O1:    stxr w9, w8, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, float %value acquire, align 4
+    ret float %r
+}
+
+define dso_local float @atomicrmw_fmaximum_float_aligned_release(ptr %ptr, float %value) {
+; -O0-LABEL: atomicrmw_fmaximum_float_aligned_release:
+; -O0:    ldaxr w0, [x9]
+; -O0:    cmp w0, w10
+; -O0:    stlxr w8, w11, [x9]
+; -O0:    subs w8, w0, w8
+;
+; -O1-LABEL: atomicrmw_fmaximum_float_aligned_release:
+; -O1:    ldxr w8, [x0]
+; -O1:    stlxr w9, w8, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, float %value release, align 4
+    ret float %r
+}
+
+define dso_local void @atomicrmw_fmaximum_float_aligned_release_unused(ptr %ptr, float %value) {
+; -O0-LABEL: atomicrmw_fmaximum_float_aligned_release_unused:
+; -O0:    ldaxr w0, [x9]
+; -O0:    cmp w0, w10
+; -O0:    stlxr w8, w11, [x9]
+; -O0:    subs w8, w0, w8
+;
+; -O1-LABEL: atomicrmw_fmaximum_float_aligned_release_unused:
+; -O1:    ldxr w8, [x0]
+; -O1:    stlxr w9, w8, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, float %value release, align 4
+    ret void
+}
+
+define dso_local float @atomicrmw_fmaximum_float_aligned_acq_rel(ptr %ptr, float %value) {
+; -O0-LABEL: atomicrmw_fmaximum_float_aligned_acq_rel:
+; -O0:    ldaxr w0, [x9]
+; -O0:    cmp w0, w10
+; -O0:    stlxr w8, w11, [x9]
+; -O0:    subs w8, w0, w8
+;
+; -O1-LABEL: atomicrmw_fmaximum_float_aligned_acq_rel:
+; -O1:    ldaxr w8, [x0]
+; -O1:    stlxr w9, w8, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, float %value acq_rel, align 4
+    ret float %r
+}
+
+define dso_local float @atomicrmw_fmaximum_float_aligned_seq_cst(ptr %ptr, float %value) {
+; -O0-LABEL: atomicrmw_fmaximum_float_aligned_seq_cst:
+; -O0:    ldaxr w0, [x9]
+; -O0:    cmp w0, w10
+; -O0:    stlxr w8, w11, [x9]
+; -O0:    subs w8, w0, w8
+;
+; -O1-LABEL: atomicrmw_fmaximum_float_aligned_seq_cst:
+; -O1:    ldaxr w8, [x0]
+; -O1:    stlxr w9, w8, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, float %value seq_cst, align 4
+    ret float %r
+}
+
+define dso_local double @atomicrmw_fmaximum_double_aligned_monotonic(ptr %ptr, double %value) {
+; -O0-LABEL: atomicrmw_fmaximum_double_aligned_monotonic:
+; -O0:    ldaxr x0, [x9]
+; -O0:    cmp x0, x10
+; -O0:    stlxr w8, x11, [x9]
+; -O0:    subs x8, x0, x8
+;
+; -O1-LABEL: atomicrmw_fmaximum_double_aligned_monotonic:
+; -O1:    ldxr x8, [x0]
+; -O1:    stxr w9, x8, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, double %value monotonic, align 8
+    ret double %r
+}
+
+define dso_local void @atomicrmw_fmaximum_double_aligned_monotonic_unused(ptr %ptr, double %value) {
+; -O0-LABEL: atomicrmw_fmaximum_double_aligned_monotonic_unused:
+; -O0:    ldaxr x0, [x9]
+; -O0:    cmp x0, x10
+; -O0:    stlxr w8, x11, [x9]
+; -O0:    subs x8, x0, x8
+;
+; -O1-LABEL: atomicrmw_fmaximum_double_aligned_monotonic_unused:
+; -O1:    ldxr x8, [x0]
+; -O1:    stxr w9, x8, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, double %value monotonic, align 8
+    ret void
+}
+
+define dso_local double @atomicrmw_fmaximum_double_aligned_acquire(ptr %ptr, double %value) {
+; -O0-LABEL: atomicrmw_fmaximum_double_aligned_acquire:
+; -O0:    ldaxr x0, [x9]
+; -O0:    cmp x0, x10
+; -O0:    stlxr w8, x11, [x9]
+; -O0:    subs x8, x0, x8
+;
+; -O1-LABEL: atomicrmw_fmaximum_double_aligned_acquire:
+; -O1:    ldaxr x8, [x0]
+; -O1:    stxr w9, x8, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, double %value acquire, align 8
+    ret double %r
+}
+
+define dso_local double @atomicrmw_fmaximum_double_aligned_release(ptr %ptr, double %value) {
+; -O0-LABEL: atomicrmw_fmaximum_double_aligned_release:
+; -O0:    ldaxr x0, [x9]
+; -O0:    cmp x0, x10
+; -O0:    stlxr w8, x11, [x9]
+; -O0:    subs x8, x0, x8
+;
+; -O1-LABEL: atomicrmw_fmaximum_double_aligned_release:
+; -O1:    ldxr x8, [x0]
+; -O1:    stlxr w9, x8, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, double %value release, align 8
+    ret double %r
+}
+
+define dso_local void @atomicrmw_fmaximum_double_aligned_release_unused(ptr %ptr, double %value) {
+; -O0-LABEL: atomicrmw_fmaximum_double_aligned_release_unused:
+; -O0:    ldaxr x0, [x9]
+; -O0:    cmp x0, x10
+; -O0:    stlxr w8, x11, [x9]
+; -O0:    subs x8, x0, x8
+;
+; -O1-LABEL: atomicrmw_fmaximum_double_aligned_release_unused:
+; -O1:    ldxr x8, [x0]
+; -O1:    stlxr w9, x8, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, double %value release, align 8
+    ret void
+}
+
+define dso_local double @atomicrmw_fmaximum_double_aligned_acq_rel(ptr %ptr, double %value) {
+; -O0-LABEL: atomicrmw_fmaximum_double_aligned_acq_rel:
+; -O0:    ldaxr x0, [x9]
+; -O0:    cmp x0, x10
+; -O0:    stlxr w8, x11, [x9]
+; -O0:    subs x8, x0, x8
+;
+; -O1-LABEL: atomicrmw_fmaximum_double_aligned_acq_rel:
+; -O1:    ldaxr x8, [x0]
+; -O1:    stlxr w9, x8, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, double %value acq_rel, align 8
+    ret double %r
+}
+
+define dso_local double @atomicrmw_fmaximum_double_aligned_seq_cst(ptr %ptr, double %value) {
+; -O0-LABEL: atomicrmw_fmaximum_double_aligned_seq_cst:
+; -O0:    ldaxr x0, [x9]
+; -O0:    cmp x0, x10
+; -O0:    stlxr w8, x11, [x9]
+; -O0:    subs x8, x0, x8
+;
+; -O1-LABEL: atomicrmw_fmaximum_double_aligned_seq_cst:
+; -O1:    ldaxr x8, [x0]
+; -O1:    stlxr w9, x8, [x0]
+    %r = atomicrmw fmaximum ptr %ptr, double %value seq_cst, align 8
+    ret double %r
+}
+
+define dso_local half @atomicrmw_fmaximum_half_unaligned_monotonic(ptr %ptr, half %value) {
+; CHECK-LABEL: atomicrmw_fmaximum_half_unaligned_monotonic:
+; CHECK:    bl __atomic_compare_exchange
+    %r = atomicrmw fmaximum ptr %ptr, half %value monotonic, align 1
+    ret half %r
+}
+
+define dso_local half @atomicrmw_fmaximum_half_unaligned_acquire(ptr %ptr, half %value) {
+; CHECK-LABEL: atomicrmw_fmaximum_half_unaligned_acquire:
+; CHECK:    bl __atomic_compare_exchange
+    %r = atomicrmw fmaximum ptr %ptr, half %value acquire, align 1
+    ret half %r
+}
+
+define dso_local half @atomicrmw_fmaximum_half_unaligned_release(ptr %ptr, half %value) {
+; CHECK-LABEL: atomicrmw_fmaximum_half_unaligned_release:
+; CHECK:    bl __atomic_compare_exchange
+    %r = atomicrmw fmaximum ptr %ptr, half %value release, align 1
+    ret half %r
+}
+
+define dso_local half @atomicrmw_fmaximum_half_unaligned_acq_rel(ptr %ptr, half %value) {
+; CHECK-LABEL: atomicrmw_fmaximum_half_unaligned_acq_rel:
+; CHECK:    bl __atomic_compare_exchange
+    %r = atomicrmw fmaximum ptr %ptr, half %value acq_rel, align 1
+    ret half %r
+}
+
+define dso_local half @atomicrmw_fmaximum_half_unaligned_seq_cst(ptr %ptr, half %value) {
+; CHECK-LABEL: atomicrmw_fmaximum_half_unaligned_seq_cst:
+; CHECK:    bl __atomic_compare_exchange
+    %r = atomicrmw fmaximum ptr %ptr, half %value seq_cst, align 1
+    ret half %r
+}
+
+define dso_local bfloat @atomicrmw_fmaximum_bfloat_unaligned_monotonic(ptr %ptr, bfloat %value) {
+; -O0-LABEL: atomicrmw_fmaximum_bfloat_unaligned_monotonic:
+; -O0:    add w8, w8, w9
+; -O0:    add w8, w8, w9
+; -O0:    bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_fmaximum_bfloat_unaligned_monotonic:
+; -O1:    add w8, w8, w20
+; -O1:    add w8, w9, w8
+; -O1:    bl __atomic_compare_exchange
+    %r = atomicrmw fmaximum ptr %ptr, bfloat %value monotonic, align 1
+    ret bfloat %r
+}
+
+define dso_local bfloat @atomicrmw_fmaximum_bfloat_unaligned_acquire(ptr %ptr, bfloat %value) {
+; -O0-LABEL: atomicrmw_fmaximum_bfloat_unaligned_acquire:
+; -O0:    add w8, w8, w9
+; -O0:    add w8, w8, w9
+; -O0:    bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_fmaximum_bfloat_unaligned_acquire:
+; -O1:    add w8, w8, w20
+; -O1:    add w8, w9, w8
+; -O1:    bl __atomic_compare_exchange
+    %r = atomicrmw fmaximum ptr %ptr, bfloat %value acquire, align 1
+    ret bfloat %r
+}
+
+define dso_local bfloat @atomicrmw_fmaximum_bfloat_unaligned_release(ptr %ptr, bfloat %value) {
+; -O0-LABEL: atomicrmw_fmaximum_bfloat_unaligned_release:
+; -O0:    add w8, w8, w9
+; -O0:    add w8, w8, w9
+; -O0:    bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_fmaximum_bfloat_unaligned_release:
+; -O1:    add w8, w8, w20
+; -O1:    add w8, w9, w8
+; -O1:    bl __atomic_compare_exchange
+    %r = atomicrmw fmaximum ptr %ptr, bfloat %value release, align 1
+    ret bfloat %r
+}
+
+define dso_local bfloat @atomicrmw_fmaximum_bfloat_unaligned_acq_rel(ptr %ptr, bfloat %value) {
+; -O0-LABEL: atomicrmw_fmaximum_bfloat_unaligned_acq_rel:
+; -O0:    add w8, w8, w9
+; -O0:    add w8, w8, w9
+; -O0:    bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_fmaximum_bfloat_unaligned_acq_rel:
+; -O1:    add w8, w8, w20
+; -O1:    add w8, w9, w8
+; -O1:    bl __atomic_compare_exchange
+    %r = atomicrmw fmaximum ptr %ptr, bfloat %value acq_rel, align 1
+    ret bfloat %r
+}
+
+define dso_local bfloat @atomicrmw_fmaximum_bfloat_unaligned_seq_cst(ptr %ptr, bfloat %value) {
+; -O0-LABEL: atomicrmw_fmaximum_bfloat_unaligned_seq_cst:
+; -O0:    add w8, w8, w9
+; -O0:    add w8, w8, w9
+; -O0:    bl __atomic_compare_exchange
+;
+; -O1-LABEL: atomicrmw_fmaximum_bfloat_unaligned_seq_cst:
+; -O1:    add w8, w8, w20
+; -O1:    add w8, w9, w8
+; -O1:    bl __atomic_compare_exchange
+    %r = atomicrmw fmaximum ptr %ptr, bfloat %value seq_cst, align 1
+    ret bfloat %r
+}
+
+define dso_local float @atomicrmw_fmaximum_float_unaligned_monotonic(ptr %ptr, float %value) {
+; CHECK-LABEL: atomicrmw_fmaximum_float_unaligned_monotonic:
+; CHECK:    bl __atomic_compare_exchange
+    %r = atomicrmw fmaximum ptr %ptr, float %value monotonic, align 1
+    ret float %r
+}
+
+define dso_local float @atomicrmw_fmaximum_float_unaligned_acquire(ptr %ptr, float %value) {
+; CHECK-LABEL: atomicrmw_fmaximum_float_unaligned_acquire:
+; CHECK:    bl __atomic_compare_exchange
+    %r = atomicrmw fmaximum ptr %ptr, float %value acquire, align 1
+    ret float %r
+}
+
+define dso_local float @atomicrmw_fmaximum_float_unaligned_release(ptr %ptr, float %value) {
+; CHECK-LABEL: atomicrmw_fmaximum_float_unaligned_release:
+; CHECK:    bl __atomic_compare_exchange
+    %r = atomicrmw fmaximum ptr %ptr, float %value release, align 1
+    ret float %r
+}
+
+define dso_local float @atomicrmw_fmaximum_float_unaligned_acq_rel(ptr %ptr, float %value) {
+; CHECK-LABEL: atomicrmw_fmaximum_float_unaligned_acq_rel:
+; CHECK:    bl __atomic_compare_exchange
+    %r = atomicrmw fmaximum ptr %ptr, float %value acq_rel, align 1
+    ret float %r
+}
+
+define dso_local float @atomicrmw_fmaximum_float_unaligned_seq_cst(ptr %ptr, float %value) {
+; CHECK-LABEL: atomicrmw_fmaximum_float_unaligned_seq_cst:
+; CHECK:    bl __atomic_compare_exchange
+    %r = atomicrmw fmaximum ptr %ptr, float %value seq_cst, align 1
+    ret float %r
+}
+
+define dso_local double @atomicrmw_fmaximum_double_unaligned_monotonic(ptr %ptr, double %value) {
+; CHECK-LABEL: atomicrmw_fmaximum_double_unaligned_monotonic:
+; CHECK:    bl __atomic_compare_exchange
+    %r = atomicrmw fmaximum ptr %ptr, double %value monotonic, align 1
+    ret double %r
+}
+
+defin...
[truncated]

@jthackray jthackray changed the title [AArch64][llvm] Pre-commit tests for #xxxxx (NFC) [AArch64][llvm] Pre-commit tests for #137703 (NFC) Apr 28, 2025
Copy link
Contributor

@CarolineConcatto CarolineConcatto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I look at the ABI to understand if these tests are lowering properly?
Like in here:
https://github.com/ARM-software/abi-aa/blob/main/atomicsabi64/atomicsabi64.rst#id30

@jthackray
Copy link
Contributor Author

jthackray commented Apr 29, 2025

Should I look at the ABI to understand if these tests are lowering properly? Like in here: https://github.com/ARM-software/abi-aa/blob/main/atomicsabi64/atomicsabi64.rst#id30

@CarolineConcatto Yes, https://github.com/ARM-software/abi-aa/blob/main/atomicsabi64/atomicsabi64.rst#bit-floating-point-types shows what the instructions should be before and after.

In PR #137703, you can see in the diffs that this changes to a single ldfmax instruction (note, not ldfmaxnm, as these were added in #125686).

  • atomicrmw fmax lowers to ldfmaxnm instruction
  • atomicrmw fmaximum lowers to ldfmax instruction

and obviously fmin/fminimum are similar.

@jthackray jthackray force-pushed the users/jthackray/new-atomics branch from 50efa5b to 92ea098 Compare April 29, 2025 12:18
@jthackray jthackray requested a review from nikic as a code owner April 29, 2025 12:18
@nikic
Copy link
Contributor

nikic commented Apr 29, 2025

Looks like something went wrong here?

@jthackray jthackray force-pushed the users/jthackray/pre-commit-tests branch from fc3d0e9 to ef8e20b Compare April 29, 2025 13:32
@jthackray
Copy link
Contributor Author

Looks like something went wrong here?

A rebase fixed it; looks like it was transient.

Copy link
Contributor

@CarolineConcatto CarolineConcatto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not spot any significant difference between fmin and fminimum. So I believe this is fine. Thank you for the work Jonathan

…tructions (#136759)

This patch adds support for LLVM IR atomicrmw `fmaximum` and `fminimum`
instructions.

These mirror the `llvm.maximum.*` and `llvm.minimum.*` instructions, but
are atomic and use IEEE754 2019 handling for NaNs, which is different to
`fmax` and `fmin`. See:
     https://llvm.org/docs/LangRef.html#llvm-minimum-intrinsic
for more details.

Future changes will allow this LLVM IR to be lowered to specialised
assembler instructions on suitable targets, such as AArch64.
Add pre-commit tests for lowering atomicrmw `fminimum`/`fmaximum` to
AArch64 assembler, in a subsequent change.
@jthackray jthackray force-pushed the users/jthackray/new-atomics branch from 92ea098 to 5df3e4b Compare April 30, 2025 16:45
@jthackray jthackray force-pushed the users/jthackray/pre-commit-tests branch from ef8e20b to 844142e Compare April 30, 2025 16:45
Base automatically changed from users/jthackray/new-atomics to main April 30, 2025 21:06
@jthackray jthackray merged commit 4ac4ad4 into main Apr 30, 2025
11 checks passed
@jthackray jthackray deleted the users/jthackray/pre-commit-tests branch April 30, 2025 21:07
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
Add pre-commit tests for lowering atomicrmw `fminimum`/`fmaximum` to
AArch64 assembler, in a subsequent change.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
Add pre-commit tests for lowering atomicrmw `fminimum`/`fmaximum` to
AArch64 assembler, in a subsequent change.
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
Add pre-commit tests for lowering atomicrmw `fminimum`/`fmaximum` to
AArch64 assembler, in a subsequent change.
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this pull request May 7, 2025
Add pre-commit tests for lowering atomicrmw `fminimum`/`fmaximum` to
AArch64 assembler, in a subsequent change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants