(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
powerpc/
pr85698.c
       1  /* { dg-do run } */
       2  /* { dg-require-effective-target vsx_hw } */
       3  /* { dg-options "-O3 -mdejagnu-cpu=power7" } */
       4  
       5  /* PR85698: Incorrect code generated on LE due to use of stxvw4x. */
       6  
       7  typedef unsigned char uint8_t;
       8  typedef short int16_t;
       9  extern void abort (void);
      10  extern int memcmp(const void *, const void *, __SIZE_TYPE__);
      11  
      12  uint8_t expected[128] =
      13  {14, 0, 4, 2, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
      14   22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 28, 35, 33, 35, 36, 37, 38, 39, 40,
      15   41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
      16   60, 61, 62, 63, 66, 63, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
      17   79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 97, 96,
      18   98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
      19   114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127};
      20  
      21  static uint8_t x264_clip_uint8( int x )
      22  {
      23    return x&(~255) ? (-x)>>31 : x;
      24  }
      25  void add4x4_idct( uint8_t *p_dst, int16_t dct[16])
      26  {
      27    int16_t d[16];
      28    int16_t tmp[16];
      29    int i, y, x;
      30    for( i = 0; i < 4; i++ )
      31      {
      32        int s02 =  dct[0*4+i]     +  dct[2*4+i];
      33        int d02 =  dct[0*4+i]     -  dct[2*4+i];
      34        int s13 =  dct[1*4+i]     + (dct[3*4+i]>>1);
      35        int d13 = (dct[1*4+i]>>1) -  dct[3*4+i];
      36        tmp[i*4+0] = s02 + s13;
      37        tmp[i*4+1] = d02 + d13;
      38        tmp[i*4+2] = d02 - d13;
      39        tmp[i*4+3] = s02 - s13;
      40      }
      41    for( i = 0; i < 4; i++ )
      42      {
      43        int s02 =  tmp[0*4+i]     +  tmp[2*4+i];
      44        int d02 =  tmp[0*4+i]     -  tmp[2*4+i];
      45        int s13 =  tmp[1*4+i]     + (tmp[3*4+i]>>1);
      46        int d13 = (tmp[1*4+i]>>1) -  tmp[3*4+i];
      47        d[0*4+i] = ( s02 + s13 + 32 ) >> 6;
      48        d[1*4+i] = ( d02 + d13 + 32 ) >> 6;
      49        d[2*4+i] = ( d02 - d13 + 32 ) >> 6;
      50        d[3*4+i] = ( s02 - s13 + 32 ) >> 6;
      51      }
      52    for( y = 0; y < 4; y++ )
      53      {
      54        for( x = 0; x < 4; x++ )
      55          p_dst[x] = x264_clip_uint8( p_dst[x] + d[y*4+x] );
      56        p_dst += 32;
      57      }
      58  }
      59  
      60  int main()
      61  {
      62    uint8_t dst[128];
      63    int16_t dct[16];
      64    int i;
      65  
      66    for (i = 0; i < 16; i++)
      67      dct[i] = i*10 + i;
      68    for (i = 0; i < 128; i++)
      69      dst[i] = i;
      70  
      71    add4x4_idct(dst, dct);
      72  
      73    if (memcmp (dst, expected, 128))
      74      abort();
      75  
      76   return 0;
      77  }
      78