In gcc/testsuite/: 2011-03-04 Nicola Pero <nicola.pero@meta-innovation.com>
[official-gcc.git] / gcc / testsuite / gcc.dg / 20050922-1.c
blobed5a3c63e9d2dbfb84d8abe0f9f285b8eb1febdd
1 /* This revealed a bug when rotates are expanded into
2 two shifts. */
4 /* { dg-do run } */
5 /* { dg-options "-O1 -std=c99" } */
7 #include <stdlib.h>
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
17 uint32_t
18 f (uint32_t *S, int j)
20 uint32_t A, B, k, L[2] = {1234, 5678};
21 int i, m;
23 A = B = 0;
24 for (i = 0; i < j; i++)
26 k = (S[i] + A + B) & 0xffffffffL;
27 A = S[i] =
28 ((k << (3 & 0x1f)) | ((k & 0xffffffff) >> (32 - (3 & 0x1f))));
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))));
35 return L[0] + L[1];
38 int
39 main ()
41 uint32_t S[2] = {0xffff, 0xffffff};
43 if (f (S,2)!= 1392607300)
44 abort();
46 return 0;