| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-fharden-control-flow-redundancy --param=max-jump-thread-duplication-stmts=0 -Ofast -fdump-tree-hardcfr -fdump-tree-optimized" } */ |
| 3 |
/* { dg-require-effective-target indirect_jumps } */ |
| 4 |
/* { dg-require-effective-target label_values } */ |
| 5 |
|
| 6 |
/* Based on gcc.c-torture/compile/20050510-1.c. */ |
| 7 |
|
| 8 |
extern void dont_remove (void); |
| 9 |
|
| 10 |
void bar (int k) |
| 11 |
{ |
| 12 |
void *label = (k) ? &&x : &&y; |
| 13 |
|
| 14 |
if (k >= 0) |
| 15 |
goto *label; |
| 16 |
|
| 17 |
x: |
| 18 |
if (k <= 0) |
| 19 |
dont_remove (); |
| 20 |
/* else goto y; */ |
| 21 |
|
| 22 |
y: |
| 23 |
return; |
| 24 |
} |
| 25 |
|
| 26 |
/* Check before calling dont_remove(), in the 'else goto y' edge, and in the |
| 27 |
abnormal edge to y. */ |
| 28 |
/* { dg-final { scan-tree-dump-times "hardcfr_check" 3 "hardcfr" } } */ |
| 29 |
/* { dg-final { scan-tree-dump-times "hardcfr_check" 3 "optimized" } } */ |
| 30 |
/* Check that hardcfr introduces an abnormal PHI node (this could be avoided, |
| 31 |
but it's not worth the effort), and that it gets optimized out. */ |
| 32 |
/* { dg-final { scan-tree-dump-times {\(ab\) = PHI .*\(ab\)} 1 "hardcfr" } } */ |
| 33 |
/* { dg-final { scan-tree-dump-not {\(ab\) = PHI .*\(ab\)} "optimized" } } */ |