aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/powerpc/crypto-builtin-1.c
blob: 234041d5c358da7cd05035417c4a59c9177ab444 (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
/* { dg-do compile { target { powerpc*-*-* } } } */
/* { dg-skip-if "" { powerpc*-*-darwin* } } */
/* { dg-require-effective-target powerpc_p8vector_ok } */
/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power8" } } */
/* { dg-options "-mcpu=power8 -O2 -ftree-vectorize -fvect-cost-model=dynamic -fno-unroll-loops -fno-unroll-all-loops" } */

typedef vector unsigned long long	crypto_t;
typedef vector unsigned long long	v2di_t;
typedef vector unsigned int		v4si_t;
typedef vector unsigned short		v8hi_t;
typedef vector unsigned char		v16qi_t;

crypto_t crpyto1 (crypto_t a)
{
  return __builtin_crypto_vsbox (a);
}

crypto_t crypto2 (crypto_t a, crypto_t b)
{
  return __builtin_crypto_vcipher (a, b);
}

crypto_t crypto3 (crypto_t a, crypto_t b)
{
  return __builtin_crypto_vcipherlast (a, b);
}

crypto_t crypto4 (crypto_t a, crypto_t b)
{
  return __builtin_crypto_vncipher (a, b);
}

crypto_t crypto5 (crypto_t a, crypto_t b)
{
  return __builtin_crypto_vncipherlast (a, b);
}

v16qi_t crypto6a (v16qi_t a, v16qi_t b, v16qi_t c)
{
  return __builtin_crypto_vpermxor (a, b, c);
}

v8hi_t crypto6b (v8hi_t a, v8hi_t b, v8hi_t c)
{
  return __builtin_crypto_vpermxor (a, b, c);
}

v4si_t crypto6c (v4si_t a, v4si_t b, v4si_t c)
{
  return __builtin_crypto_vpermxor (a, b, c);
}

v2di_t crypto6d (v2di_t a, v2di_t b, v2di_t c)
{
  return __builtin_crypto_vpermxor (a, b, c);
}

v16qi_t crypto7a (v16qi_t a, v16qi_t b)
{
  return __builtin_crypto_vpmsumb (a, b);
}

v16qi_t crypto7b (v16qi_t a, v16qi_t b)
{
  return __builtin_crypto_vpmsum (a, b);
}

v8hi_t crypto7c (v8hi_t a, v8hi_t b)
{
  return __builtin_crypto_vpmsumh (a, b);
}

v8hi_t crypto7d (v8hi_t a, v8hi_t b)
{
  return __builtin_crypto_vpmsum (a, b);
}

v4si_t crypto7e (v4si_t a, v4si_t b)
{
  return __builtin_crypto_vpmsumw (a, b);
}

v4si_t crypto7f (v4si_t a, v4si_t b)
{
  return __builtin_crypto_vpmsum (a, b);
}

v2di_t crypto7g (v2di_t a, v2di_t b)
{
  return __builtin_crypto_vpmsumd (a, b);
}

v2di_t crypto7h (v2di_t a, v2di_t b)
{
  return __builtin_crypto_vpmsum (a, b);
}

v2di_t crypto8a (v2di_t a)
{
  return __builtin_crypto_vshasigmad (a, 0, 8);
}

v2di_t crypto8b (v2di_t a)
{
  return __builtin_crypto_vshasigma (a, 0, 8);
}

v4si_t crypto8c (v4si_t a)
{
  return __builtin_crypto_vshasigmaw (a, 1, 15);
}

v4si_t crypto8d (v4si_t a)
{
  return __builtin_crypto_vshasigma (a, 1, 15);
}

/* Note space is used after the instruction so that vcipherlast does not match
   vcipher.  */
/* { dg-final { scan-assembler-times "vcipher "      1 } } */
/* { dg-final { scan-assembler-times "vcipherlast "  1 } } */
/* { dg-final { scan-assembler-times "vncipher "     1 } } */
/* { dg-final { scan-assembler-times "vncipherlast " 1 } } */
/* { dg-final { scan-assembler-times "vpermxor "     4 } } */
/* { dg-final { scan-assembler-times "vpmsumb "      2 } } */
/* { dg-final { scan-assembler-times "vpmsumd "      2 } } */
/* { dg-final { scan-assembler-times "vpmsumh "      2 } } */
/* { dg-final { scan-assembler-times "vpmsumw "      2 } } */
/* { dg-final { scan-assembler-times "vsbox "        1 } } */
/* { dg-final { scan-assembler-times "vshasigmad "   2 } } */
/* { dg-final { scan-assembler-times "vshasigmaw "   2 } } */