1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fipa-sra -fdump-tree-eipa_sra-details"  } */
3 
4 struct bovid
5 {
6   float red;
7   int green;
8   void *blue;
9 };
10 
11 static int
12 __attribute__((noinline))
ox(struct bovid * cow)13 ox (struct bovid *cow)
14 {
15   cow->red = cow->red + cow->green + cow->green;
16   return 0;
17 }
18 
19 int something;
20 
21 static int
22 __attribute__((noinline))
ox_improved(struct bovid * calf)23 ox_improved (struct bovid *calf)
24 {
25   if (something > 0)
26     calf->red = calf->red + calf->green;
27   else
28     calf->red = calf->green + 87;
29   something = 77;
30   return 0;
31 }
32 
33 
main(int argc,char * argv[])34 int main (int argc, char *argv[])
35 {
36   struct bovid cow;
37 
38   cow.red = 7.4;
39   cow.green = 6;
40   cow.blue = &cow;
41 
42   ox (&cow);
43 
44   ox_improved (&cow);
45   return 0;
46 }
47 
48 /* { dg-final { scan-tree-dump "About to replace expr cow_.*D.->red with \\*ISRA" "eipa_sra"  } } */
49 /* { dg-final { scan-tree-dump "About to replace expr cow_.*D.->green with ISRA" "eipa_sra"  } } */
50 /* { dg-final { scan-tree-dump "About to replace expr calf_.*D.->red with \\*ISRA" "eipa_sra"  } } */
51 /* { dg-final { scan-tree-dump "About to replace expr calf_.*D.->green with ISRA" "eipa_sra"  } } */
52