(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
powerpc/
vsx-builtin-8.c
       1  /* { dg-do compile { target { powerpc*-*-* } } } */
       2  /* { dg-skip-if "" { powerpc*-*-darwin* } } */
       3  /* { dg-require-effective-target powerpc_vsx_ok } */
       4  /* { dg-options "-O3 -mdejagnu-cpu=power7 -Wno-deprecated" } */
       5  
       6  /* Test the various load/store varients.  */
       7  
       8  #include <altivec.h>
       9  
      10  #define TEST_COPY(NAME, TYPE)						\
      11  void NAME ## _copy_native (vector TYPE *a, vector TYPE *b)		\
      12  {									\
      13    *a = *b;								\
      14  }									\
      15  									\
      16  void NAME ## _copy_vec (vector TYPE *a, vector TYPE *b)			\
      17  {									\
      18    vector TYPE x = vec_ld (0, b);					\
      19    vec_st (x, 0, a);							\
      20  }									\
      21  
      22  #define TEST_COPYL(NAME, TYPE)						\
      23  void NAME ## _lvxl (vector TYPE *a, vector TYPE *b)			\
      24  {									\
      25    vector TYPE x = vec_ldl (0, b);					\
      26    vec_stl (x, 0, a);							\
      27  }									\
      28  
      29  #define TEST_VSX_COPY(NAME, TYPE)					\
      30  void NAME ## _copy_vsx (vector TYPE *a, vector TYPE *b)			\
      31  {									\
      32    vector TYPE x = vec_vsx_ld (0, b);					\
      33    vec_vsx_st (x, 0, a);							\
      34  }									\
      35  
      36  #define TEST_ALIGN(NAME, TYPE)						\
      37  void NAME ## _align (vector unsigned char *a, TYPE *b)			\
      38  {									\
      39    vector unsigned char x = vec_lvsl (0, b);				\
      40    vector unsigned char y = vec_lvsr (0, b);				\
      41    vec_st (x, 0, a);							\
      42    vec_st (y, 8, a);							\
      43  }
      44  
      45  #ifndef NO_COPY
      46  TEST_COPY(uchar,  unsigned char)
      47  TEST_COPY(schar,  signed   char)
      48  TEST_COPY(bchar,  bool     char)
      49  TEST_COPY(ushort, unsigned short)
      50  TEST_COPY(sshort, signed   short)
      51  TEST_COPY(bshort, bool     short)
      52  TEST_COPY(uint,   unsigned int)
      53  TEST_COPY(sint,   signed   int)
      54  TEST_COPY(bint,   bool     int)
      55  TEST_COPY(float,  float)
      56  TEST_COPY(double, double)
      57  #endif	/* NO_COPY */
      58  
      59  #ifndef NO_COPYL
      60  TEST_COPYL(uchar,  unsigned char)
      61  TEST_COPYL(schar,  signed   char)
      62  TEST_COPYL(bchar,  bool     char)
      63  TEST_COPYL(ushort, unsigned short)
      64  TEST_COPYL(sshort, signed   short)
      65  TEST_COPYL(bshort, bool     short)
      66  TEST_COPYL(uint,   unsigned int)
      67  TEST_COPYL(sint,   signed   int)
      68  TEST_COPYL(bint,   bool     int)
      69  TEST_COPYL(float,  float)
      70  TEST_COPYL(double, double)
      71  #endif	/* NO_COPYL */
      72  
      73  #ifndef NO_ALIGN
      74  TEST_ALIGN(uchar,  unsigned char)
      75  TEST_ALIGN(schar,  signed   char)
      76  TEST_ALIGN(ushort, unsigned short)
      77  TEST_ALIGN(sshort, signed   short)
      78  TEST_ALIGN(uint,   unsigned int)
      79  TEST_ALIGN(sint,   signed   int)
      80  TEST_ALIGN(float,  float)
      81  TEST_ALIGN(double, double)
      82  #endif	/* NO_ALIGN */
      83  
      84  
      85  #ifndef NO_VSX_COPY
      86  TEST_VSX_COPY(uchar,  unsigned char)
      87  TEST_VSX_COPY(schar,  signed   char)
      88  TEST_VSX_COPY(bchar,  bool     char)
      89  TEST_VSX_COPY(ushort, unsigned short)
      90  TEST_VSX_COPY(sshort, signed   short)
      91  TEST_VSX_COPY(bshort, bool     short)
      92  TEST_VSX_COPY(uint,   unsigned int)
      93  TEST_VSX_COPY(sint,   signed   int)
      94  TEST_VSX_COPY(bint,   bool     int)
      95  TEST_VSX_COPY(float,  float)
      96  TEST_VSX_COPY(double, double)
      97  #endif	/* NO_VSX_COPY */