1 // REQUIRES: aarch64-registered-target
2 // -fopemp and -fopenmp-simd behavior are expected to be the same.
4 // RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon -fopenmp -x c -emit-llvm %s -o - -femit-all-decls | FileCheck %s --check-prefix=AARCH64
5 // RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +neon -fopenmp-simd -x c -emit-llvm %s -o - -femit-all-decls | FileCheck %s --check-prefix=AARCH64
7 #pragma omp declare simd
8 #pragma omp declare simd simdlen(2)
9 #pragma omp declare simd simdlen(6)
10 #pragma omp declare simd simdlen(8)
13 // AARCH64: "_ZGVnM2v_foo" "_ZGVnM4v_foo" "_ZGVnM8v_foo" "_ZGVnN2v_foo" "_ZGVnN4v_foo" "_ZGVnN8v_foo"
14 // AARCH64-NOT: _ZGVnN6v_foo
16 void foo_loop(double *x
, float *y
, int N
) {
17 for (int i
= 0; i
< N
; ++i
) {
22 // make sure that the following two function by default gets generated
23 // with 4 and 2 lanes, as descrived in the vector ABI
24 #pragma omp declare simd notinbranch
26 #pragma omp declare simd notinbranch
29 // AARCH64: "_ZGVnN2v_baz" "_ZGVnN4v_baz"
31 // AARCH64: "_ZGVnN2v_bar" "_ZGVnN4v_bar"
34 void baz_bar_loop(double *x
, float *y
, int N
) {
35 for (int i
= 0; i
< N
; ++i
) {
41 /***************************/
42 /* 32-bit integer tests */
43 /***************************/
45 #pragma omp declare simd
46 #pragma omp declare simd simdlen(2)
47 #pragma omp declare simd simdlen(6)
48 #pragma omp declare simd simdlen(8)
51 // AARCH64: "_ZGVnN2v_foo_int" "_ZGVnN4v_foo_int" "_ZGVnN8v_foo_int"
52 // No non power of two
53 // AARCH64-NOT: _ZGVnN6v_foo_int
55 void foo_int_loop(long *x
, int *y
, int N
) {
56 for (int i
= 0; i
< N
; ++i
) {
61 #pragma omp declare simd
62 char simple_8bit(char);
63 // AARCH64: "_ZGVnM16v_simple_8bit" "_ZGVnM8v_simple_8bit" "_ZGVnN16v_simple_8bit" "_ZGVnN8v_simple_8bit"
64 #pragma omp declare simd
65 short simple_16bit(short);
66 // AARCH64: "_ZGVnM4v_simple_16bit" "_ZGVnM8v_simple_16bit" "_ZGVnN4v_simple_16bit" "_ZGVnN8v_simple_16bit"
67 #pragma omp declare simd
68 int simple_32bit(int);
69 // AARCH64: "_ZGVnM2v_simple_32bit" "_ZGVnM4v_simple_32bit" "_ZGVnN2v_simple_32bit" "_ZGVnN4v_simple_32bit"
70 #pragma omp declare simd
71 long simple_64bit(long);
72 // AARCH64: "_ZGVnM2v_simple_64bit" "_ZGVnN2v_simple_64bit"
74 #pragma omp declare simd
75 #pragma omp declare simd simdlen(32)
77 // AARCH64: "_ZGVnN16v_a01" "_ZGVnN32v_a01" "_ZGVnN8v_a01"
80 #pragma omp declare simd
81 #pragma omp declare simd simdlen(2)
83 // AARCH64: "_ZGVnN2v_a02" "_ZGVnN4v_a02" "_ZGVnN8v_a02"
90 #pragma omp declare simd
92 // AARCH64: "_ZGVnN4v_b01"
95 #pragma omp declare simd
97 // AARCH64: "_ZGVnN16v_b02" "_ZGVnN8v_b02"
100 #pragma omp declare simd
101 double *b03(double *);
102 // AARCH64: "_ZGVnN2v_b03"
109 #pragma omp declare simd inbranch
110 int c01(double *x
, short y
);
111 // AARCH64: "_ZGVnM8vv_c01"
114 #pragma omp declare simd inbranch uniform(x)
115 double c02(double *x
, char y
);
116 // AARCH64: "_ZGVnM16uv_c02" "_ZGVnM8uv_c02"
119 /************************************/
120 /* Linear with a constant parameter */
121 /************************************/
123 #pragma omp declare simd notinbranch linear(i)
124 double constlinear(const int i
);
125 // AARCH64: "_ZGVnN2l_constlinear" "_ZGVnN4l_constlinear"
126 // AARCH64-NOT: constlinear
128 /*************************/
129 /* sincos-like signature */
130 /*************************/
131 #pragma omp declare simd linear(sin) linear(cos)
132 void sincos(double in
, double *sin
, double *cos
);
133 // AARCH64: "_ZGVnN2vl8l8_sincos"
134 // AARCH64-NOT: sincos
136 #pragma omp declare simd linear(sin : 1) linear(cos : 2)
137 void SinCos(double in
, double *sin
, double *cos
);
138 // AARCH64: "_ZGVnN2vl8l16_SinCos"
139 // AARCH64-NOT: SinCos
141 // Selection of tests based on the examples provided in chapter 5 of
142 // the Vector Function ABI specifications for AArch64, at
143 // https://developer.arm.com/products/software-development-tools/hpc/arm-compiler-for-hpc/vector-function-abi.
146 #pragma omp declare simd inbranch uniform(x) linear(val(i) : 4)
147 int foo2(int *x
, int i
);
148 // AARCH64: "_ZGVnM2ul4_foo2" "_ZGVnM4ul4_foo2"
152 #pragma omp declare simd inbranch uniform(x, c) linear(i \
154 int foo3(int *x
, int i
, unsigned char c
);
155 // AARCH64: "_ZGVnM16uls2u_foo3" "_ZGVnM8uls2u_foo3"
159 #pragma omp declare simd linear(x) aligned(x : 16) simdlen(4)
160 int foo4(int *x
, float y
);
161 // AARCH64: "_ZGVnM4l4a16v_foo4" "_ZGVnN4l4a16v_foo4"
170 void do_something() {
193 #pragma omp declare simd notinbranch
195 // AARCH64: "_ZGVnN2v_DoRGB"
199 void do_rgb_stuff() {