Hi. i386 target uses hint-based expansion of memcpy-like and memset-like functions. I would like to add a test in order to cover the functionality.
Ready for trunk? Martin gcc/ChangeLog: 2018-08-13 Martin Liska <mli...@suse.cz> * config/i386/i386.c (ix86_expand_set_or_movmem): Dump selected expansion strategy. gcc/testsuite/ChangeLog: 2018-08-13 Martin Liska <mli...@suse.cz> * gcc.dg/tree-prof/val-prof-10.c: New test. --- gcc/config/i386/i386.c | 5 ++++ gcc/testsuite/gcc.dg/tree-prof/val-prof-10.c | 31 ++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/tree-prof/val-prof-10.c
diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 7554fd1f659..db1c4031a3f 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -27632,6 +27632,11 @@ ix86_expand_set_or_movmem (rtx dst, rtx src, rtx count_exp, rtx val_exp, issetmem, issetmem && val_exp == const0_rtx, have_as, &dynamic_check, &noalign, false); + + if (dump_file) + fprintf (dump_file, "Selected stringop expansion strategy: %s\n", + stringop_alg_names[alg]); + if (alg == libcall) return false; gcc_assert (alg != no_stringop); diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-10.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-10.c new file mode 100644 index 00000000000..57854b5911b --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-10.c @@ -0,0 +1,31 @@ +/* { dg-options "-O2 -fdump-rtl-expand -mtune=core2" } */ +/* { dg-skip-if "" { ! { i?86-*-* x86_64-*-* } } } */ + +long buffer1[128], buffer2[128]; +char *x; + +void foo(long *r) +{ + x = (char *)r; + asm volatile("" ::: "memory"); +} + +void +__attribute__((noinline)) +compute() +{ + volatile int n = 24; + __builtin_memcpy (buffer1, buffer2, n); + foo (&buffer1[0]); +} + +int +main() +{ + for (unsigned i = 0; i < 10000; i++) + compute (); + + return 0; +} + +/* { dg-final-use-not-autofdo { scan-rtl-dump "Selected stringop expansion strategy: rep_byte" "expand" } } */