aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/powerpc/p8vector-fp.c
blob: 3cfd8161dd630cf368d6125fb24deea4c6f7f103 (plain)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/* { dg-do compile { target { powerpc*-*-* } } } */
/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
/* { dg-require-effective-target powerpc_p8vector_ok } */
/* { dg-options "-mcpu=power8 -O2 -mupper-regs-df -mupper-regs-sf -fno-math-errno" } */

float abs_sf (float *p)
{
  float f = *p;
  __asm__ ("# reg %x0" : "+v" (f));
  return __builtin_fabsf (f);
}

float nabs_sf (float *p)
{
  float f = *p;
  __asm__ ("# reg %x0" : "+v" (f));
  return - __builtin_fabsf (f);
}

float neg_sf (float *p)
{
  float f = *p;
  __asm__ ("# reg %x0" : "+v" (f));
  return - f;
}

float add_sf (float *p, float *q)
{
  float f1 = *p;
  float f2 = *q;
  __asm__ ("# reg %x0, %x1" : "+v" (f1), "+v" (f2));
  return f1 + f2;
}

float sub_sf (float *p, float *q)
{
  float f1 = *p;
  float f2 = *q;
  __asm__ ("# reg %x0, %x1" : "+v" (f1), "+v" (f2));
  return f1 - f2;
}

float mul_sf (float *p, float *q)
{
  float f1 = *p;
  float f2 = *q;
  __asm__ ("# reg %x0, %x1" : "+v" (f1), "+v" (f2));
  return f1 * f2;
}

float div_sf (float *p, float *q)
{
  float f1 = *p;
  float f2 = *q;
  __asm__ ("# reg %x0, %x1" : "+v" (f1), "+v" (f2));
  return f1 / f2;
}

float sqrt_sf (float *p)
{
  float f = *p;
  __asm__ ("# reg %x0" : "+v" (f));
  return __builtin_sqrtf (f);
}


double abs_df (double *p)
{
  double d = *p;
  __asm__ ("# reg %x0" : "+v" (d));
  return __builtin_fabs (d);
}

double nabs_df (double *p)
{
  double d = *p;
  __asm__ ("# reg %x0" : "+v" (d));
  return - __builtin_fabs (d);
}

double neg_df (double *p)
{
  double d = *p;
  __asm__ ("# reg %x0" : "+v" (d));
  return - d;
}

double add_df (double *p, double *q)
{
  double d1 = *p;
  double d2 = *q;
  __asm__ ("# reg %x0, %x1" : "+v" (d1), "+v" (d2));
  return d1 + d2;
}

double sub_df (double *p, double *q)
{
  double d1 = *p;
  double d2 = *q;
  __asm__ ("# reg %x0, %x1" : "+v" (d1), "+v" (d2));
  return d1 - d2;
}

double mul_df (double *p, double *q)
{
  double d1 = *p;
  double d2 = *q;
  __asm__ ("# reg %x0, %x1" : "+v" (d1), "+v" (d2));
  return d1 * d2;
}

double div_df (double *p, double *q)
{
  double d1 = *p;
  double d2 = *q;
  __asm__ ("# reg %x0, %x1" : "+v" (d1), "+v" (d2));
  return d1 / d2;
}

double sqrt_df (float *p)
{
  double d = *p;
  __asm__ ("# reg %x0" : "+v" (d));
  return __builtin_sqrt (d);
}

/* { dg-final { scan-assembler "xsabsdp"  } } */
/* { dg-final { scan-assembler "xsadddp"  } } */
/* { dg-final { scan-assembler "xsaddsp"  } } */
/* { dg-final { scan-assembler "xsdivdp"  } } */
/* { dg-final { scan-assembler "xsdivsp"  } } */
/* { dg-final { scan-assembler "xsmuldp"  } } */
/* { dg-final { scan-assembler "xsmulsp"  } } */
/* { dg-final { scan-assembler "xsnabsdp" } } */
/* { dg-final { scan-assembler "xsnegdp"  } } */
/* { dg-final { scan-assembler "xssqrtdp" } } */
/* { dg-final { scan-assembler "xssqrtsp" } } */
/* { dg-final { scan-assembler "xssubdp"  } } */
/* { dg-final { scan-assembler "xssubsp"  } } */