1  /* { dg-do run { target { powerpc*-*-* } } } */
       2  /* { dg-require-effective-target int128 } */
       3  /* { dg-require-effective-target p9vector_hw } */
       4  /* { dg-options "-mdejagnu-cpu=power9" } */
       5  
       6  #include <altivec.h>
       7  #include <stdbool.h>
       8  #include <stdlib.h>
       9  
      10  bool
      11  test_nan (__ieee128 *p)
      12  {
      13    __ieee128 source = *p;
      14  
      15    /*
      16      0x40    Test for NaN
      17      0x20    Test for +Infinity
      18      0x10    Test for -Infinity
      19      0x08    Test for +Zero
      20      0x04    Test for -Zero
      21      0x02    Test for +Denormal
      22      0x01    Test for -Denormal
      23    */
      24    return scalar_test_data_class (source, 0x40);
      25  }
      26  
      27  int
      28  main ()
      29  {
      30    /* NaN is represented with the maximum biased exponent value and a
      31     *  non-zero fraction value. The sign bit ignored.  If the
      32     *  high-order bit of the fraction field is 0, then the NaN is a
      33     *  Signaling NaN.  Otherwise, it is a Quiet NaN.  */
      34    __int128 signal_significand = (__int128) 0xffffffff;
      35    __int128 quiet_significand = (((__int128) 0x1) << 112) | 0xffffffff;
      36    __int128 a_number_significand = (((__int128) 0x1) << 112);
      37    unsigned long long int nan_exponent = 0x7fff;
      38    unsigned long long int a_number_exponent = 16383;
      39  
      40    __ieee128 signaling_nan =
      41      scalar_insert_exp (signal_significand, nan_exponent);
      42    __ieee128 quiet_nan =
      43      scalar_insert_exp (quiet_significand, nan_exponent);
      44    __ieee128 a_number =
      45      scalar_insert_exp (a_number_significand, a_number_exponent);
      46  
      47    if (!test_nan (&signaling_nan))
      48      abort ();
      49    if (!test_nan (&quiet_nan))
      50      abort ();
      51    if (test_nan (&a_number))
      52      abort ();
      53    return 0;
      54  }