(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
powerpc/
altivec-cell-8.c
       1  /* { dg-do run { target { powerpc*-*-* && cell_hw } } } */
       2  /* { dg-do compile { target { powerpc*-*-* && { ! cell_hw } } } } */
       3  /* { dg-require-effective-target powerpc_ppu_ok } */
       4  /* { dg-options "-O2 -maltivec -mabi=altivec -mdejagnu-cpu=cell" } */
       5  #include <altivec.h>
       6  #include <string.h>
       7  
       8  extern void abort (void);
       9  
      10  typedef short int sint16;
      11  typedef signed char int8;
      12  
      13  int main1(void) __attribute__((noinline));
      14  int main1(void)
      15  {
      16      sint16 test_vector[4] = { 1678, -2356, 19246, -17892 };
      17      int8 test_dst[128] __attribute__(( aligned( 16 )));
      18      float test_out[4] __attribute__(( aligned( 16 )));
      19      int p;
      20  
      21      for( p = 0; p < 24; ++p )
      22      {
      23          memset( test_dst, 0, 128 );
      24          memcpy( &test_dst[p], test_vector, 8 );
      25          {
      26              vector float VR, VL, V;
      27     /* load the righthand section of the misaligned vector */
      28              VR = (vector float) vec_lvrx( 8, &test_dst[p] );
      29              VL = (vector float) vec_lvlx( 0, &test_dst[p] );
      30     /* Vector Shift Left Double by Octet Immediate, move the right hand section into the bytes */
      31              VR = vec_vsldoi( VR, VR, 2 << 2 ); 
      32     /* or those two together */
      33              V = vec_vor( VL, VR );
      34     /* sign extend */
      35              V = (vector float) vec_vupkhsh((vector bool short)V );
      36     /* fixed to float by S16_SHIFT_BITS bits */
      37              V = (vector float) vec_vcfsx ((vector signed int)V, 5 ); 
      38  
      39              vec_stvx( V, 0, &test_out[0] );
      40              if (test_out[0] != 52.437500)
      41                  abort ();
      42              if (test_out[1] != -73.625000)
      43                  abort ();
      44              if (test_out[2] != 601.437500)
      45                  abort ();
      46              if (test_out[3] != -559.125000)
      47                  abort ();
      48          }
      49      }
      50  return 0;
      51  }
      52  
      53  
      54  int main(void)
      55  {
      56    return main1();
      57  }