1// REQUIRES: aarch64-registered-target
2// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
3// RUN:  -ffp-contract=fast -S -O3 -o - %s | FileCheck %s --check-prefix=CHECK \
4// RUN:  --check-prefix=CHECK-ARM64
5
6// Test new aarch64 intrinsics with poly128
7// FIXME: Currently, poly128_t equals to uint128, which will be spilt into
8// two 64-bit GPR(eg X0, X1). Now moving data from X0, X1 to FPR128 will
9// introduce 2 store and 1 load instructions(store X0, X1 to memory and
10// then load back to Q0). If target has NEON, this is better replaced by
11// FMOV or INS.
12
13#include <arm_neon.h>
14
15void test_vstrq_p128(poly128_t * ptr, poly128_t val) {
16  // CHECK-LABEL: test_vstrq_p128
17  vstrq_p128(ptr, val);
18
19  // CHECK-ARM64: stp {{x[0-9]+}}, {{x[0-9]+}}, [x0]
20}
21
22poly128_t test_vldrq_p128(poly128_t * ptr) {
23  // CHECK-LABEL: test_vldrq_p128
24  return vldrq_p128(ptr);
25
26  // CHECK-ARM64: ldp {{x[0-9]+}}, {{x[0-9]+}}, [x0]
27}
28
29void test_ld_st_p128(poly128_t * ptr) {
30  // CHECK-LABEL: test_ld_st_p128
31   vstrq_p128(ptr+1, vldrq_p128(ptr));
32
33 // CHECK-ARM64: ldp [[PLO:x[0-9]+]], [[PHI:x[0-9]+]], [{{x[0-9]+}}]
34 // CHECK-ARM64-NEXT: stp [[PLO]], [[PHI]], [{{x[0-9]+}}, #16]
35}
36
37poly128_t test_vmull_p64(poly64_t a, poly64_t b) {
38  // CHECK-LABEL: test_vmull_p64
39  return vmull_p64(a, b);
40  // CHECK: pmull {{v[0-9]+}}.1q, {{v[0-9]+}}.1d, {{v[0-9]+}}.1d
41}
42
43poly128_t test_vmull_high_p64(poly64x2_t a, poly64x2_t b) {
44  // CHECK-LABEL: test_vmull_high_p64
45  return vmull_high_p64(a, b);
46  // CHECK: pmull2 {{v[0-9]+}}.1q, {{v[0-9]+}}.2d, {{v[0-9]+}}.2d
47}
48
49// CHECK-LABEL: test_vreinterpretq_p128_s8
50// CHECK: ret
51poly128_t test_vreinterpretq_p128_s8(int8x16_t a) {
52  return vreinterpretq_p128_s8(a);
53}
54
55// CHECK-LABEL: test_vreinterpretq_p128_s16
56// CHECK: ret
57poly128_t test_vreinterpretq_p128_s16(int16x8_t a) {
58  return vreinterpretq_p128_s16(a);
59}
60
61// CHECK-LABEL: test_vreinterpretq_p128_s32
62// CHECK: ret
63poly128_t test_vreinterpretq_p128_s32(int32x4_t a) {
64  return vreinterpretq_p128_s32(a);
65}
66
67// CHECK-LABEL: test_vreinterpretq_p128_s64
68// CHECK: ret
69poly128_t test_vreinterpretq_p128_s64(int64x2_t a) {
70  return vreinterpretq_p128_s64(a);
71}
72
73// CHECK-LABEL: test_vreinterpretq_p128_u8
74// CHECK: ret
75poly128_t test_vreinterpretq_p128_u8(uint8x16_t a) {
76  return vreinterpretq_p128_u8(a);
77}
78
79// CHECK-LABEL: test_vreinterpretq_p128_u16
80// CHECK: ret
81poly128_t test_vreinterpretq_p128_u16(uint16x8_t a) {
82  return vreinterpretq_p128_u16(a);
83}
84
85// CHECK-LABEL: test_vreinterpretq_p128_u32
86// CHECK: ret
87poly128_t test_vreinterpretq_p128_u32(uint32x4_t a) {
88  return vreinterpretq_p128_u32(a);
89}
90
91// CHECK-LABEL: test_vreinterpretq_p128_u64
92// CHECK: ret
93poly128_t test_vreinterpretq_p128_u64(uint64x2_t a) {
94  return vreinterpretq_p128_u64(a);
95}
96
97// CHECK-LABEL: test_vreinterpretq_p128_f32
98// CHECK: ret
99poly128_t test_vreinterpretq_p128_f32(float32x4_t a) {
100  return vreinterpretq_p128_f32(a);
101}
102
103// CHECK-LABEL: test_vreinterpretq_p128_f64
104// CHECK: ret
105poly128_t test_vreinterpretq_p128_f64(float64x2_t a) {
106  return vreinterpretq_p128_f64(a);
107}
108
109// CHECK-LABEL: test_vreinterpretq_p128_p8
110// CHECK: ret
111poly128_t test_vreinterpretq_p128_p8(poly8x16_t a) {
112  return vreinterpretq_p128_p8(a);
113}
114
115// CHECK-LABEL: test_vreinterpretq_p128_p16
116// CHECK: ret
117poly128_t test_vreinterpretq_p128_p16(poly16x8_t a) {
118  return vreinterpretq_p128_p16(a);
119}
120
121// CHECK-LABEL: test_vreinterpretq_p128_p64
122// CHECK: ret
123poly128_t test_vreinterpretq_p128_p64(poly64x2_t a) {
124  return vreinterpretq_p128_p64(a);
125}
126
127// CHECK-LABEL: test_vreinterpretq_s8_p128
128// CHECK: ret
129int8x16_t test_vreinterpretq_s8_p128(poly128_t a) {
130  return vreinterpretq_s8_p128(a);
131}
132
133// CHECK-LABEL: test_vreinterpretq_s16_p128
134// CHECK: ret
135int16x8_t test_vreinterpretq_s16_p128(poly128_t  a) {
136  return vreinterpretq_s16_p128(a);
137}
138
139// CHECK-LABEL: test_vreinterpretq_s32_p128
140// CHECK: ret
141int32x4_t test_vreinterpretq_s32_p128(poly128_t a) {
142  return vreinterpretq_s32_p128(a);
143}
144
145// CHECK-LABEL: test_vreinterpretq_s64_p128
146// CHECK: ret
147int64x2_t test_vreinterpretq_s64_p128(poly128_t  a) {
148  return vreinterpretq_s64_p128(a);
149}
150
151// CHECK-LABEL: test_vreinterpretq_u8_p128
152// CHECK: ret
153uint8x16_t test_vreinterpretq_u8_p128(poly128_t  a) {
154  return vreinterpretq_u8_p128(a);
155}
156
157// CHECK-LABEL: test_vreinterpretq_u16_p128
158// CHECK: ret
159uint16x8_t test_vreinterpretq_u16_p128(poly128_t  a) {
160  return vreinterpretq_u16_p128(a);
161}
162
163// CHECK-LABEL: test_vreinterpretq_u32_p128
164// CHECK: ret
165uint32x4_t test_vreinterpretq_u32_p128(poly128_t  a) {
166  return vreinterpretq_u32_p128(a);
167}
168
169// CHECK-LABEL: test_vreinterpretq_u64_p128
170// CHECK: ret
171uint64x2_t test_vreinterpretq_u64_p128(poly128_t  a) {
172  return vreinterpretq_u64_p128(a);
173}
174
175// CHECK-LABEL: test_vreinterpretq_f32_p128
176// CHECK: ret
177float32x4_t test_vreinterpretq_f32_p128(poly128_t  a) {
178  return vreinterpretq_f32_p128(a);
179}
180
181// CHECK-LABEL: test_vreinterpretq_f64_p128
182// CHECK: ret
183float64x2_t test_vreinterpretq_f64_p128(poly128_t  a) {
184  return vreinterpretq_f64_p128(a);
185}
186
187// CHECK-LABEL: test_vreinterpretq_p8_p128
188// CHECK: ret
189poly8x16_t test_vreinterpretq_p8_p128(poly128_t  a) {
190  return vreinterpretq_p8_p128(a);
191}
192
193// CHECK-LABEL: test_vreinterpretq_p16_p128
194// CHECK: ret
195poly16x8_t test_vreinterpretq_p16_p128(poly128_t  a) {
196  return vreinterpretq_p16_p128(a);
197}
198
199// CHECK-LABEL: test_vreinterpretq_p64_p128
200// CHECK: ret
201poly64x2_t test_vreinterpretq_p64_p128(poly128_t  a) {
202  return vreinterpretq_p64_p128(a);
203}
204
205
206