summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/powerpc/vsx-builtin-8.c
blob: 836b3851cad843cda2ce4753e84663f5d05b67ec (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
/* { dg-do compile { target { powerpc*-*-* } } } */
/* { dg-skip-if "" { powerpc*-*-darwin* } { "*" } { "" } } */
/* { dg-require-effective-target powerpc_vsx_ok } */
/* { dg-options "-O3 -mcpu=power7" } */

/* Test the various load/store varients.  */

#include <altivec.h>

#define TEST_COPY(NAME, TYPE)						\
void NAME ## _copy_native (vector TYPE *a, vector TYPE *b)		\
{									\
  *a = *b;								\
}									\
									\
void NAME ## _copy_vec (vector TYPE *a, vector TYPE *b)			\
{									\
  vector TYPE x = vec_ld (0, b);					\
  vec_st (x, 0, a);							\
}									\

#define TEST_COPYL(NAME, TYPE)						\
void NAME ## _lvxl (vector TYPE *a, vector TYPE *b)			\
{									\
  vector TYPE x = vec_ldl (0, b);					\
  vec_stl (x, 0, a);							\
}									\

#define TEST_VSX_COPY(NAME, TYPE)					\
void NAME ## _copy_vsx (vector TYPE *a, vector TYPE *b)			\
{									\
  vector TYPE x = vec_vsx_ld (0, b);					\
  vec_vsx_st (x, 0, a);							\
}									\

#define TEST_ALIGN(NAME, TYPE)						\
void NAME ## _align (vector unsigned char *a, TYPE *b)			\
{									\
  vector unsigned char x = vec_lvsl (0, b);				\
  vector unsigned char y = vec_lvsr (0, b);				\
  vec_st (x, 0, a);							\
  vec_st (y, 8, a);							\
}

#ifndef NO_COPY
TEST_COPY(uchar,  unsigned char)
TEST_COPY(schar,  signed   char)
TEST_COPY(bchar,  bool     char)
TEST_COPY(ushort, unsigned short)
TEST_COPY(sshort, signed   short)
TEST_COPY(bshort, bool     short)
TEST_COPY(uint,   unsigned int)
TEST_COPY(sint,   signed   int)
TEST_COPY(bint,   bool     int)
TEST_COPY(float,  float)
TEST_COPY(double, double)
#endif	/* NO_COPY */

#ifndef NO_COPYL
TEST_COPYL(uchar,  unsigned char)
TEST_COPYL(schar,  signed   char)
TEST_COPYL(bchar,  bool     char)
TEST_COPYL(ushort, unsigned short)
TEST_COPYL(sshort, signed   short)
TEST_COPYL(bshort, bool     short)
TEST_COPYL(uint,   unsigned int)
TEST_COPYL(sint,   signed   int)
TEST_COPYL(bint,   bool     int)
TEST_COPYL(float,  float)
TEST_COPYL(double, double)
#endif	/* NO_COPYL */

#ifndef NO_ALIGN
TEST_ALIGN(uchar,  unsigned char)
TEST_ALIGN(schar,  signed   char)
TEST_ALIGN(ushort, unsigned short)
TEST_ALIGN(sshort, signed   short)
TEST_ALIGN(uint,   unsigned int)
TEST_ALIGN(sint,   signed   int)
TEST_ALIGN(float,  float)
TEST_ALIGN(double, double)
#endif	/* NO_ALIGN */


#ifndef NO_VSX_COPY
TEST_VSX_COPY(uchar,  unsigned char)
TEST_VSX_COPY(schar,  signed   char)
TEST_VSX_COPY(bchar,  bool     char)
TEST_VSX_COPY(ushort, unsigned short)
TEST_VSX_COPY(sshort, signed   short)
TEST_VSX_COPY(bshort, bool     short)
TEST_VSX_COPY(uint,   unsigned int)
TEST_VSX_COPY(sint,   signed   int)
TEST_VSX_COPY(bint,   bool     int)
TEST_VSX_COPY(float,  float)
TEST_VSX_COPY(double, double)
#endif	/* NO_VSX_COPY */