1 ; PR52927: Relaxed atomics can load to/store from fp regs directly
2 ; RUN: llc < %s -mtriple=arm64-eabi -asm-verbose=false -verify-machineinstrs -mcpu=cyclone | FileCheck %s
4 define float @atomic_load_relaxed_f32(ptr %p, i32 %off32, i64 %off64) #0 {
5 ; CHECK-LABEL: atomic_load_relaxed_f32:
6 %ptr_unsigned = getelementptr float, ptr %p, i32 4095
7 %val_unsigned = load atomic float, ptr %ptr_unsigned monotonic, align 4
8 ; CHECK: ldr {{s[0-9]+}}, [x0, #16380]
10 %ptr_regoff = getelementptr float, ptr %p, i32 %off32
11 %val_regoff = load atomic float, ptr %ptr_regoff unordered, align 4
12 %tot1 = fadd float %val_unsigned, %val_regoff
13 ; CHECK: ldr {{s[0-9]+}}, [x0, w1, sxtw #2]
15 %ptr_regoff64 = getelementptr float, ptr %p, i64 %off64
16 %val_regoff64 = load atomic float, ptr %ptr_regoff64 monotonic, align 4
17 %tot2 = fadd float %tot1, %val_regoff64
18 ; CHECK: ldr {{s[0-9]+}}, [x0, x2, lsl #2]
20 %ptr_unscaled = getelementptr float, ptr %p, i32 -64
21 %val_unscaled = load atomic float, ptr %ptr_unscaled unordered, align 4
22 %tot3 = fadd float %tot2, %val_unscaled
23 ; CHECK: ldur {{s[0-9]+}}, [x0, #-256]
28 define double @atomic_load_relaxed_f64(ptr %p, i32 %off32, i64 %off64) #0 {
29 ; CHECK-LABEL: atomic_load_relaxed_f64:
30 %ptr_unsigned = getelementptr double, ptr %p, i32 4095
31 %val_unsigned = load atomic double, ptr %ptr_unsigned monotonic, align 8
32 ; CHECK: ldr {{d[0-9]+}}, [x0, #32760]
34 %ptr_regoff = getelementptr double, ptr %p, i32 %off32
35 %val_regoff = load atomic double, ptr %ptr_regoff unordered, align 8
36 %tot1 = fadd double %val_unsigned, %val_regoff
37 ; CHECK: ldr {{d[0-9]+}}, [x0, w1, sxtw #3]
39 %ptr_regoff64 = getelementptr double, ptr %p, i64 %off64
40 %val_regoff64 = load atomic double, ptr %ptr_regoff64 monotonic, align 8
41 %tot2 = fadd double %tot1, %val_regoff64
42 ; CHECK: ldr {{d[0-9]+}}, [x0, x2, lsl #3]
44 %ptr_unscaled = getelementptr double, ptr %p, i32 -32
45 %val_unscaled = load atomic double, ptr %ptr_unscaled unordered, align 8
46 %tot3 = fadd double %tot2, %val_unscaled
47 ; CHECK: ldur {{d[0-9]+}}, [x0, #-256]
52 define void @atomic_store_relaxed_f32(ptr %p, i32 %off32, i64 %off64, float %val) #0 {
53 ; CHECK-LABEL: atomic_store_relaxed_f32:
54 %ptr_unsigned = getelementptr float, ptr %p, i32 4095
55 store atomic float %val, ptr %ptr_unsigned monotonic, align 4
56 ; CHECK: str {{s[0-9]+}}, [x0, #16380]
58 %ptr_regoff = getelementptr float, ptr %p, i32 %off32
59 store atomic float %val, ptr %ptr_regoff unordered, align 4
60 ; CHECK: str {{s[0-9]+}}, [x0, w1, sxtw #2]
62 %ptr_regoff64 = getelementptr float, ptr %p, i64 %off64
63 store atomic float %val, ptr %ptr_regoff64 monotonic, align 4
64 ; CHECK: str {{s[0-9]+}}, [x0, x2, lsl #2]
66 %ptr_unscaled = getelementptr float, ptr %p, i32 -64
67 store atomic float %val, ptr %ptr_unscaled unordered, align 4
68 ; CHECK: stur {{s[0-9]+}}, [x0, #-256]
73 define void @atomic_store_relaxed_f64(ptr %p, i32 %off32, i64 %off64, double %val) #0 {
74 ; CHECK-LABEL: atomic_store_relaxed_f64:
75 %ptr_unsigned = getelementptr double, ptr %p, i32 4095
76 store atomic double %val, ptr %ptr_unsigned monotonic, align 8
77 ; CHECK: str {{d[0-9]+}}, [x0, #32760]
79 %ptr_regoff = getelementptr double, ptr %p, i32 %off32
80 store atomic double %val, ptr %ptr_regoff unordered, align 8
81 ; CHECK: str {{d[0-9]+}}, [x0, w1, sxtw #3]
83 %ptr_regoff64 = getelementptr double, ptr %p, i64 %off64
84 store atomic double %val, ptr %ptr_regoff64 unordered, align 8
85 ; CHECK: str {{d[0-9]+}}, [x0, x2, lsl #3]
87 %ptr_unscaled = getelementptr double, ptr %p, i32 -32
88 store atomic double %val, ptr %ptr_unscaled monotonic, align 8
89 ; CHECK: stur {{d[0-9]+}}, [x0, #-256]
94 attributes #0 = { nounwind }