2018-04-30 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / pr42640.c
blob70807c091d6e75252f67f1579b46c02eea8afbc5
1 /* { dg-do run } */
2 /* { dg-options "-O2 -ftree-loop-distribution" } */
4 /* Checks if loop distribution works correctly if the subscript used
5 is assigned to a loop invariant value. */
7 extern void abort (void);
8 struct S { int a; int b; int c; };
10 int get_rr_node_index (int i)
12 return i;
15 struct S nodes[8];
16 struct S *rr_node = nodes;
17 volatile int io_rat = 2;
18 void
19 doit (int i, int j)
21 int s_node, p_node, inode, ipad, iloop;
23 for (ipad = 0; ipad < io_rat; ipad++)
25 p_node = get_rr_node_index (ipad+2);
26 inode = get_rr_node_index (ipad);
28 for (iloop = 1; iloop <= 2; iloop++)
30 rr_node[inode].a = i;
31 rr_node[inode].b = j;
32 rr_node[inode].c = ipad;
33 inode = p_node;
38 int
39 main ()
41 int i;
43 doit (1, 2);
45 if (rr_node[0].a != rr_node[1].a
46 || rr_node[2].a != rr_node[3].a
47 || rr_node[1].a != 1
48 || rr_node[0].b != rr_node[1].b
49 || rr_node[2].b != rr_node[3].b
50 || rr_node[1].b != 2
51 || rr_node[0].c != 0
52 || rr_node[1].c != 1
53 || rr_node[2].c != 0
54 || rr_node[3].c != 1)
55 abort ();
57 return 0;