(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
powerpc/
vec-minmax-2.c
       1  /* { dg-do compile } */
       2  /* { dg-require-effective-target powerpc_p9vector_ok } */
       3  /* { dg-options "-O2 -mdejagnu-cpu=power9 -ffast-math" } */
       4  /* { dg-final { scan-assembler-times {\mxsmaxcdp\M} 2 } } */
       5  /* { dg-final { scan-assembler-times {\mxsmincdp\M} 2 } } */
       6  
       7  /* This test verifies that float or double vec_min/max can be converted
       8     to scalar comparison when fast-math is set.  */
       9  
      10  
      11  #include <altivec.h>
      12  
      13  #ifdef _BIG_ENDIAN
      14     const int PREF_D = 0;
      15  #else
      16     const int PREF_D = 1;
      17  #endif
      18  
      19  double vmaxd (double a, double b)
      20  {
      21    vector double va = vec_promote (a, PREF_D);
      22    vector double vb = vec_promote (b, PREF_D);
      23    return vec_extract (vec_max (va, vb), PREF_D);
      24  }
      25  
      26  double vmind (double a, double b)
      27  {
      28    vector double va = vec_promote (a, PREF_D);
      29    vector double vb = vec_promote (b, PREF_D);
      30    return vec_extract (vec_min (va, vb), PREF_D);
      31  }
      32  
      33  #ifdef _BIG_ENDIAN
      34     const int PREF_F = 0;
      35  #else
      36     const int PREF_F = 3;
      37  #endif
      38  
      39  float vmaxf (float a, float b)
      40  {
      41    vector float va = vec_promote (a, PREF_F);
      42    vector float vb = vec_promote (b, PREF_F);
      43    return vec_extract (vec_max (va, vb), PREF_F);
      44  }
      45  
      46  float vminf (float a, float b)
      47  {
      48    vector float va = vec_promote (a, PREF_F);
      49    vector float vb = vec_promote (b, PREF_F);
      50    return vec_extract (vec_min (va, vb), PREF_F);
      51  }