| 1 |
// { dg-do compile } |
| 2 |
// { dg-options "-fgimple -O2 -fdump-tree-thread1-details" } |
| 3 |
|
| 4 |
/* This tests that we can thread BB4->BB999 coming in through the |
| 5 |
following path: |
| 6 |
|
| 7 |
latch many insns |
| 8 |
| | |
| 9 |
V V |
| 10 |
6 -> 7 -> 3 -> 4 -> 999 |
| 11 |
|
| 12 |
The ranger based threader cannot thread this because BB4 has too |
| 13 |
many instructions so it gives up looking back. However, if we were |
| 14 |
able to looking further, we would notice that a profitable path |
| 15 |
passing through the loop latch (BB7) exists. |
| 16 |
|
| 17 |
That is, 3->4->N in isolation is not profitable, but 6->7->3->4->N is. |
| 18 |
|
| 19 |
It is not clear whether handling this case in the backwards |
| 20 |
threader is profitable, as it would increase the search space |
| 21 |
considerably. The test is being added to note a regression from |
| 22 |
the old backward threader code. |
| 23 |
|
| 24 |
This test has been distilled from libphobos/src/std/net/isemail.d. |
| 25 |
|
| 26 |
The ranger threader stops at the 3->4 subpath with: "did not thread |
| 27 |
around loop and would copy too many statements". */ |
| 28 |
|
| 29 |
|
| 30 |
extern void bar(); |
| 31 |
extern int random(); |
| 32 |
|
| 33 |
int __GIMPLE (ssa,startwith("thread1")) |
| 34 |
foo (int key) |
| 35 |
{ |
| 36 |
int context; |
| 37 |
int _1454; |
| 38 |
|
| 39 |
__BB(2): |
| 40 |
goto __BB3; |
| 41 |
|
| 42 |
// Loop header. |
| 43 |
__BB(3): |
| 44 |
context_448 = __PHI (__BB2: 0, __BB7: context_450); |
| 45 |
if (key_5(D) > 0) |
| 46 |
goto __BB999; |
| 47 |
else |
| 48 |
goto __BB4; |
| 49 |
|
| 50 |
__BB(4): |
| 51 |
bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); |
| 52 |
bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); |
| 53 |
bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); |
| 54 |
bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); |
| 55 |
bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); |
| 56 |
bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); bar(); |
| 57 |
switch (context_448) {default: L5; case 0: L999; } |
| 58 |
|
| 59 |
__BB(5): |
| 60 |
L5: |
| 61 |
goto __BB6; |
| 62 |
|
| 63 |
__BB(6): |
| 64 |
context_450 = __PHI (__BB5: 0); |
| 65 |
_1454 = random (); |
| 66 |
if (_1454 > 0) |
| 67 |
goto __BB999; |
| 68 |
else |
| 69 |
goto __BB7; |
| 70 |
|
| 71 |
// Loop latch. |
| 72 |
__BB(7): |
| 73 |
goto __BB3; |
| 74 |
|
| 75 |
__BB(999): |
| 76 |
L999: |
| 77 |
return 5; |
| 78 |
} |
| 79 |
|
| 80 |
// { dg-final { scan-tree-dump-times "Registering.*jump thread.*incoming edge; \\(6, 7\\) \\(7, 3\\) \\(3, 4\\) \\(4, 999\\) nocopy" 1 "thread1" { xfail *-*-* } } } |