(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
powerpc/
vsx-builtin-13b.c
       1  /* { dg-do run { target int128 } } */
       2  /* { dg-require-effective-target vsx_hw } */
       3  /* { dg-options "-mvsx -O3" } */
       4  
       5  /* This test should run the same on any target that supports vsx
       6     instructions.  Intentionally not specifying cpu in order to test
       7     all code generation paths.  */
       8  
       9  #include <altivec.h>
      10  
      11  /* Define this after PR89424 is addressed.  */
      12  #define PR89424
      13  
      14  /* Define this after PR89626 is addressed.  */
      15  #undef PR89626
      16  
      17  #ifdef PR89626
      18  #define SIGNED
      19  #else
      20  #define SIGNED signed
      21  #endif
      22  
      23  extern void abort (void);
      24  
      25  #define CONST0		(((SIGNED __int128) 31415926539) << 60)
      26  
      27  /* Test that indices > length of vector are applied modulo the vector
      28     length.  */
      29  
      30  /* Test for vector residing in register.  */
      31  SIGNED __int128 e0 (vector SIGNED __int128 v)
      32  {
      33    return __builtin_vec_ext_v1ti (v, 0);
      34  }
      35  
      36  SIGNED __int128 e3 (vector SIGNED __int128 v)
      37  {
      38    return __builtin_vec_ext_v1ti (v, 3);
      39  }
      40  
      41  /* Test for vector residing in memory.  */
      42  SIGNED __int128 me0 (vector SIGNED __int128 *vp)
      43  {
      44    return __builtin_vec_ext_v1ti (*vp, 0);
      45  }
      46  
      47  SIGNED __int128 me3 (vector SIGNED __int128 *vp)
      48  {
      49    return __builtin_vec_ext_v1ti (*vp, 3);
      50  }
      51  
      52  /* Test the same with variable indices.  */
      53  
      54  #ifdef PR89424
      55  /* Test for variable selector and vector residing in register.  */
      56  __attribute__((noinline))
      57  SIGNED __int128 ei (vector SIGNED __int128 v, int i)
      58  {
      59    return __builtin_vec_ext_v1ti (v, i);
      60  }
      61  
      62  /* Test for variable selector and vector residing in memory.  */
      63  SIGNED __int128 mei (vector SIGNED __int128 *vp, int i)
      64  {
      65    return __builtin_vec_ext_v1ti (*vp, i);
      66  }
      67  #endif
      68  
      69  int main (int argc, char *argv[]) {
      70    vector SIGNED __int128 dv = { CONST0 };
      71    SIGNED __int128 d;
      72  
      73    d = e0 (dv);
      74    if (d != CONST0)
      75      abort ();
      76  
      77    d = e3 (dv);
      78    if (d != CONST0)
      79      abort ();
      80  
      81    d = me0 (&dv);
      82    if (d != CONST0)
      83      abort ();
      84  
      85    d = me3 (&dv);
      86    if (d != CONST0)
      87      abort ();
      88  
      89  #ifdef PR89424
      90    d = ei (dv, 0);
      91    if (d != CONST0)
      92      abort ();
      93  
      94    d = ei (dv, 1);
      95    if (d != CONST0)
      96      abort ();
      97  
      98    d = ei (dv, 2);
      99    if (d != CONST0)
     100      abort ();
     101  
     102    d = ei (dv, 3);
     103    if (d != CONST0)
     104      abort ();
     105  
     106    d = mei (&dv, 0);
     107    if (d != CONST0)
     108      abort ();
     109  
     110    d = mei (&dv, 1);
     111    if (d != CONST0)
     112      abort ();
     113  
     114    d = mei (&dv, 2);
     115    if (d != CONST0)
     116      abort ();
     117  
     118    d = mei (&dv, 3);
     119    if (d != CONST0)
     120      abort ();
     121  #endif
     122  
     123    return 0;
     124  }