Skip to content

Commit 465bc5e

Browse files
authored
AArch64/ARM/PPC/X86: Add some atomic tests (#92933)
FP typed atomic load/store coverage was mostly missing, especially for half and bfloat.
1 parent bb42511 commit 465bc5e

File tree

5 files changed

+1045
-0
lines changed

5 files changed

+1045
-0
lines changed

llvm/test/CodeGen/AArch64/Atomics/aarch64-atomic-load-lse2.ll

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,119 @@ define dso_local i128 @load_atomic_i128_unaligned_seq_cst_const(ptr readonly %pt
566566
%r = load atomic i128, ptr %ptr seq_cst, align 1
567567
ret i128 %r
568568
}
569+
570+
define dso_local half @load_atomic_f16_aligned_unordered(ptr %ptr) {
571+
; CHECK-LABEL: load_atomic_f16_aligned_unordered:
572+
; CHECK: ldrh w8, [x0]
573+
%r = load atomic half, ptr %ptr unordered, align 2
574+
ret half %r
575+
}
576+
577+
define dso_local half @load_atomic_f16_aligned_unordered_const(ptr readonly %ptr) {
578+
; CHECK-LABEL: load_atomic_f16_aligned_unordered_const:
579+
; CHECK: ldrh w8, [x0]
580+
%r = load atomic half, ptr %ptr unordered, align 2
581+
ret half %r
582+
}
583+
584+
define dso_local half @load_atomic_f16_aligned_monotonic(ptr %ptr) {
585+
; CHECK-LABEL: load_atomic_f16_aligned_monotonic:
586+
; CHECK: ldrh w8, [x0]
587+
%r = load atomic half, ptr %ptr monotonic, align 2
588+
ret half %r
589+
}
590+
591+
define dso_local half @load_atomic_f16_aligned_monotonic_const(ptr readonly %ptr) {
592+
; CHECK-LABEL: load_atomic_f16_aligned_monotonic_const:
593+
; CHECK: ldrh w8, [x0]
594+
%r = load atomic half, ptr %ptr monotonic, align 2
595+
ret half %r
596+
}
597+
598+
define dso_local half @load_atomic_f16_aligned_acquire(ptr %ptr) {
599+
; CHECK-LABEL: load_atomic_f16_aligned_acquire:
600+
; CHECK: ldarh w8, [x0]
601+
%r = load atomic half, ptr %ptr acquire, align 2
602+
ret half %r
603+
}
604+
605+
define dso_local half @load_atomic_f16_aligned_acquire_const(ptr readonly %ptr) {
606+
; CHECK-LABEL: load_atomic_f16_aligned_acquire_const:
607+
; CHECK: ldarh w8, [x0]
608+
%r = load atomic half, ptr %ptr acquire, align 2
609+
ret half %r
610+
}
611+
612+
define dso_local half @load_atomic_f16_aligned_seq_cst(ptr %ptr) {
613+
; CHECK-LABEL: load_atomic_f16_aligned_seq_cst:
614+
; CHECK: ldarh w8, [x0]
615+
%r = load atomic half, ptr %ptr seq_cst, align 2
616+
ret half %r
617+
}
618+
619+
define dso_local half @load_atomic_f16_aligned_seq_cst_const(ptr readonly %ptr) {
620+
; CHECK-LABEL: load_atomic_f16_aligned_seq_cst_const:
621+
; CHECK: ldarh w8, [x0]
622+
%r = load atomic half, ptr %ptr seq_cst, align 2
623+
ret half %r
624+
}
625+
626+
define dso_local bfloat @load_atomic_bf16_aligned_unordered(ptr %ptr) {
627+
; CHECK-LABEL: load_atomic_bf16_aligned_unordered:
628+
; CHECK: ldrh w8, [x0]
629+
%r = load atomic bfloat, ptr %ptr unordered, align 2
630+
ret bfloat %r
631+
}
632+
633+
define dso_local bfloat @load_atomic_bf16_aligned_unordered_const(ptr readonly %ptr) {
634+
; CHECK-LABEL: load_atomic_bf16_aligned_unordered_const:
635+
; CHECK: ldrh w8, [x0]
636+
%r = load atomic bfloat, ptr %ptr unordered, align 2
637+
ret bfloat %r
638+
}
639+
640+
define dso_local bfloat @load_atomic_bf16_aligned_monotonic(ptr %ptr) {
641+
; CHECK-LABEL: load_atomic_bf16_aligned_monotonic:
642+
; CHECK: ldrh w8, [x0]
643+
%r = load atomic bfloat, ptr %ptr monotonic, align 2
644+
ret bfloat %r
645+
}
646+
647+
define dso_local bfloat @load_atomic_bf16_aligned_monotonic_const(ptr readonly %ptr) {
648+
; CHECK-LABEL: load_atomic_bf16_aligned_monotonic_const:
649+
; CHECK: ldrh w8, [x0]
650+
%r = load atomic bfloat, ptr %ptr monotonic, align 2
651+
ret bfloat %r
652+
}
653+
654+
define dso_local bfloat @load_atomic_bf16_aligned_acquire(ptr %ptr) {
655+
; CHECK-LABEL: load_atomic_bf16_aligned_acquire:
656+
; CHECK: ldarh w8, [x0]
657+
%r = load atomic bfloat, ptr %ptr acquire, align 2
658+
ret bfloat %r
659+
}
660+
661+
define dso_local bfloat @load_atomic_bf16_aligned_acquire_const(ptr readonly %ptr) {
662+
; CHECK-LABEL: load_atomic_bf16_aligned_acquire_const:
663+
; CHECK: ldarh w8, [x0]
664+
%r = load atomic bfloat, ptr %ptr acquire, align 2
665+
ret bfloat %r
666+
}
667+
668+
define dso_local bfloat @load_atomic_bf16_aligned_seq_cst(ptr %ptr) {
669+
; CHECK-LABEL: load_atomic_bf16_aligned_seq_cst:
670+
; CHECK: ldarh w8, [x0]
671+
%r = load atomic bfloat, ptr %ptr seq_cst, align 2
672+
ret bfloat %r
673+
}
674+
675+
define dso_local bfloat @load_atomic_bf16_aligned_seq_cst_const(ptr readonly %ptr) {
676+
; CHECK-LABEL: load_atomic_bf16_aligned_seq_cst_const:
677+
; CHECK: ldarh w8, [x0]
678+
%r = load atomic bfloat, ptr %ptr seq_cst, align 2
679+
ret bfloat %r
680+
}
681+
569682
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
570683
; -O0: {{.*}}
571684
; -O1: {{.*}}

llvm/test/CodeGen/AArch64/relaxed-fp-atomics.ll

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,94 @@ define void @atomic_store_relaxed_f64(ptr %p, i32 %off32, i64 %off64, double %va
9191
ret void
9292
}
9393

94+
define half @atomic_load_relaxed_f16(ptr %p, i32 %off32, i64 %off64) #0 {
95+
; CHECK-LABEL: atomic_load_relaxed_f16:
96+
%ptr_unsigned = getelementptr half, ptr %p, i32 4095
97+
%val_unsigned = load atomic half, ptr %ptr_unsigned monotonic, align 4
98+
; CHECK: ldrh {{w[0-9]+}}, [x0, #8190]
99+
100+
%ptr_regoff = getelementptr half, ptr %p, i32 %off32
101+
%val_regoff = load atomic half, ptr %ptr_regoff unordered, align 4
102+
%tot1 = fadd half %val_unsigned, %val_regoff
103+
; CHECK: ldrh {{w[0-9]+}}, [x0, w1, sxtw #1]
104+
105+
%ptr_regoff64 = getelementptr half, ptr %p, i64 %off64
106+
%val_regoff64 = load atomic half, ptr %ptr_regoff64 monotonic, align 4
107+
%tot2 = fadd half %tot1, %val_regoff64
108+
; CHECK: ldrh {{w[0-9]+}}, [x0, x2, lsl #1]
109+
110+
%ptr_unscaled = getelementptr half, ptr %p, i32 -64
111+
%val_unscaled = load atomic half, ptr %ptr_unscaled unordered, align 4
112+
%tot3 = fadd half %tot2, %val_unscaled
113+
; CHECK: ldurh {{w[0-9]+}}, [x0, #-128]
114+
115+
ret half %tot3
116+
}
117+
118+
define bfloat @atomic_load_relaxed_bf16(ptr %p, i32 %off32, i64 %off64) #0 {
119+
; CHECK-LABEL: atomic_load_relaxed_bf16:
120+
%ptr_unsigned = getelementptr bfloat, ptr %p, i32 4095
121+
%val_unsigned = load atomic bfloat, ptr %ptr_unsigned monotonic, align 4
122+
; CHECK: ldrh {{w[0-9]+}}, [x0, #8190]
123+
124+
%ptr_regoff = getelementptr bfloat, ptr %p, i32 %off32
125+
%val_regoff = load atomic bfloat, ptr %ptr_regoff unordered, align 4
126+
%tot1 = fadd bfloat %val_unsigned, %val_regoff
127+
; CHECK: ldrh {{w[0-9]+}}, [x0, w1, sxtw #1]
128+
129+
%ptr_regoff64 = getelementptr bfloat, ptr %p, i64 %off64
130+
%val_regoff64 = load atomic bfloat, ptr %ptr_regoff64 monotonic, align 4
131+
%tot2 = fadd bfloat %tot1, %val_regoff64
132+
; CHECK: ldrh {{w[0-9]+}}, [x0, x2, lsl #1]
133+
134+
%ptr_unscaled = getelementptr bfloat, ptr %p, i32 -64
135+
%val_unscaled = load atomic bfloat, ptr %ptr_unscaled unordered, align 4
136+
%tot3 = fadd bfloat %tot2, %val_unscaled
137+
; CHECK: ldurh {{w[0-9]+}}, [x0, #-128]
138+
139+
ret bfloat %tot3
140+
}
141+
142+
define void @atomic_store_relaxed_f16(ptr %p, i32 %off32, i64 %off64, half %val) #0 {
143+
; CHECK-LABEL: atomic_store_relaxed_f16:
144+
%ptr_unsigned = getelementptr half, ptr %p, i32 4095
145+
store atomic half %val, ptr %ptr_unsigned monotonic, align 4
146+
; CHECK: strh {{w[0-9]+}}, [x0, #8190]
147+
148+
%ptr_regoff = getelementptr half, ptr %p, i32 %off32
149+
store atomic half %val, ptr %ptr_regoff unordered, align 4
150+
; CHECK: strh {{w[0-9]+}}, [x0, w1, sxtw #1]
151+
152+
%ptr_regoff64 = getelementptr half, ptr %p, i64 %off64
153+
store atomic half %val, ptr %ptr_regoff64 monotonic, align 4
154+
; CHECK: strh {{w[0-9]+}}, [x0, x2, lsl #1]
155+
156+
%ptr_unscaled = getelementptr half, ptr %p, i32 -64
157+
store atomic half %val, ptr %ptr_unscaled unordered, align 4
158+
; CHECK: sturh {{w[0-9]+}}, [x0, #-128]
159+
160+
ret void
161+
}
162+
163+
define void @atomic_store_relaxed_bf16(ptr %p, i32 %off32, i64 %off64, bfloat %val) #0 {
164+
; CHECK-LABEL: atomic_store_relaxed_bf16:
165+
%ptr_unsigned = getelementptr bfloat, ptr %p, i32 4095
166+
store atomic bfloat %val, ptr %ptr_unsigned monotonic, align 4
167+
; CHECK: strh {{w[0-9]+}}, [x0, #8190]
168+
169+
%ptr_regoff = getelementptr bfloat, ptr %p, i32 %off32
170+
store atomic bfloat %val, ptr %ptr_regoff unordered, align 4
171+
; CHECK: strh {{w[0-9]+}}, [x0, w1, sxtw #1]
172+
173+
%ptr_regoff64 = getelementptr bfloat, ptr %p, i64 %off64
174+
store atomic bfloat %val, ptr %ptr_regoff64 monotonic, align 4
175+
; CHECK: strh {{w[0-9]+}}, [x0, x2, lsl #1]
176+
177+
%ptr_unscaled = getelementptr bfloat, ptr %p, i32 -64
178+
store atomic bfloat %val, ptr %ptr_unscaled unordered, align 4
179+
; CHECK: sturh {{w[0-9]+}}, [x0, #-128]
180+
181+
ret void
182+
}
183+
94184
attributes #0 = { nounwind }

0 commit comments

Comments
 (0)