annotate gcc/testsuite/gcc.dg/vmx/gcc-bug-i.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 #include "harness.h"
kono
parents:
diff changeset
2
kono
parents:
diff changeset
3 /* This problem occurs if a function is inlined. When its local
kono
parents:
diff changeset
4 variables get allocated space on the caller's (the function to
kono
parents:
diff changeset
5 which it is inlined) stack frame, they don't get 16-byte alignment
kono
parents:
diff changeset
6 even if they need it. Here's an example with a union (that's the
kono
parents:
diff changeset
7 first case I uncovered, but it's probably a general occurrence on
kono
parents:
diff changeset
8 inlining). */
kono
parents:
diff changeset
9
kono
parents:
diff changeset
10 #define N 10
kono
parents:
diff changeset
11 /* adjust N = size of buffer to try to get bad alignment for inlined union */
kono
parents:
diff changeset
12
kono
parents:
diff changeset
13 #define DO_INLINE __attribute__ ((always_inline))
kono
parents:
diff changeset
14 #define DONT_INLINE __attribute__ ((noinline))
kono
parents:
diff changeset
15
kono
parents:
diff changeset
16 #ifdef __LITTLE_ENDIAN__
kono
parents:
diff changeset
17 static inline DO_INLINE int inline_me(vector signed short data)
kono
parents:
diff changeset
18 {
kono
parents:
diff changeset
19 union {vector signed short v; signed short s[8];} u;
kono
parents:
diff changeset
20 signed short x;
kono
parents:
diff changeset
21 unsigned char x1, x2;
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 u.v = data;
kono
parents:
diff changeset
24 x = u.s[7];
kono
parents:
diff changeset
25 x1 = (x >> 8) & 0xff;
kono
parents:
diff changeset
26 x2 = x & 0xff;
kono
parents:
diff changeset
27 return ((x2 << 8) | x1);
kono
parents:
diff changeset
28 }
kono
parents:
diff changeset
29 #else
kono
parents:
diff changeset
30 static inline DO_INLINE int inline_me(vector signed short data)
kono
parents:
diff changeset
31 {
kono
parents:
diff changeset
32 union {vector signed short v; signed short s[8];} u;
kono
parents:
diff changeset
33 u.v = data;
kono
parents:
diff changeset
34 return u.s[7];
kono
parents:
diff changeset
35 }
kono
parents:
diff changeset
36 #endif
kono
parents:
diff changeset
37
kono
parents:
diff changeset
38 static DONT_INLINE int foo(vector signed short data)
kono
parents:
diff changeset
39 {
kono
parents:
diff changeset
40 int c, buffer[N], i;
kono
parents:
diff changeset
41 c = inline_me(data);
kono
parents:
diff changeset
42 for (i=0; i<N; i++) {
kono
parents:
diff changeset
43 if (i == 0)
kono
parents:
diff changeset
44 buffer[i] = c;
kono
parents:
diff changeset
45 else
kono
parents:
diff changeset
46 buffer[i] = buffer[i-1] + c*i;
kono
parents:
diff changeset
47 }
kono
parents:
diff changeset
48 return buffer[N-1];
kono
parents:
diff changeset
49 }
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 static void test()
kono
parents:
diff changeset
52 {
kono
parents:
diff changeset
53 check(foo((vector signed short)
kono
parents:
diff changeset
54 ((vector unsigned char){1,2,3,4,5,6,7,8,
kono
parents:
diff changeset
55 9,10,11,12,13,14,15,16})) == 0x2b4e0,
kono
parents:
diff changeset
56 "foo");
kono
parents:
diff changeset
57 }