xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/atomic-non-integer.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=x86_64-linux-generic -verify-machineinstrs -mattr=sse2 | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; Note: This test is testing that the lowering for atomics matches what we
4*9880d681SAndroid Build Coastguard Worker; currently emit for non-atomics + the atomic restriction.  The presence of
5*9880d681SAndroid Build Coastguard Worker; particular lowering detail in these tests should not be read as requiring
6*9880d681SAndroid Build Coastguard Worker; that detail for correctness unless it's related to the atomicity itself.
7*9880d681SAndroid Build Coastguard Worker; (Specifically, there were reviewer questions about the lowering for halfs
8*9880d681SAndroid Build Coastguard Worker;  and their calling convention which remain unresolved.)
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Workerdefine void @store_half(half* %fptr, half %v) {
11*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @store_half
12*9880d681SAndroid Build Coastguard Worker; CHECK: movq	%rdi, %rbx
13*9880d681SAndroid Build Coastguard Worker; CHECK: callq	__gnu_f2h_ieee
14*9880d681SAndroid Build Coastguard Worker; CHECK: movw	%ax, (%rbx)
15*9880d681SAndroid Build Coastguard Worker  store atomic half %v, half* %fptr unordered, align 2
16*9880d681SAndroid Build Coastguard Worker  ret void
17*9880d681SAndroid Build Coastguard Worker}
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Workerdefine void @store_float(float* %fptr, float %v) {
20*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @store_float
21*9880d681SAndroid Build Coastguard Worker; CHECK: movd	%xmm0, %eax
22*9880d681SAndroid Build Coastguard Worker; CHECK: movl	%eax, (%rdi)
23*9880d681SAndroid Build Coastguard Worker  store atomic float %v, float* %fptr unordered, align 4
24*9880d681SAndroid Build Coastguard Worker  ret void
25*9880d681SAndroid Build Coastguard Worker}
26*9880d681SAndroid Build Coastguard Worker
27*9880d681SAndroid Build Coastguard Workerdefine void @store_double(double* %fptr, double %v) {
28*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @store_double
29*9880d681SAndroid Build Coastguard Worker; CHECK: movd	%xmm0, %rax
30*9880d681SAndroid Build Coastguard Worker; CHECK: movq	%rax, (%rdi)
31*9880d681SAndroid Build Coastguard Worker  store atomic double %v, double* %fptr unordered, align 8
32*9880d681SAndroid Build Coastguard Worker  ret void
33*9880d681SAndroid Build Coastguard Worker}
34*9880d681SAndroid Build Coastguard Worker
35*9880d681SAndroid Build Coastguard Workerdefine void @store_fp128(fp128* %fptr, fp128 %v) {
36*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @store_fp128
37*9880d681SAndroid Build Coastguard Worker; CHECK: callq	__sync_lock_test_and_set_16
38*9880d681SAndroid Build Coastguard Worker  store atomic fp128 %v, fp128* %fptr unordered, align 16
39*9880d681SAndroid Build Coastguard Worker  ret void
40*9880d681SAndroid Build Coastguard Worker}
41*9880d681SAndroid Build Coastguard Worker
42*9880d681SAndroid Build Coastguard Workerdefine half @load_half(half* %fptr) {
43*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @load_half
44*9880d681SAndroid Build Coastguard Worker; CHECK: movw	(%rdi), %ax
45*9880d681SAndroid Build Coastguard Worker; CHECK: movzwl	%ax, %edi
46*9880d681SAndroid Build Coastguard Worker; CHECK: callq	__gnu_h2f_ieee
47*9880d681SAndroid Build Coastguard Worker  %v = load atomic half, half* %fptr unordered, align 2
48*9880d681SAndroid Build Coastguard Worker  ret half %v
49*9880d681SAndroid Build Coastguard Worker}
50*9880d681SAndroid Build Coastguard Worker
51*9880d681SAndroid Build Coastguard Workerdefine float @load_float(float* %fptr) {
52*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @load_float
53*9880d681SAndroid Build Coastguard Worker; CHECK: movl	(%rdi), %eax
54*9880d681SAndroid Build Coastguard Worker; CHECK: movd	%eax, %xmm0
55*9880d681SAndroid Build Coastguard Worker  %v = load atomic float, float* %fptr unordered, align 4
56*9880d681SAndroid Build Coastguard Worker  ret float %v
57*9880d681SAndroid Build Coastguard Worker}
58*9880d681SAndroid Build Coastguard Worker
59*9880d681SAndroid Build Coastguard Workerdefine double @load_double(double* %fptr) {
60*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @load_double
61*9880d681SAndroid Build Coastguard Worker; CHECK: movq	(%rdi), %rax
62*9880d681SAndroid Build Coastguard Worker; CHECK: movd	%rax, %xmm0
63*9880d681SAndroid Build Coastguard Worker  %v = load atomic double, double* %fptr unordered, align 8
64*9880d681SAndroid Build Coastguard Worker  ret double %v
65*9880d681SAndroid Build Coastguard Worker}
66*9880d681SAndroid Build Coastguard Worker
67*9880d681SAndroid Build Coastguard Workerdefine fp128 @load_fp128(fp128* %fptr) {
68*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @load_fp128
69*9880d681SAndroid Build Coastguard Worker; CHECK: callq	__sync_val_compare_and_swap_16
70*9880d681SAndroid Build Coastguard Worker  %v = load atomic fp128, fp128* %fptr unordered, align 16
71*9880d681SAndroid Build Coastguard Worker  ret fp128 %v
72*9880d681SAndroid Build Coastguard Worker}
73*9880d681SAndroid Build Coastguard Worker
74*9880d681SAndroid Build Coastguard Worker
75*9880d681SAndroid Build Coastguard Worker; sanity check the seq_cst lowering since that's the
76*9880d681SAndroid Build Coastguard Worker; interesting one from an ordering perspective on x86.
77*9880d681SAndroid Build Coastguard Worker
78*9880d681SAndroid Build Coastguard Workerdefine void @store_float_seq_cst(float* %fptr, float %v) {
79*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @store_float_seq_cst
80*9880d681SAndroid Build Coastguard Worker; CHECK: movd	%xmm0, %eax
81*9880d681SAndroid Build Coastguard Worker; CHECK: xchgl	%eax, (%rdi)
82*9880d681SAndroid Build Coastguard Worker  store atomic float %v, float* %fptr seq_cst, align 4
83*9880d681SAndroid Build Coastguard Worker  ret void
84*9880d681SAndroid Build Coastguard Worker}
85*9880d681SAndroid Build Coastguard Worker
86*9880d681SAndroid Build Coastguard Workerdefine void @store_double_seq_cst(double* %fptr, double %v) {
87*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @store_double_seq_cst
88*9880d681SAndroid Build Coastguard Worker; CHECK: movd	%xmm0, %rax
89*9880d681SAndroid Build Coastguard Worker; CHECK: xchgq	%rax, (%rdi)
90*9880d681SAndroid Build Coastguard Worker  store atomic double %v, double* %fptr seq_cst, align 8
91*9880d681SAndroid Build Coastguard Worker  ret void
92*9880d681SAndroid Build Coastguard Worker}
93*9880d681SAndroid Build Coastguard Worker
94*9880d681SAndroid Build Coastguard Workerdefine float @load_float_seq_cst(float* %fptr) {
95*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @load_float_seq_cst
96*9880d681SAndroid Build Coastguard Worker; CHECK: movl	(%rdi), %eax
97*9880d681SAndroid Build Coastguard Worker; CHECK: movd	%eax, %xmm0
98*9880d681SAndroid Build Coastguard Worker  %v = load atomic float, float* %fptr seq_cst, align 4
99*9880d681SAndroid Build Coastguard Worker  ret float %v
100*9880d681SAndroid Build Coastguard Worker}
101*9880d681SAndroid Build Coastguard Worker
102*9880d681SAndroid Build Coastguard Workerdefine double @load_double_seq_cst(double* %fptr) {
103*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @load_double_seq_cst
104*9880d681SAndroid Build Coastguard Worker; CHECK: movq	(%rdi), %rax
105*9880d681SAndroid Build Coastguard Worker; CHECK: movd	%rax, %xmm0
106*9880d681SAndroid Build Coastguard Worker  %v = load atomic double, double* %fptr seq_cst, align 8
107*9880d681SAndroid Build Coastguard Worker  ret double %v
108*9880d681SAndroid Build Coastguard Worker}
109