File: declare-variant-1.c

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (56 lines) | stat: -rw-r--r-- 1,801 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* { dg-do link { target { vect_simd_clones && { i?86-*-* x86_64-*-* } } } } */
/* { dg-require-effective-target lto } */
/* { dg-require-effective-target fpic } */
/* { dg-require-effective-target shared } */
/* { dg-additional-options "-fdump-tree-gimple -fdump-tree-optimized -O2 -fPIC -shared -flto -flto-partition=one" } */
/* { dg-additional-options "-mno-sse3" } */

int
f01 (int a)
{
  asm volatile ("" : "+g" (a) : "g" (1) : "memory");
  return a;
}

int
f02 (int a)
{
  asm volatile ("" : "+g" (a) : "g" (2) : "memory");
  return a;
}

int
f03 (int a)
{
  asm volatile ("" : "+g" (a) : "g" (3) : "memory");
  return a;
}

#pragma omp declare variant (f01) match (device={isa("avx512f")}) /* 4 or 8 */
#pragma omp declare variant (f02) match (implementation={vendor(score(3):gnu)},device={kind(cpu)}) /* (1 or 2) + 3 */
#pragma omp declare variant (f03) match (implementation={vendor(score(5):gnu)},device={kind(host)}) /* (1 or 2) + 5 */
int
f04 (int a)
{
  asm volatile ("" : "+g" (a) : "g" (4) : "memory");
  return a;
}

#pragma omp declare simd
int
test1 (int x)
{
  /* At gimplification time, we can't decide yet which function to call,
     given the f01 variant.  */
  /* { dg-final { scan-tree-dump-times "f04 \\\(x" 2 "gimple" } } */
  /* After simd clones are created, the original non-clone test1 shall
     call f03 (score 6), the sse2/avx/avx2 clones too, but avx512f clones
     shall call f01 with score 8.  */
  /* { dg-final { scan-ltrans-tree-dump-not "f04 \\\(x" "optimized" } } */
  /* { dg-final { scan-ltrans-tree-dump-not "f02 \\\(x" "optimized" } } */
  /* { dg-final { scan-ltrans-tree-dump-times "f03 \\\(x" 14 "optimized" } } */
  /* { dg-final { scan-ltrans-tree-dump-times "f01 \\\(x" 4 "optimized" } } */
  int a = f04 (x);
  int b = f04 (x);
  return a + b;
}