| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-O2 -fdump-tree-threadfull1-details -fdump-tree-thread2" } */ |
| 3 |
|
| 4 |
extern int status, pt; |
| 5 |
extern int count; |
| 6 |
void |
| 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 2 jump threading opportunities (which don't cross loops), |
| 36 |
all of which will be realized, which will eliminate testing of |
| 37 |
FLAG, completely. */ |
| 38 |
/* { dg-final { scan-tree-dump-times "Registering jump" 2 "threadfull1"} } */ |
| 39 |
|
| 40 |
/* We used to remove references to FLAG by DCE2, but this was |
| 41 |
depending on early threaders threading through loop boundaries |
| 42 |
(which we shouldn't do). However, the late threading passes, which |
| 43 |
run after loop optimizations , can successfully eliminate the |
| 44 |
references to FLAG. Verify that ther are no references by the late |
| 45 |
threading passes. */ |
| 46 |
/* { dg-final { scan-tree-dump-not "if .flag" "thread2"} } */ |