Debian Codegraph @

gcc/testsuite/g++.target/aarch64/vect-simd-clone-1.C

raw
1 /* { dg-do compile } */
2 /* { dg-additional-options "-O3 -march=armv8-a" } */
3
4 /* Ensure correct creation of SVE Vector-length agnostic (VLA SVE) vector
5 function calls from scalar versions in accordance with the Vector Function
6 Application Binary Interface Specification for AArch64 (AAVPCS).
7
8 We check for correctness in:
9 - Vector function name mangling, with the grammar:
10
11 vector name := prefix "_" name
12 prefix := "_ZGV" isa mask <len> <parameters>
13
14 Whereby:
15 - <isa> := "s" for SVE
16 - <mask> := "M" for Mask
17 - <len> := "x" for VLA SVE
18
19 resulting in:
20 <prefix> := "_ZGVsMx" <parameters>
21
22 with each vector parameter contributing a "v" to the prefix.
23
24 - Parameter and return value mapping:
25 - Unless marked with uniform or linear OpenMP clauses, parameters and
26 return values are expected to map to vectors.
27 - Where the lane-size of a parameter is less than the widest data size
28 for a given function, the resulting vector should be unpacked and
29 populated via extending loads.
30
31 - Finally, we also make sure we can correctly generate calls to the same
32 function, differing only in the target architecture (i.e. SVE vs SIMD),
33 ensuring that each call points to the correctly-mangled vector function
34 and employs the correct ABI. For example, for `fn' we may expect:
35
36 for #pragma GCC target("+sve"): _ZGVsMxvv_fn
37 for #pragma GCC target("+simd): _ZGVnN4vv_fn */
38
39 #pragma GCC target ("+sve")
40 /* { dg-final { scan-assembler {\s+_ZGVsMxv__Z3fn0i\n} } } */
41 extern int __attribute__ ((simd, const)) fn0 (int);
42 void test_fn0 (int *a, int *b, int n)
43 {
44 for (int i = 0; i < n; ++i)
45 a[i] += fn0 (b[i]);
46 }
47
48 /* { dg-final { scan-assembler {\s+_ZGVsMxvv__Z3fn1si\n} } } */
49 extern int __attribute__ ((simd, const)) fn1 (short, int);
50 void test_fn1 (int *a, int *b, short *c, int n)
51 {
52 for (int i = 0; i < n; ++i)
53 a[i] = fn1 (c[i], b[i]);
54 }
55
56 /* { dg-final { scan-assembler {\s+_ZGVsMxvv__Z3fn2si\n} } } */
57 extern short __attribute__ ((simd, const)) fn2 (short, int);
58 void test_fn2 (short *a, int *b, short *c, int n)
59 {
60 for (int i = 0; i < n; ++i)
61 a[i] = fn2 (c[i], b[i]);
62 }
63
64 /* { dg-final { scan-assembler {\s+_ZGVsMxvv__Z3fn3ic\n} } } */
65 extern char __attribute__ ((simd, const)) fn3 (int, char);
66 void test_fn3 (int *a, int *b, char *c, int n)
67 {
68 for (int i = 0; i < n; ++i)
69 a[i] = (int) (fn3 (b[i], c[i]) + c[i]);
70 }
71
72 /* { dg-final { scan-assembler {\s+_ZGVsMxvv__Z3fn4is\n} } } */
73 extern short __attribute__ ((simd, const)) fn4 (int, short);
74 void test_fn4 (int *a, int *b, short *c, int n)
75 {
76 for (int i = 0; i < n; ++i)
77 a[i] = (int) (fn4 (b[i], c[i]) + c[i]);
78 }
79
80 #pragma GCC reset_options
81 #pragma GCC target ("+simd")
82 /* { dg-final { scan-assembler {\s+_ZGVsMxvv__Z3fn4is\n} } } */
83 extern short __attribute__ ((simd, const)) fn4 (int, short);
84 void test_fn5 (int *a, int *b, short *c, int n)
85 {
86 for (int i = 0; i < n; ++i)
87 a[i] = (int) (fn4 (b[i], c[i]) + c[i]);
88 }