i386: Support wide immediate constants in STV.
[official-gcc.git] / gcc / testsuite / gcc.dg / vmx / gcc-bug-i.c
blob3e0e6a0793eef5c105c071d6dad1f77e845bcabc
1 #include "harness.h"
3 /* This problem occurs if a function is inlined. When its local
4 variables get allocated space on the caller's (the function to
5 which it is inlined) stack frame, they don't get 16-byte alignment
6 even if they need it. Here's an example with a union (that's the
7 first case I uncovered, but it's probably a general occurrence on
8 inlining). */
10 #define N 10
11 /* adjust N = size of buffer to try to get bad alignment for inlined union */
13 #define DO_INLINE __attribute__ ((always_inline))
14 #define DONT_INLINE __attribute__ ((noinline))
16 #ifdef __LITTLE_ENDIAN__
17 static inline DO_INLINE int inline_me(vector signed short data)
19 union {vector signed short v; signed short s[8];} u;
20 signed short x;
21 unsigned char x1, x2;
23 u.v = data;
24 x = u.s[7];
25 x1 = (x >> 8) & 0xff;
26 x2 = x & 0xff;
27 return ((x2 << 8) | x1);
29 #else
30 static inline DO_INLINE int inline_me(vector signed short data)
32 union {vector signed short v; signed short s[8];} u;
33 u.v = data;
34 return u.s[7];
36 #endif
38 static DONT_INLINE int foo(vector signed short data)
40 int c, buffer[N], i;
41 c = inline_me(data);
42 for (i=0; i<N; i++) {
43 if (i == 0)
44 buffer[i] = c;
45 else
46 buffer[i] = buffer[i-1] + c*i;
48 return buffer[N-1];
51 static void test()
53 check(foo((vector signed short)
54 ((vector unsigned char){1,2,3,4,5,6,7,8,
55 9,10,11,12,13,14,15,16})) == 0x2b4e0,
56 "foo");