(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
powerpc/
ppc-target-4.c
       1  /* { dg-do compile { target { powerpc*-*-* } } } */
       2  /* { dg-skip-if "" { powerpc*-*-darwin* } } */
       3  /* { dg-require-effective-target powerpc_vsx_ok } */
       4  /* { dg-options "-O2 -ffast-math -mdejagnu-cpu=power5 -mno-altivec -mabi=altivec -fno-unroll-loops" } */
       5  /* { dg-final { scan-assembler-times "vaddfp" 1 } } */
       6  /* { dg-final { scan-assembler-times "xvaddsp" 1 } } */
       7  /* { dg-final { scan-assembler-times "fadds" 1 } } */
       8  
       9  #ifndef SIZE
      10  #define SIZE 1024
      11  #endif
      12  
      13  #ifdef __ALTIVEC__
      14  #error "__ALTIVEC__ should not be defined."
      15  #endif
      16  
      17  #ifdef __VSX__
      18  #error "__VSX__ should not be defined."
      19  #endif
      20  
      21  #pragma GCC target("vsx")
      22  #include <altivec.h>
      23  #pragma GCC reset_options
      24  
      25  #pragma GCC push_options
      26  #pragma GCC target("altivec,no-vsx")
      27  
      28  #ifndef __ALTIVEC__
      29  #error "__ALTIVEC__ should be defined."
      30  #endif
      31  
      32  #ifdef __VSX__
      33  #error "__VSX__ should not be defined."
      34  #endif
      35  
      36  void
      37  av_add (vector float *a, vector float *b, vector float *c)
      38  {
      39    unsigned long i;
      40    unsigned long n = SIZE / 4;
      41  
      42    for (i = 0; i < n; i++)
      43      a[i] = vec_add (b[i], c[i]);
      44  }
      45  
      46  #pragma GCC target("vsx")
      47  
      48  #ifndef __ALTIVEC__
      49  #error "__ALTIVEC__ should be defined."
      50  #endif
      51  
      52  #ifndef __VSX__
      53  #error "__VSX__ should be defined."
      54  #endif
      55  
      56  void
      57  vsx_add (vector float *a, vector float *b, vector float *c)
      58  {
      59    unsigned long i;
      60    unsigned long n = SIZE / 4;
      61  
      62    for (i = 0; i < n; i++)
      63      a[i] = vec_add (b[i], c[i]);
      64  }
      65  
      66  #pragma GCC pop_options
      67  #pragma GCC target("no-vsx,no-altivec")
      68  
      69  #ifdef __ALTIVEC__
      70  #error "__ALTIVEC__ should not be defined."
      71  #endif
      72  
      73  #ifdef __VSX__
      74  #error "__VSX__ should not be defined."
      75  #endif
      76  
      77  void
      78  norm_add (float *a, float *b, float *c)
      79  {
      80    unsigned long i;
      81  
      82    for (i = 0; i < SIZE; i++)
      83      a[i] = b[i] + c[i];
      84  }