| 1 |
/* Test that IPA-CP is able to produce a pass-through jump function for the |
| 2 |
call of g1 and g2 even though a is addressable. Also test that h is not |
| 3 |
cloned. */ |
| 4 |
|
| 5 |
/* { dg-do compile } */ |
| 6 |
/* { dg-options "-O3 -fipa-cp -fipa-cp-clone -fdump-ipa-cp -fno-early-inlining" } */ |
| 7 |
/* { dg-add-options bind_pic_locally } */ |
| 8 |
|
| 9 |
extern void use_stuff (int); |
| 10 |
extern void use_pointer (int *); |
| 11 |
|
| 12 |
static int |
| 13 |
h (int a, int b) |
| 14 |
{ |
| 15 |
int i; |
| 16 |
|
| 17 |
for (i = 8; i <= b; i++) |
| 18 |
use_stuff (a+8); |
| 19 |
} |
| 20 |
|
| 21 |
static int |
| 22 |
g1 (int a, int b) |
| 23 |
{ |
| 24 |
int i; |
| 25 |
|
| 26 |
for (i = 0; i <= b; i++) |
| 27 |
use_pointer (&a); |
| 28 |
h (a, b); |
| 29 |
} |
| 30 |
|
| 31 |
static int |
| 32 |
g2 (int a, int b) |
| 33 |
{ |
| 34 |
int i; |
| 35 |
|
| 36 |
for (i = 4; i <= b; i += 2) |
| 37 |
use_stuff (a); |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
static void |
| 42 |
f (int a, int z) |
| 43 |
{ |
| 44 |
if (z > 1) |
| 45 |
g1 (a, z); |
| 46 |
else |
| 47 |
g2 (a + 4, z); |
| 48 |
use_pointer (&a); |
| 49 |
} |
| 50 |
|
| 51 |
int |
| 52 |
main (int argc, char *argv[]) |
| 53 |
{ |
| 54 |
int i; |
| 55 |
for (i = 0; i < 100; i++) |
| 56 |
f (7, argc); |
| 57 |
return 0; |
| 58 |
} |
| 59 |
|
| 60 |
|
| 61 |
/* { dg-final { scan-ipa-dump "Creating a specialized node of g1.*for all known contexts" "cp" } } */ |
| 62 |
/* { dg-final { scan-ipa-dump "Creating a specialized node of g2.*for all known contexts" "cp" } } */ |
| 63 |
/* { dg-final { scan-ipa-dump-not "Creating a specialized node of h.*for all known contexts" "cp" } } */ |
| 64 |
/* { dg-final { scan-ipa-dump-times "replacing param .0 a with const 7" 2 "cp" } } */ |
| 65 |
/* { dg-final { scan-ipa-dump "replacing param .0 a with const 11" "cp" } } */ |
| 66 |
|
| 67 |
|