diff options
Diffstat (limited to 'gcc/testsuite/gcc.dg/tree-prof')
33 files changed, 434 insertions, 61 deletions
diff --git a/gcc/testsuite/gcc.dg/tree-prof/20050826-2.c b/gcc/testsuite/gcc.dg/tree-prof/20050826-2.c index bdaef3d5bf..f0febbdffa 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/20050826-2.c +++ b/gcc/testsuite/gcc.dg/tree-prof/20050826-2.c @@ -72,4 +72,4 @@ main (void) return 0; } -/* { dg-final-use { scan-tree-dump-not "Invalid sum" "dom2"} } */ +/* { dg-final-use-not-autofdo { scan-tree-dump-not "Invalid sum" "dom2"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/cmpsf-1.c b/gcc/testsuite/gcc.dg/tree-prof/cmpsf-1.c index 49102df3e6..16adb92e1c 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/cmpsf-1.c +++ b/gcc/testsuite/gcc.dg/tree-prof/cmpsf-1.c @@ -181,4 +181,4 @@ main (void) exit (0); } -/* { dg-final-use { scan-tree-dump-not "Invalid sum" "dom2"} } */ +/* { dg-final-use-not-autofdo { scan-tree-dump-not "Invalid sum" "dom2"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/cold_partition_label.c b/gcc/testsuite/gcc.dg/tree-prof/cold_partition_label.c index 910ac046bc..6214e3629f 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/cold_partition_label.c +++ b/gcc/testsuite/gcc.dg/tree-prof/cold_partition_label.c @@ -29,9 +29,11 @@ foo (int path) int main (int argc, char *argv[]) { + int i; buf_hot = "hello"; buf_cold = "world"; - foo (argc); + for (i = 0; i < 1000000; i++) + foo (argc); return 0; } diff --git a/gcc/testsuite/gcc.dg/tree-prof/comp-goto-1.c b/gcc/testsuite/gcc.dg/tree-prof/comp-goto-1.c index bbfe1f4728..42d61f3cad 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/comp-goto-1.c +++ b/gcc/testsuite/gcc.dg/tree-prof/comp-goto-1.c @@ -16,7 +16,7 @@ typedef union { struct { - unsigned int offset:18; + signed int offset:18; unsigned int ignore:4; unsigned int s1:8; int :2; diff --git a/gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1.c b/gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1.c index e36ba26914..3979b17b15 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1.c +++ b/gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1.c @@ -15,4 +15,4 @@ caller(void (*func) (void)) func (); } -/* { dg-final-use { scan-ipa-dump "hist->count 1 hist->all 1" "profile" } } */ +/* { dg-final-use-not-autofdo { scan-ipa-dump "hist->count 1 hist->all 1" "profile" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c b/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c index bed40a594c..53063c3e7f 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c +++ b/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c @@ -1,4 +1,4 @@ -/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile -fdump-ipa-afdo" } */ static int a1 (void) { @@ -28,7 +28,7 @@ main (void) int (*p) (void); int i; - for (i = 0; i < 10; i ++) + for (i = 0; i < 10000000; i ++) { setp (&p, i); p (); @@ -37,5 +37,6 @@ main (void) return 0; } -/* { dg-final-use { scan-ipa-dump "Indirect call -> direct call.* a1 transformation on insn" "profile"} } */ +/* { dg-final-use-not-autofdo { scan-ipa-dump "Indirect call -> direct call.* a1 transformation on insn" "profile"} } */ +/* { dg-final-use-autofdo { scan-ipa-dump "Indirect call -> direct call.* a1 transformation on insn" "afdo"} } */ /* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/inliner-1.c b/gcc/testsuite/gcc.dg/tree-prof/inliner-1.c index f0cdf879c8..8d1481bfeb 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/inliner-1.c +++ b/gcc/testsuite/gcc.dg/tree-prof/inliner-1.c @@ -25,7 +25,7 @@ int main () { int i; - for (i = 0; i < 100; i++) + for (i = 0; i < 1000000; i++) { if (a) cold_function (); diff --git a/gcc/testsuite/gcc.dg/tree-prof/merge_block.c b/gcc/testsuite/gcc.dg/tree-prof/merge_block.c index da4ec5a867..5da5ddff6a 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/merge_block.c +++ b/gcc/testsuite/gcc.dg/tree-prof/merge_block.c @@ -14,7 +14,7 @@ main () { int i; /* The loop will be optimized away after ipa-inline. */ - for (i = 0; i < 1000; i++) + for (i = 0; i < 1000000; i++) t (); return 0; } diff --git a/gcc/testsuite/gcc.dg/tree-prof/peel-1.c b/gcc/testsuite/gcc.dg/tree-prof/peel-1.c index 048beb6913..7245b68c1e 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/peel-1.c +++ b/gcc/testsuite/gcc.dg/tree-prof/peel-1.c @@ -20,6 +20,4 @@ main() t(); return 0; } -/* { dg-final-use { scan-tree-dump "Peeled loop ., 2 times" "cunroll" } } */ -/* In fact one peeling is enough; we however mispredict number of iterations of the loop - at least until loop_ch is schedule ahead of profiling pass. */ +/* { dg-final-use { scan-tree-dump "Peeled loop ., 1 times" "cunroll" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/pr66295.c b/gcc/testsuite/gcc.dg/tree-prof/pr66295.c new file mode 100644 index 0000000000..d7d64c41b0 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/pr66295.c @@ -0,0 +1,35 @@ +/* { dg-require-ifunc "" } */ +/* { dg-skip-if "" { ! { i?86-*-* x86_64-*-* } } } */ +/* { dg-options "-O2" } */ + +static double bar (double *__restrict, double *__restrict, int) +__attribute__ ((target_clones("avx,avx2,avx512f,default"))); + +double +foo (double *__restrict a, double *__restrict b, int n) +{ + return bar (a,b,n); +} + +double +bar (double *__restrict a, double *__restrict b, int n) +{ + double s; + int i; + s = 0.0; + for (i=0; i<n; i++) + s += a[i] + b[i]; + + return s; +} + +#define N 5 + +int main () +{ + double a[N] = {1.2f, 1.2f, 1.2f, 1.2f, 1.2f }; + double b[N] = {1.2f, 1.2f, 1.2f, 1.2f, 1.2f }; + + __builtin_printf ("value: %.5f\n", foo (a, b, N)); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-prof/pr79587.c b/gcc/testsuite/gcc.dg/tree-prof/pr79587.c new file mode 100644 index 0000000000..517e081991 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/pr79587.c @@ -0,0 +1,26 @@ +/* { dg-require-effective-target lto } */ +/* { dg-options "-O2 -flto" } */ + +unsigned long global = -12345; + +unsigned long +__attribute__((noinline)) +test(unsigned long v, unsigned long v2) +{ + unsigned long x = v % v2; + + return x; +} + +int main(int argc, char **argv) +{ + unsigned long r = 0; + + for (int i = 0; i < 100; i++) + r += test(argc, global); + + if (r != 100) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-prof/section-attr-1.c b/gcc/testsuite/gcc.dg/tree-prof/section-attr-1.c new file mode 100644 index 0000000000..ee6662ea6e --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/section-attr-1.c @@ -0,0 +1,45 @@ +/* Checks for a bug where a function with a section attribute would prevent + all later functions from being partitioned into hot and cold blocks. */ +/* { dg-require-effective-target freorder } */ +/* { dg-options "-O2 -fno-profile-reorder-functions -freorder-blocks-and-partition -save-temps" } */ + +#define SIZE 10000 + +#define NOINLINE __attribute__((noinline)) __attribute__ ((noclone)) + +const char *sarr[SIZE]; +const char *buf_hot; +const char *buf_cold; + +void foo (int path); + +__attribute__((section(".text"))) +int +main (int argc, char *argv[]) +{ + int i; + buf_hot = "hello"; + buf_cold = "world"; + for (i = 0; i < 1000000; i++) + foo (argc); + return 0; +} + + +void NOINLINE +foo (int path) +{ + int i; + if (path) + { + for (i = 0; i < SIZE; i++) + sarr[i] = buf_hot; + } + else + { + for (i = 0; i < SIZE; i++) + sarr[i] = buf_cold; + } +} + +/* { dg-final-use { scan-assembler "\.section\[\t \]*\.text\.unlikely\[\\n\\r\]+\[\t \]*\.size\[\t \]*foo\.cold\.0" { target *-*-linux* *-*-gnu* } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/section-attr-2.c b/gcc/testsuite/gcc.dg/tree-prof/section-attr-2.c new file mode 100644 index 0000000000..898a395cd7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/section-attr-2.c @@ -0,0 +1,44 @@ +/* Checks for a bug where static data with a section attribute within a + function would stop the function being partitioned into hot and cold + blocks. */ +/* { dg-require-effective-target freorder } */ +/* { dg-options "-O2 -fno-profile-reorder-functions -freorder-blocks-and-partition -save-temps" } */ + +#define SIZE 10000 + +#define NOINLINE __attribute__((noinline)) __attribute__ ((noclone)) + +const char *sarr[SIZE]; +const char *buf_hot; +const char *buf_cold; + +void foo (int path); + +int +main (int argc, char *argv[]) +{ + int i; + buf_hot = "hello"; + buf_cold = "world"; + for (i = 0; i < 1000000; i++) + foo (argc); + return 0; +} + +void NOINLINE +foo (int path) +{ + static int i __attribute__((section(".data"))); + if (path) + { + for (i = 0; i < SIZE; i++) + sarr[i] = buf_hot; + } + else + { + for (i = 0; i < SIZE; i++) + sarr[i] = buf_cold; + } +} + +/* { dg-final-use { scan-assembler "\.section\[\t \]*\.text\.unlikely\[\\n\\r\]+\[\t \]*\.size\[\t \]*foo\.cold\.0" { target *-*-linux* *-*-gnu* } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/section-attr-3.c b/gcc/testsuite/gcc.dg/tree-prof/section-attr-3.c new file mode 100644 index 0000000000..36829dcb7a --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/section-attr-3.c @@ -0,0 +1,45 @@ +/* Checks for a bug where static data with a section attribute within a + function would stop the function being partitioned into hot and cold + blocks. */ +/* { dg-require-effective-target freorder } */ +/* { dg-options "-O2 -fno-profile-reorder-functions -freorder-blocks-and-partition -save-temps" } */ + +#define SIZE 10000 + +#define NOINLINE __attribute__((noinline)) __attribute__ ((noclone)) + +const char *sarr[SIZE]; +const char *buf_hot __attribute__ ((section (".data"))); +const char *buf_cold; + +void foo (int path); + +int +main (int argc, char *argv[]) +{ + int i; + buf_hot = "hello"; + buf_cold = "world"; + for (i = 0; i < 1000000; i++) + foo (argc); + return 0; +} + + +void NOINLINE +foo (int path) +{ + int i; + if (path) + { + for (i = 0; i < SIZE; i++) + sarr[i] = buf_hot; + } + else + { + for (i = 0; i < SIZE; i++) + sarr[i] = buf_cold; + } +} + +/* { dg-final-use { scan-assembler "\.section\[\t \]*\.text\.unlikely\[\\n\\r\]+\[\t \]*\.size\[\t \]*foo\.cold\.0" { target *-*-linux* *-*-gnu* } } } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/stringop-1.c b/gcc/testsuite/gcc.dg/tree-prof/stringop-1.c index e1e06348ae..6f8908a343 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/stringop-1.c +++ b/gcc/testsuite/gcc.dg/tree-prof/stringop-1.c @@ -14,8 +14,9 @@ main() } return 0; } -/* { dg-final-use { scan-ipa-dump "Single value 4 stringop" "profile"} } */ +/* autofdo doesn't support value profiling for now: */ +/* { dg-final-use-not-autofdo { scan-ipa-dump "Single value 4 stringop" "profile"} } */ /* Really this ought to simplify into assignment, but we are not there yet. */ /* a[0] = b[0] is what we fold the resulting memcpy into. */ -/* { dg-final-use { scan-tree-dump " = MEM.*&b" "optimized"} } */ -/* { dg-final-use { scan-tree-dump "MEM.*&a\\\] = " "optimized"} } */ +/* { dg-final-use-not-autofdo { scan-tree-dump " = MEM.*&b" "optimized"} } */ +/* { dg-final-use-not-autofdo { scan-tree-dump "MEM.*&a\\\] = " "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/stringop-2.c b/gcc/testsuite/gcc.dg/tree-prof/stringop-2.c index 66f8d292e1..330b159b7f 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/stringop-2.c +++ b/gcc/testsuite/gcc.dg/tree-prof/stringop-2.c @@ -19,6 +19,7 @@ main() } return 0; } -/* { dg-final-use { scan-ipa-dump "Single value 4 stringop" "profile"} } */ +/* autofdo doesn't support value profiling for now: */ +/* { dg-final-use-not-autofdo { scan-ipa-dump "Single value 4 stringop" "profile"} } */ /* The versioned memset of size 4 should be optimized to an assignment. */ -/* { dg-final-use { scan-tree-dump "MEM\\\[\\(void .\\)&a\\\] = 168430090" "optimized"} } */ +/* { dg-final-use-not-autofdo { scan-tree-dump "MEM\\\[\\(void .\\)&a\\\] = 168430090" "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/switch-case-1.c b/gcc/testsuite/gcc.dg/tree-prof/switch-case-1.c index 89e76cc59d..6a9af083a9 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/switch-case-1.c +++ b/gcc/testsuite/gcc.dg/tree-prof/switch-case-1.c @@ -35,5 +35,6 @@ int main () foo ((i * i) % 5); return 0; } -/* { dg-final-use { scan-rtl-dump-times ";; basic block\[^\\n\]*count 4000" 2 "expand"} } */ -/* { dg-final-use { scan-rtl-dump-times ";; basic block\[^\\n\]*count 2000" 1 "expand"} } */ +/* autofdo cannot do that precise execution numbers */ +/* { dg-final-use-not-autofdo { scan-rtl-dump-times ";; basic block\[^\\n\]*count 4000" 2 "expand"} } */ +/* { dg-final-use-not-autofdo { scan-rtl-dump-times ";; basic block\[^\\n\]*count 2000" 1 "expand"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/switch-case-2.c b/gcc/testsuite/gcc.dg/tree-prof/switch-case-2.c index 7161282117..cfedc9c6b7 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/switch-case-2.c +++ b/gcc/testsuite/gcc.dg/tree-prof/switch-case-2.c @@ -35,5 +35,6 @@ int main () foo ((i * i) % 5); return 0; } -/* { dg-final-use { scan-rtl-dump-times ";; basic block\[^\\n\]*count 4000" 2 "expand"} } */ -/* { dg-final-use { scan-rtl-dump-times ";; basic block\[^\\n\]*count 2000" 1 "expand"} } */ +/* autofdo cannot do that precise execution numbers: */ +/* { dg-final-use-not-autofdo { scan-rtl-dump-times ";; basic block\[^\\n\]*count 4000" 2 "expand"} } */ +/* { dg-final-use-not-autofdo { scan-rtl-dump-times ";; basic block\[^\\n\]*count 2000" 1 "expand"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/time-profiler-1.c b/gcc/testsuite/gcc.dg/tree-prof/time-profiler-1.c index ee8a9d805c..455f923f3f 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/time-profiler-1.c +++ b/gcc/testsuite/gcc.dg/tree-prof/time-profiler-1.c @@ -16,6 +16,6 @@ int main () { return foo (); } -/* { dg-final-use { scan-ipa-dump-times "Read tp_first_run: 0" 1 "profile"} } */ -/* { dg-final-use { scan-ipa-dump-times "Read tp_first_run: 1" 1 "profile"} } */ -/* { dg-final-use { scan-ipa-dump-times "Read tp_first_run: 2" 1 "profile"} } */ +/* { dg-final-use-not-autofdo { scan-ipa-dump-times "Read tp_first_run: 0" 1 "profile"} } */ +/* { dg-final-use-not-autofdo { scan-ipa-dump-times "Read tp_first_run: 1" 1 "profile"} } */ +/* { dg-final-use-not-autofdo { scan-ipa-dump-times "Read tp_first_run: 2" 1 "profile"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/time-profiler-2.c b/gcc/testsuite/gcc.dg/tree-prof/time-profiler-2.c index 29c0d191af..e6eaeb9981 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/time-profiler-2.c +++ b/gcc/testsuite/gcc.dg/tree-prof/time-profiler-2.c @@ -43,7 +43,7 @@ int main () return r; } -/* { dg-final-use { scan-ipa-dump-times "Read tp_first_run: 0" 2 "profile"} } */ -/* { dg-final-use { scan-ipa-dump-times "Read tp_first_run: 1" 1 "profile"} } */ -/* { dg-final-use { scan-ipa-dump-times "Read tp_first_run: 2" 1 "profile"} } */ -/* { dg-final-use { scan-ipa-dump-times "Read tp_first_run: 3" 1 "profile"} } */ +/* { dg-final-use-not-autofdo { scan-ipa-dump-times "Read tp_first_run: 0" 2 "profile"} } */ +/* { dg-final-use-not-autofdo { scan-ipa-dump-times "Read tp_first_run: 1" 1 "profile"} } */ +/* { dg-final-use-not-autofdo { scan-ipa-dump-times "Read tp_first_run: 2" 1 "profile"} } */ +/* { dg-final-use-not-autofdo { scan-ipa-dump-times "Read tp_first_run: 3" 1 "profile"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/time-profiler-3.c b/gcc/testsuite/gcc.dg/tree-prof/time-profiler-3.c new file mode 100644 index 0000000000..69ce026082 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/time-profiler-3.c @@ -0,0 +1,22 @@ +/* { dg-options "-O2 -fdump-ipa-profile -fprofile-update=atomic" } */ +/* { dg-require-effective-target profile_update_atomic } */ + +__attribute__ ((noinline)) +int foo() +{ + return 0; +} + +__attribute__ ((noinline)) +int bar() +{ + return 1; +} + +int main () +{ + return foo (); +} +/* { dg-final-use-not-autofdo { scan-ipa-dump-times "Read tp_first_run: 0" 1 "profile"} } */ +/* { dg-final-use-not-autofdo { scan-ipa-dump-times "Read tp_first_run: 1" 1 "profile"} } */ +/* { dg-final-use-not-autofdo { scan-ipa-dump-times "Read tp_first_run: 2" 1 "profile"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/tree-prof.exp b/gcc/testsuite/gcc.dg/tree-prof/tree-prof.exp index 650ad8d080..0a21f1799f 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/tree-prof.exp +++ b/gcc/testsuite/gcc.dg/tree-prof/tree-prof.exp @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2016 Free Software Foundation, Inc. +# Copyright (C) 2001-2017 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -44,6 +44,7 @@ set PROFOPT_OPTIONS [list {}] # profile data. set profile_option "-fprofile-generate -D_PROFILE_GENERATE" set feedback_option "-fprofile-use -D_PROFILE_USE" +set profile_wrapper "" foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] { # If we're only testing specific files and this isn't one of them, skip it. @@ -53,4 +54,11 @@ foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] { profopt-execute $src } +foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.c]] { + if ![runtest_file_p $runtests $src] then { + continue + } + auto-profopt-execute $src +} + set PROFOPT_OPTIONS $treeprof_save_profopt_options diff --git a/gcc/testsuite/gcc.dg/tree-prof/update-loopch.c b/gcc/testsuite/gcc.dg/tree-prof/update-loopch.c index 4dd51af6ae..242fa524ee 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/update-loopch.c +++ b/gcc/testsuite/gcc.dg/tree-prof/update-loopch.c @@ -14,8 +14,9 @@ main () /* Loop header copying will peel away the initial conditional, so the loop body is once reached directly from entry point of function, rest via loopback edge. */ -/* { dg-final-use { scan-ipa-dump "loop depth 1, count 33334" "profile"} } */ -/* { dg-final-use { scan-tree-dump "loop depth 1, count 33333" "optimized"} } */ -/* { dg-final-use { scan-tree-dump-not "loop depth 1, count 33332" "optimized"} } */ -/* { dg-final-use { scan-tree-dump "Removing basic block" "optimized"} } */ +/* autofdo cannot do that precise counts */ +/* { dg-final-use-not-autofdo { scan-ipa-dump "loop depth 1, count 33334" "profile"} } */ +/* { dg-final-use-not-autofdo { scan-tree-dump "loop depth 1, count 33333" "optimized"} } */ +/* { dg-final-use-not-autofdo { scan-tree-dump-not "loop depth 1, count 33332" "optimized"} } */ +/* { dg-final-use-not-autofdo { scan-tree-dump "Removing basic block" "optimized"} } */ /* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-1.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-1.c index 97dd311f4d..35e0f908f2 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/val-prof-1.c +++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-1.c @@ -16,6 +16,7 @@ main () } return 0; } -/* { dg-final-use { scan-ipa-dump "Div.mod by constant n_\[0-9\]*=257 transformation on insn" "profile"} } */ -/* { dg-final-use { scan-tree-dump "if \\(n_\[0-9\]* != 257\\)" "optimized"} } */ +/* autofdo does not do value profiling so far */ +/* { dg-final-use-not-autofdo { scan-ipa-dump "Div.mod by constant n_\[0-9\]*=257 transformation on insn" "profile"} } */ +/* { dg-final-use-not-autofdo { scan-tree-dump "if \\(n_\[0-9\]* != 257\\)" "optimized"} } */ /* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c index 2e85a86f51..ad78043ddd 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c +++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c @@ -24,8 +24,9 @@ main () } return 0; } -/* { dg-final-use { scan-ipa-dump "Mod power of 2 transformation on insn" "profile" } } */ +/* autofdo does not do value profiling so far */ +/* { dg-final-use-not-autofdo { scan-ipa-dump "Mod power of 2 transformation on insn" "profile" } } */ /* This is part of code checking that n is power of 2, so we are sure that the transformation didn't get optimized out. */ -/* { dg-final-use { scan-tree-dump "n_\[0-9\]* \\+ (4294967295|0x0*ffffffff)" "optimized"} } */ +/* { dg-final-use-not-autofdo { scan-tree-dump "n_\[0-9\]* \\+ (4294967295|0x0*ffffffff)" "optimized"} } */ /* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c index 6da88a898f..366ada1fa2 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c +++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c @@ -24,8 +24,9 @@ main () } return 0; } -/* { dg-final-use { scan-ipa-dump "Mod subtract transformation on insn" "profile" } } */ +/* autofdo does not do value profiling so far */ +/* { dg-final-use-not-autofdo { scan-ipa-dump "Mod subtract transformation on insn" "profile" } } */ /* This is part of code checking that n is greater than the divisor so we are sure that it didn't get optimized out. */ -/* { dg-final-use { scan-tree-dump "if \\(n_\[0-9\]* \\>" "optimized"} } */ +/* { dg-final-use-not-autofdo { scan-tree-dump "if \\(_\[0-9\]* \\< n_\[0-9\]*" "optimized"} } */ /* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-4.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-4.c index 5d151580f1..374428e720 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/val-prof-4.c +++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-4.c @@ -24,8 +24,9 @@ main () } return 0; } -/* { dg-final-use { scan-ipa-dump "Mod subtract transformation on insn" "profile" } } */ +/* autofdo does not do value profiling so far */ +/* { dg-final-use-not-autofdo { scan-ipa-dump "Mod subtract transformation on insn" "profile" } } */ /* This is part of code checking that n is greater than the divisor so we are sure that it didn't get optimized out. */ -/* { dg-final-use { scan-tree-dump "if \\(n_\[0-9\]* \\>" "optimized"} } */ +/* { dg-final-use-not-autofdo { scan-tree-dump "if \\(n_\[0-9\]* \\>" "optimized"} } */ /* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-5.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-5.c index 7e88ac47dc..7f4a15b778 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/val-prof-5.c +++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-5.c @@ -6,11 +6,12 @@ main() { int i; for (i = 0; i < 1000; i++) - if (a[i]) + if (a[i] != 1) a[i]/=b; else a[i]/=b; return 0; } -/* { dg-final-use { scan-ipa-dump "Div.mod by constant b.*=997 transformation on insn" "profile" } } */ +/* autofdo does not do value profiling so far */ +/* { dg-final-use-not-autofdo { scan-ipa-dump "Div.mod by constant b.*=997 transformation on insn" "profile" } } */ /* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-6.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-6.c index fd24ee33bd..597efa6ad7 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/val-prof-6.c +++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-6.c @@ -15,5 +15,6 @@ main() t(i); return 0; } -/* { dg-final-use { scan-tree-dump "Average value sum:499500" "optimized"} } */ -/* { dg-final-use { scan-tree-dump "IOR value" "optimized"} } */ +/* autofdo does not do value profiling so far */ +/* { dg-final-use-not-autofdo { scan-tree-dump "Average value sum:499500" "optimized"} } */ +/* { dg-final-use-not-autofdo { scan-tree-dump "IOR value" "optimized"} } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-7.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-7.c index 3d85714d14..84ec9fbf7b 100644 --- a/gcc/testsuite/gcc.dg/tree-prof/val-prof-7.c +++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-7.c @@ -1,25 +1,81 @@ /* { dg-options "-O2 -fdump-ipa-profile -mtune=core2" } */ /* { dg-skip-if "" { ! { i?86-*-* x86_64-*-* } } { "*" } { "" } } */ -extern void bzero (void *, __SIZE_TYPE__); +char *buffer1; +char *buffer2; -int foo(int len) -{ - char array[1000]; - bzero(array, len); - return 0; +#define DEFINE_TEST(N) \ +__attribute__((noinline)) \ +void bzero_test_ ## N (int len) \ +{ \ + __builtin_bzero (buffer1, len); \ +} \ + \ +__attribute__((noinline)) \ +void memcpy_test_ ## N (int len) \ +{ \ + __builtin_memcpy (buffer1, buffer2, len); \ +} \ + \ +__attribute__((noinline)) \ +void mempcpy_test_ ## N (int len) \ +{ \ + __builtin_mempcpy (buffer1, buffer2, len); \ +} \ + \ +__attribute__((noinline)) \ +void memset_test_ ## N (int len) \ +{ \ + __builtin_memset (buffer1, 'c', len); \ +} \ + \ +void test_stringops_ ## N(int len) \ +{ \ + bzero_test_ ## N (len); \ + memcpy_test_## N (len); \ + mempcpy_test_ ## N (len); \ + memset_test_ ## N (len); \ +} \ + \ +void test_stringops_with_values_ ## N (int common, int not_common) \ +{ \ + int i; \ + for (i = 0; i < 1000; i++) \ + { \ + if (i > 990) \ + test_stringops_ ## N (not_common); \ + else \ + test_stringops_ ## N (common); \ + } \ } +DEFINE_TEST(0); +DEFINE_TEST(1); +DEFINE_TEST(2); + int main() { - int i; - for (i = 0; i < 1000; i++) - { - if (i > 990) - foo(16); - else - foo(8); - } + buffer1 = __builtin_malloc (1000); + buffer2 = __builtin_malloc (1000); + + test_stringops_with_values_0 (8, 55); + test_stringops_with_values_1 (55, 55); + test_stringops_with_values_2 (257, 55); + return 0; } -/* { dg-final-use { scan-ipa-dump "Single value 8 stringop transformation on bzero" "profile" } } */ +/* { dg-final-use-not-autofdo { scan-ipa-dump "Single value 8 stringop transformation on __builtin_bzero" "profile" } } */ +/* { dg-final-use-not-autofdo { scan-ipa-dump "Single value 55 stringop transformation on __builtin_bzero" "profile" } } */ +/* { dg-final-use-not-autofdo { scan-ipa-dump-times "Single value 32 stringop transformation on __builtin_bzero" 0 "profile" } } */ + +/* { dg-final-use-not-autofdo { scan-ipa-dump "Single value 8 stringop transformation on __builtin_memcpy" "profile" } } */ +/* { dg-final-use-not-autofdo { scan-ipa-dump "Single value 55 stringop transformation on __builtin_memcpy" "profile" } } */ +/* { dg-final-use-not-autofdo { scan-ipa-dump-times "Single value 32 stringop transformation on __builtin_memcpy" 0 "profile" } } */ + +/* { dg-final-use-not-autofdo { scan-ipa-dump "Single value 8 stringop transformation on __builtin_mempcpy" "profile" } } */ +/* { dg-final-use-not-autofdo { scan-ipa-dump "Single value 55 stringop transformation on __builtin_mempcpy" "profile" } } */ +/* { dg-final-use-not-autofdo { scan-ipa-dump-times "Single value 32 stringop transformation on __builtin_mempcpy" 0 "profile" } } */ + +/* { dg-final-use-not-autofdo { scan-ipa-dump "Single value 8 stringop transformation on __builtin_memset" "profile" } } */ +/* { dg-final-use-not-autofdo { scan-ipa-dump "Single value 55 stringop transformation on __builtin_memset" "profile" } } */ +/* { dg-final-use-not-autofdo { scan-ipa-dump-times "Single value 32 stringop transformation on __builtin_memset" 0 "profile" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-8.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-8.c new file mode 100644 index 0000000000..2c505e3d97 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-8.c @@ -0,0 +1,19 @@ +/* { dg-options "-O0 -fdump-ipa-profile" } */ + +int +main (int argc, char **argv) +{ + unsigned u = (argc - 1); + int counter = 0; + + for (unsigned i = 0; i < 100; i++) + { + unsigned x = i < 10 ? 16 : 15; + counter += u % x; + } + + return counter; +} + +/* autofdo does not do value profiling so far */ +/* { dg-final-use-not-autofdo { scan-ipa-dump "Pow2 counter pow2:10 nonpow2:90." "profile" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-9.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-9.c new file mode 100644 index 0000000000..8fc2301593 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-9.c @@ -0,0 +1,18 @@ +/* { dg-options "-O0 -fdump-tree-optimized" } */ + +int +main (int argc, char **argv) +{ + unsigned u = (argc - 1); + int counter = 0; + + for (unsigned i = 0; i < 100; i++) + { + counter += u % 16; + } + + return counter; +} + +/* autofdo does not do value profiling so far */ +/* { dg-final-use-not-autofdo { scan-tree-dump-times "__gcov_pow2_profiler" 0 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-profiler-threads-1.c b/gcc/testsuite/gcc.dg/tree-prof/val-profiler-threads-1.c new file mode 100644 index 0000000000..95d6ee3b4a --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/val-profiler-threads-1.c @@ -0,0 +1,43 @@ +/* { dg-options "-O0 -pthread -fprofile-update=atomic" } */ +/* { dg-require-effective-target profile_update_atomic } */ + +#include <pthread.h> + +#define NUM_THREADS 8 +#define SIZE 1024 +#define ITERATIONS (1000 * 1000) + +char buffer[SIZE]; +char buffer2[SIZE]; + +void *copy_memory(char *dst, char *src, unsigned size) +{ + for (unsigned i = 0; i < ITERATIONS; i++) + { + dst[size % 10] = src[size % 20]; + } +} + +void *foo(void *d) +{ + copy_memory (buffer, buffer2, SIZE); +} + +int main(int argc, char *argv[]) +{ + pthread_t threads[NUM_THREADS]; + int rc; + long t; + for(t=0;t<NUM_THREADS;t++){ + rc = pthread_create(&threads[t], NULL, foo, 0); + if (rc){ + return 1; + } + } + + int retval; + for(t=0;t<NUM_THREADS;t++) + pthread_join (threads[t], (void**)&retval); + + return buffer[10]; +} |