1 /* { dg-do compile } */
2 /* { dg-options "-O2 -fdump-tree-thread1-details -fdump-tree-dce2" } */
3
4 extern int status, pt;
5 extern int count;
6 void
foo(int N,int c,int b,int * a)7 foo (int N, int c, int b, int *a)
8 {
9 int i, flag;
10 i = b -1;
11 flag = 1;
12 if (status && i < N && a[i] == b) {
13 N--;
14 flag = 0;
15 if (pt)
16 count++;
17 }
18 else
19 for (i = -1, flag = 1; ++i < N && flag;)
20 if (a[i] == b)
21 {
22 --N;
23 flag = 0;
24 if (i < N)
25 a[i] = a[N];
26 else
27 a[i] = 0;
28 if (pt)
29 count++;
30 }
31 if(status && flag)
32 pt--;
33 }
34
35 /* There are 4 FSM jump threading opportunities, all of which will be
36 realized, which will eliminate testing of FLAG, completely. */
37 /* { dg-final { scan-tree-dump-times "Registering FSM" 4 "thread1"} } */
38
39 /* There should be no assignments or references to FLAG, verify they're
40 eliminated as early as possible. */
41 /* { dg-final { scan-tree-dump-not "if .flag" "dce2"} } */
42