1 /* { dg-do compile } */
2 /* { dg-options "-O2 -ftree-loop-distribution -ftree-loop-distribute-patterns -fdump-tree-ldist-details -fdump-tree-optimized" } */
3 
4 extern void bar(int);
5 
6 void
foo(unsigned i,unsigned n)7 foo (unsigned i, unsigned n)
8 {
9   int a[30];
10   int b[30];
11   if (n == 0)
12     return;
13   for (i=0; i < n; i++)
14     a[i] = b[i] = 0;
15 
16   while (1)
17     if (b[0])
18       bar (a[i - 1]);
19 }
20 
21 /* We should apply loop distribution and generate 1 memset (0).  PRE optimizes
22    away a[] completely.  */
23 
24 /* { dg-final { scan-tree-dump "distributed: split to 0 loops and 1 library calls" "ldist" } } */
25 /* { dg-final { scan-tree-dump-times "generated memset zero" 1 "ldist" } } */
26 /* { dg-final { scan-tree-dump-times "int a" 0 "optimized" } } */
27