[committed] Fix previously latent bug in reorg affecting cris port
[official-gcc.git] / gcc / testsuite / gcc.target / powerpc / pr87532.c
blob4b07f07258f3256d0e688461049d137e43c7d9b5
1 /* { dg-do run } */
2 /* { dg-require-effective-target vmx_hw } */
3 /* { dg-options "-maltivec" } */
5 /* This test should run the same on any target that supports altivec/dfp
6 instructions. Intentionally not specifying cpu in order to test
7 all code generation paths. */
9 #include <stdlib.h>
10 #include <stddef.h>
11 #include <altivec.h>
12 #include <stdio.h>
14 static void
15 check (unsigned char, unsigned char) __attribute__((__noinline__));
17 static __attribute__((altivec(vector__))) unsigned char
18 deoptimize (__attribute__((altivec(vector__))) unsigned char)
19 __attribute__((__noinline__));
21 static __attribute__((altivec(vector__))) unsigned char
22 deoptimize (__attribute__((altivec(vector__))) unsigned char a)
24 __asm__ (" # %x0" : "+v" (a));
25 return a;
28 // Toggle this attribute inline/noinline to see pass/fail.
29 // fails with the noinline attribute applied.
30 __attribute__ ((__noinline__))
31 unsigned char
32 get_auto_n (__attribute__((altivec(vector__))) unsigned char a, size_t n)
34 return (unsigned char) __builtin_vec_extract (a, n);
37 void
38 do_auto (__attribute__((altivec(vector__))) unsigned char a)
40 size_t i;
41 for (i = 1; i < 3 ; i++)
45 printf ("get_auto_n (a, %d) produces 0x0%x\n",
46 i, (int) get_auto_n (a, i));
48 if ((int) get_auto_n (a,i) > 250) abort();
49 } while (0);
53 int
54 main (void)
56 size_t i;
57 __attribute__((altivec(vector__))) unsigned char x =
58 { 3, 2, 3, 8, 5, 6, 7, 8, 240, 241, 242, 243, 244, 245, 246, 247 };
59 __attribute__((altivec(vector__))) unsigned char a;
61 printf (" first elements of x are: %d %d %d %d %d\n",
62 x[0], x[1], x[2], x[3], x[4]);
64 a = deoptimize (x);
66 printf (" after deoptimization, first elements of a are: %d %d %d %d %d\n",
67 a[0], a[1], a[2], a[3], a[4]);
69 do_auto (a);
71 return 0;