Debian Codegraph @

gcc/testsuite/gcc.target/cris/pr93372-47.c

raw
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -march=v10" } */
3 /* { dg-final { scan-assembler-times {\tnop} 1 } } */
4
5 /* A somewhat brittle test-case, checking that we have (only) one
6 unfilled delay-slot in random_bitstring: there might be none or two
7 or more, and general improvements may lead to unfilled delay-slots.
8 When the scan-assembler-times directive regresses, re-run
9 gcc.c-torture/execute/arith-rand-ll.c, check cycle-level
10 execution-time regressions in random_bitstring and take appropriate
11 action. */
12
13 static long long
14 simple_rand ()
15 {
16 static unsigned long long seed = 47114711;
17 unsigned long long this = seed * 1103515245 + 12345;
18 seed = this;
19 return this >> 8;
20 }
21
22 unsigned long long int
23 random_bitstring ()
24 {
25 unsigned long long int x;
26 int n_bits;
27 long long ran;
28 int tot_bits = 0;
29
30 x = 0;
31 for (;;)
32 {
33 ran = simple_rand ();
34 n_bits = (ran >> 1) % 16;
35 tot_bits += n_bits;
36
37 if (n_bits == 0)
38 return x;
39 else
40 {
41 x <<= n_bits;
42 if (ran & 1)
43 x |= (1 << n_bits) - 1;
44
45 if (tot_bits > 8 * sizeof (long long) + 6)
46 return x;
47 }
48 }
49 }