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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [torture/] [pr48702.c] - Blame information for rev 754

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* { dg-do run } */
2
 
3
extern void abort (void);
4
 
5
#define LEN 4
6
 
7
static inline void unpack(int  array[LEN])
8
{
9
  int ii, val;
10
  val = 1;
11
  for (ii = 0; ii < LEN; ii++) {
12
      array[ii] = val % 2;
13
      val = val / 2;
14
  }
15
}
16
 
17
static inline int  pack(int  array[LEN])
18
{
19
  int ans, ii;
20
  ans = 0;
21
  for (ii = LEN-1; ii >= 0; ii--) {
22
      ans = 2 * ans + array[ii];
23
  }
24
  return ans;
25
}
26
 
27
int __attribute__((noinline))
28
foo()
29
{
30
  int temp, ans;
31
  int array[LEN];
32
  unpack(array);
33
  temp = array[0];
34
  array[0] = array[2];
35
  array[2] = temp;
36
  ans = pack(array);
37
  return ans;
38
}
39
 
40
int main(void)
41
{
42
  int val;
43
  val = foo();
44
  if (val != 4)
45
    abort ();
46
  return 0;
47
}

powered by: WebSVN 2.1.0

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