Debian Codegraph @

libgomp/testsuite/libgomp.c/declare-variant-1.c

raw
1 /* { dg-do link { target { vect_simd_clones && { i?86-*-* x86_64-*-* } } } } */
2 /* { dg-require-effective-target lto } */
3 /* { dg-require-effective-target fpic } */
4 /* { dg-require-effective-target shared } */
5 /* { dg-additional-options "-fdump-tree-gimple -fdump-tree-optimized -O2 -fPIC -shared -flto -flto-partition=one" } */
6 /* { dg-additional-options "-mno-sse3" } */
7
8 int
9 f01 (int a)
10 {
11 asm volatile ("" : "+g" (a) : "g" (1) : "memory");
12 return a;
13 }
14
15 int
16 f02 (int a)
17 {
18 asm volatile ("" : "+g" (a) : "g" (2) : "memory");
19 return a;
20 }
21
22 int
23 f03 (int a)
24 {
25 asm volatile ("" : "+g" (a) : "g" (3) : "memory");
26 return a;
27 }
28
29 #pragma omp declare variant (f01) match (device={isa("avx512f")}) /* 4 or 8 */
30 #pragma omp declare variant (f02) match (implementation={vendor(score(3):gnu)},device={kind(cpu)}) /* (1 or 2) + 3 */
31 #pragma omp declare variant (f03) match (implementation={vendor(score(5):gnu)},device={kind(host)}) /* (1 or 2) + 5 */
32 int
33 f04 (int a)
34 {
35 asm volatile ("" : "+g" (a) : "g" (4) : "memory");
36 return a;
37 }
38
39 #pragma omp declare simd
40 int
41 test1 (int x)
42 {
43 /* At gimplification time, we can't decide yet which function to call,
44 given the f01 variant. */
45 /* { dg-final { scan-tree-dump-times "f04 \\\(x" 2 "gimple" } } */
46 /* After simd clones are created, the original non-clone test1 shall
47 call f03 (score 6), the sse2/avx/avx2 clones too, but avx512f clones
48 shall call f01 with score 8. */
49 /* { dg-final { scan-ltrans-tree-dump-not "f04 \\\(x" "optimized" } } */
50 /* { dg-final { scan-ltrans-tree-dump-not "f02 \\\(x" "optimized" } } */
51 /* { dg-final { scan-ltrans-tree-dump-times "f03 \\\(x" 14 "optimized" } } */
52 /* { dg-final { scan-ltrans-tree-dump-times "f01 \\\(x" 4 "optimized" } } */
53 int a = f04 (x);
54 int b = f04 (x);
55 return a + b;
56 }