Debian Codegraph @

gcc/testsuite/gcc.target/pru/loop-u8_pcrel_overflow.c

raw
1 /* Test large loop bodies where U8_PCREL would overflow */
2
3 /* { dg-do run } */
4 /* { dg-options "-O1 -mloop" } */
5
6 /* -O1 in the options is significant. Without it do-loop will not be
7 run. */
8
9 extern void abort (void);
10
11 #define OP do { i1 <<= 2; i1 >>= 2; i2 *= 3; i2 /= 2; } while(0)
12 #define OP4 OP; OP; OP; OP
13 #define OP16 OP4; OP4; OP4; OP4
14 #define OP64 OP16; OP16; OP16; OP16
15 #define OP256 OP64; OP64; OP64; OP64
16
17 unsigned int
18 test_loop (unsigned int i1, unsigned i2)
19 {
20 unsigned int i;
21 volatile unsigned int s = 0;
22
23 for (i = 0; i < 100; i++) {
24 /* cannot use ASM NOP because it will prevent
25 GCC from issuing a LOOP instruction. */
26 OP256;
27 s++;
28 }
29 return s + i1 + i2;
30 }
31
32 volatile unsigned int I1 = 0;
33 volatile unsigned int I2 = 0;
34
35 int
36 main (int argc, char** argv)
37 {
38 if (test_loop (I1, I2) != 100)
39 abort();
40
41 return 0;
42 }