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