OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [20050922-1.c] - Blame information for rev 298

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 298 jeremybenn
/* This revealed a bug when rotates are expanded into
2
   two shifts.  */
3
 
4
/* { dg-do run } */
5
/* { dg-options "-O1 -std=c99" } */
6
 
7
#include <stdlib.h>
8
 
9
#if __INT_MAX__ == 2147483647
10
typedef unsigned int uint32_t;
11
#elif __LONG_MAX__ == 2147483647
12
typedef unsigned long uint32_t;
13
#else
14
#error unable to find 32-bit integer type
15
#endif
16
 
17
uint32_t
18
f (uint32_t *S, int j)
19
{
20
  uint32_t A, B, k, L[2] = {1234, 5678};
21
  int i, m;
22
 
23
  A = B = 0;
24
  for (i = 0; i < j; i++)
25
    {
26
      k = (S[i] + A + B) & 0xffffffffL;
27
      A = S[i] =
28
      ((k << (3 & 0x1f)) | ((k & 0xffffffff) >> (32 - (3 & 0x1f))));
29
 
30
      m = (int) (A + B);
31
      k = (L[i] + A + B) & 0xffffffffL;
32
      B = L[i] =
33
        ((k << (m & 0x1f)) | ((k & 0xffffffff) >> (32 - (m & 0x1f))));
34
    }
35
  return L[0] + L[1];
36
}
37
 
38
int
39
main ()
40
{
41
  uint32_t S[2] = {0xffff, 0xffffff};
42
 
43
  if (f (S,2)!= 1392607300)
44
    abort();
45
 
46
  return 0;
47
}

powered by: WebSVN 2.1.0

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