OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.dg/] [vmx/] [gcc-bug-i.c] - Blame information for rev 816

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
#include "harness.h"
2
 
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).  */
9
 
10
#define N 10
11
/* adjust N = size of buffer to try to get bad alignment for inlined union */
12
 
13
#define DO_INLINE __attribute__ ((always_inline))
14
#define DONT_INLINE __attribute__ ((noinline))
15
 
16
static DO_INLINE int inline_me(vector signed short data)
17
{
18
  union {vector signed short v; signed short s[8];} u;
19
  u.v = data;
20
  return u.s[7];
21
}
22
 
23
static DONT_INLINE int foo(vector signed short data)
24
{
25
  int c, buffer[N], i;
26
  c = inline_me(data);
27
  for (i=0; i<N; i++) {
28
    if (i == 0)
29
      buffer[i] = c;
30
    else
31
      buffer[i] = buffer[i-1] + c*i;
32
  }
33
  return buffer[N-1];
34
}
35
 
36
static void test()
37
{
38
  check(foo((vector signed short)
39
            ((vector unsigned char){1,2,3,4,5,6,7,8,
40
                                   9,10,11,12,13,14,15,16})) == 0x2b4e0,
41
        "foo");
42
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.