1 /* { dg-do run } */ 2 /* { dg-options "-O2 -ftree-loop-distribution" } */ 3 4 /* Checks if loop distribution works correctly if the subscript used 5 is assigned to a loop invariant value. */ 6 7 extern void abort (void); 8 struct S { int a; int b; int c; }; 9 get_rr_node_index(int i)10int get_rr_node_index (int i) 11 { 12 return i; 13 } 14 15 struct S nodes[8]; 16 struct S *rr_node = nodes; 17 volatile int io_rat = 2; 18 void doit(int i,int j)19doit (int i, int j) 20 { 21 int s_node, p_node, inode, ipad, iloop; 22 23 for (ipad = 0; ipad < io_rat; ipad++) 24 { 25 p_node = get_rr_node_index (ipad+2); 26 inode = get_rr_node_index (ipad); 27 28 for (iloop = 1; iloop <= 2; iloop++) 29 { 30 rr_node[inode].a = i; 31 rr_node[inode].b = j; 32 rr_node[inode].c = ipad; 33 inode = p_node; 34 } 35 } 36 } 37 38 int main()39main () 40 { 41 int i; 42 43 doit (1, 2); 44 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 (); 56 57 return 0; 58 } 59