I don't see a good way to scan assembly output for this optimization, so I've just added the following testcase based on scanning the dump file. Better ideas are welcome.
Bernd
* function.c (thread_prologue_and_epilogue_insns): Emit information about shrink wrapping in the dump file. * gcc.target/i386/sw-1.c: New test. Index: gcc/function.c =================================================================== --- gcc.orig/function.c +++ gcc/function.c @@ -5752,6 +5752,9 @@ thread_prologue_and_epilogue_insns (void if (hard_reg_set_intersect_p (live_on_edge, prologue_clobbered)) entry_edge = orig_entry_edge; + if (dump_file && entry_edge != orig_entry_edge) + fprintf (dump_file, "Prologue moved down by shrink-wrapping.\n"); + fail_shrinkwrap: bitmap_clear (&bb_antic_flags); bitmap_clear (&bb_on_list); Index: gcc/testsuite/gcc.target/i386/sw-1.c =================================================================== --- /dev/null +++ gcc/testsuite/gcc.target/i386/sw-1.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fshrink-wrap -fdump-rtl-pro_and_epilogue" } */ + +#include <string.h> + +int c; +int x[2000]; +__attribute__((regparm(1))) int foo (int a, int b) + { + int t[200]; + if (a == 0) + return 1; + if (c == 0) + return 2; + memcpy (t, x + b, sizeof t); + return t[a]; + } + +/* { dg-final { scan-rtl-dump "Prologue moved down" "pro_and_epilogue" } } */ +/* { dg-final { cleanup-rtl-dump "pro_and_epilogue" } } */