1  /* { dg-do compile } */
       2  /* { dg-require-effective-target powerpc_p9vector_ok } */
       3  /* { dg-options "-O2 -mdejagnu-cpu=power9" } */
       4  /* { dg-final { scan-assembler-times {\mxvmaxdp\M} 1 } } */
       5  /* { dg-final { scan-assembler-times {\mxvmaxsp\M} 1 } } */
       6  /* { dg-final { scan-assembler-times {\mxvmindp\M} 1 } } */
       7  /* { dg-final { scan-assembler-times {\mxvminsp\M} 1 } } */
       8  
       9  /* This test verifies that float or double vec_min/max are bound to
      10     xv[min|max][d|s]p instructions when fast-math is not set.  */
      11  
      12  
      13  #include <altivec.h>
      14  
      15  #ifdef _BIG_ENDIAN
      16     const int PREF_D = 0;
      17  #else
      18     const int PREF_D = 1;
      19  #endif
      20  
      21  double vmaxd (double a, double b)
      22  {
      23    vector double va = vec_promote (a, PREF_D);
      24    vector double vb = vec_promote (b, PREF_D);
      25    return vec_extract (vec_max (va, vb), PREF_D);
      26  }
      27  
      28  double vmind (double a, double b)
      29  {
      30    vector double va = vec_promote (a, PREF_D);
      31    vector double vb = vec_promote (b, PREF_D);
      32    return vec_extract (vec_min (va, vb), PREF_D);
      33  }
      34  
      35  #ifdef _BIG_ENDIAN
      36     const int PREF_F = 0;
      37  #else
      38     const int PREF_F = 3;
      39  #endif
      40  
      41  float vmaxf (float a, float b)
      42  {
      43    vector float va = vec_promote (a, PREF_F);
      44    vector float vb = vec_promote (b, PREF_F);
      45    return vec_extract (vec_max (va, vb), PREF_F);
      46  }
      47  
      48  float vminf (float a, float b)
      49  {
      50    vector float va = vec_promote (a, PREF_F);
      51    vector float vb = vec_promote (b, PREF_F);
      52    return vec_extract (vec_min (va, vb), PREF_F);
      53  }