1  /* { dg-do run } */
       2  /* { dg-options "-O2 -mavx512f -std=gnu99" } */
       3  /* { dg-require-effective-target avx512f } */
       4  /* { dg-require-effective-target c99_runtime } */
       5  
       6  #define AVX512F
       7  
       8  #include "avx512f-helper.h"
       9  
      10  #define SIZE (AVX512F_LEN / 64)
      11  #include "avx512f-mask-type.h"
      12  #include "math_m_pi.h"
      13  #include "float.h"
      14  
      15  
      16  static void
      17  CALC (double *r, double dest, double src, long long tbl)
      18  {
      19    switch (tbl & 0xf)
      20      {
      21      case 0:
      22        *r = dest;
      23        break;
      24      case 1:
      25        *r = src;
      26        break;
      27      case 2:
      28        *r = signbit (src) ? -NAN : NAN;
      29        break;
      30      case 3:
      31        *r = -NAN;
      32        break;
      33      case 4:
      34        *r = -INFINITY;
      35        break;
      36      case 5:
      37        *r = INFINITY;
      38        break;
      39      case 6:
      40        *r = signbit (src) ? -INFINITY : INFINITY;
      41        break;
      42      case 7:
      43        *r = 1.0 / -INFINITY;
      44        break;
      45      case 8:
      46        *r = 0.0;
      47        break;
      48      case 9:
      49        *r = -1.0;
      50        break;
      51      case 10:
      52        *r = 1.0;
      53        break;
      54      case 11:
      55        *r = 1.0 / 2.0;
      56        break;
      57      case 12:
      58        *r = 90.0;
      59        break;
      60      case 13:
      61        *r = M_PI_2;
      62        break;
      63      case 14:
      64        *r = DBL_MAX;
      65        break;
      66      case 15:
      67        *r = -DBL_MAX;
      68        break;
      69      default:
      70        abort ();
      71      }
      72  }
      73  
      74  void
      75  TEST (void)
      76  {
      77    int i, j;
      78    UNION_TYPE (AVX512F_LEN, d) res1, res2, res3, s1;
      79    UNION_TYPE (AVX512F_LEN, i_q) s2;
      80    double res_ref[SIZE];
      81  
      82  
      83    float vals[2] = { -10, 10 };
      84    int controls[8] = {0, 0x11111111, 0x77777777, 0x88888888,
      85      0x99999999, 0xaaaaaaaa, 0xbbbbbbbb, 0xcccccccc};
      86  
      87    MASK_TYPE mask = MASK_VALUE;
      88  
      89    for (i = 0; i < 2; i++)
      90      {
      91        for (j = 0; j < SIZE; j++)
      92  	{
      93  	  s1.a[j] = vals[i];
      94  	  s2.a[j] = controls[j];
      95  	  res1.a[j] = DEFAULT_VALUE;
      96  	  res2.a[j] = DEFAULT_VALUE;
      97  	  res3.a[j] = DEFAULT_VALUE;
      98  
      99  	  CALC (&res_ref[j], res1.a[j], s1.a[j], s2.a[j]);
     100  	}
     101  
     102        res1.x = INTRINSIC (_fixupimm_pd) (res1.x, s1.x, s2.x, 0);
     103        res2.x = INTRINSIC (_mask_fixupimm_pd) (res2.x, mask, s1.x, s2.x, 0);
     104        res3.x = INTRINSIC (_maskz_fixupimm_pd) (mask, res3.x, s1.x, s2.x, 0);
     105  
     106        if (UNION_CHECK (AVX512F_LEN, d) (res1, res_ref))
     107  	abort ();
     108  
     109        MASK_MERGE(d) (res_ref, mask, SIZE);
     110        if (UNION_CHECK (AVX512F_LEN, d) (res2, res_ref))
     111  	abort ();
     112        MASK_ZERO(d) (res_ref, mask, SIZE);
     113        if (UNION_CHECK (AVX512F_LEN, d) (res3, res_ref))
     114  	abort ();
     115      }
     116  }
     117