[testsuite] require sqrt_insn effective target where needed
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / pr85698.c
blobf63494ca2b7ec3616767e7b2b7c0b4807a25c26f
1 /* { dg-do run } */
2 /* { dg-require-effective-target vsx_hw } */
3 /* { dg-options "-O3 -mdejagnu-cpu=power7" } */
5 /* PR85698: Incorrect code generated on LE due to use of stxvw4x. */
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__);
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};
21 static uint8_t x264_clip_uint8( int x )
23 return x&(~255) ? (-x)>>31 : x;
25 void add4x4_idct( uint8_t *p_dst, int16_t dct[16])
27 int16_t d[16];
28 int16_t tmp[16];
29 int i, y, x;
30 for( i = 0; i < 4; i++ )
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;
41 for( i = 0; i < 4; i++ )
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;
52 for( y = 0; y < 4; y++ )
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;
60 int main()
62 uint8_t dst[128];
63 int16_t dct[16];
64 int i;
66 for (i = 0; i < 16; i++)
67 dct[i] = i*10 + i;
68 for (i = 0; i < 128; i++)
69 dst[i] = i;
71 add4x4_idct(dst, dct);
73 if (memcmp (dst, expected, 128))
74 abort();
76 return 0;