diff options
Diffstat (limited to 'gcc-4.9/gcc/testsuite/gcc.dg/tree-prof')
31 files changed, 781 insertions, 2 deletions
diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/crossmodule-indircall-1a.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/crossmodule-indircall-1a.c index a94195cd9..520cad0b2 100644 --- a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/crossmodule-indircall-1a.c +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/crossmodule-indircall-1a.c @@ -1,6 +1,7 @@ /* It seems there is no way to avoid the other source of mulitple source testcase from being compiled independently. Just avoid error. */ +/* { dg-require-effective-target lto } */ #ifdef DOJOB extern int a; void abort (void); diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/inliner-1.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/inliner-1.c index e44887b52..99398a60f 100644 --- a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/inliner-1.c +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/inliner-1.c @@ -1,4 +1,4 @@ -/* { dg-options "-O2 -fdump-tree-optimized" } */ +/* { dg-options "-O2 --param inline-hot-caller=0 -fdump-tree-optimized" } */ int a; int b[100]; void abort (void); @@ -34,7 +34,7 @@ main () return 0; } -/* cold function should be inlined, while hot function should not. +/* cold function should be not inlined, while hot function should be. Look for "cold_function () [tail call];" call statement not for the declaration or other appearances of the string in dump. */ /* { dg-final-use { scan-tree-dump "cold_function ..;" "optimized"} } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/bb-reorg_0.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/bb-reorg_0.c new file mode 100644 index 000000000..f850c9bfd --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/bb-reorg_0.c @@ -0,0 +1,39 @@ +/* { dg-require-effective-target freorder } */ +/* { dg-options "-O2 -freorder-blocks-and-partition" } */ + +#include <string.h> + +#define SIZE 1000 +int t0 = 0; +const char *t2[SIZE]; +char buf[SIZE]; + +void +foo (void) +{ + char *s = buf; + t0 = 1; + + for (;;) + { + if (*s == '\0') + break; + else + { + t2[t0] = s; + t0++; + } + *s++ = '\0'; + } + t2[t0] = NULL; +} + + +int +main () +{ + strcpy (buf, "hello"); + foo (); + return 0; +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/ic-misattribution-1_0.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/ic-misattribution-1_0.c new file mode 100644 index 000000000..ff103a8c5 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/ic-misattribution-1_0.c @@ -0,0 +1,19 @@ +/* { dg-options "-O2 -fdump-ipa-profile" } */ + +extern void callee (void); +extern void caller (void (*func) (void)); + +typedef void (*func_t) (void); +func_t func; + +int +main () +{ + func = callee; + caller (callee); + func (); + return 0; +} + +/* { dg-final-use { scan-ipa-dump-times "Indirect call -> direct call" 2 "profile" } } */ +/* { dg-final-use { cleanup-ipa-dump "profile" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/ic-misattribution-1_1.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/ic-misattribution-1_1.c new file mode 100644 index 000000000..4948ec4fa --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/ic-misattribution-1_1.c @@ -0,0 +1,18 @@ +/* { dg-options "-O2 -fdump-ipa-profile" } */ + +extern void other_caller (void); + +void +callee (void) +{ + return; +} + +void +caller(void (*func) (void)) +{ + func (); +} + +/* { dg-final-use { scan-ipa-dump "Indiret call -> direct call" "profile" } } */ +/* { dg-final-use { cleanup-ipa-dump "profile" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/indir-call-prof-single_0.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/indir-call-prof-single_0.c new file mode 100644 index 000000000..29a216c69 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/indir-call-prof-single_0.c @@ -0,0 +1,43 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */ + +static int a1 (void) +{ + return 10; +} + +static int a2 (void) +{ + return 0; +} + +typedef int (*tp) (void); + +static tp aa [] = {a2, a1, a1, a1, a1}; + +__attribute__((noinline)) void setp (int (**pp) (void), int i) +{ + if (!i) + *pp = aa [i]; + else + *pp = aa [(i & 2) + 1]; +} + +int +main (void) +{ + int (*p) (void); + int i; + + for (i = 0; i < 10; i ++) + { + setp (&p, i); + p (); + } + + return 0; +} + +/* { dg-final-use { scan-ipa-dump "Indirect call -> direct call.* a1" "profile"} } */ +/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ +/* { dg-final-use { cleanup-ipa-dump "profile" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/indir-call-prof_0.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/indir-call-prof_0.c new file mode 100644 index 000000000..6bd048df6 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/indir-call-prof_0.c @@ -0,0 +1,23 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */ + +extern void setp (int (**pp) (void), int i); + +int +main (void) +{ + int (*p) (void); + int i; + + for (i = 0; i < 10; i ++) + { + setp (&p, i); + p (); + } + + return 0; +} + +/* { dg-final-use { scan-ipa-dump "Indirect call -> direct call.* a1" "profile"} } */ +/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ +/* { dg-final-use { cleanup-ipa-dump "profile" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/indir-call-prof_1.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/indir-call-prof_1.c new file mode 100644 index 000000000..0cdb607cd --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/indir-call-prof_1.c @@ -0,0 +1,23 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */ + +int a1 (void) +{ + return 10; +} + +int a2 (void) +{ + return 0; +} + +typedef int (*tp) (void); + +tp aa [] = {a2, a1, a1, a1, a1}; + +__attribute__((noinline)) void setp (int (**pp) (void), int i) +{ + if (!i) + *pp = aa [i]; + else + *pp = aa [(i & 2) + 1]; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/inliner-1_0.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/inliner-1_0.c new file mode 100644 index 000000000..a82b95d82 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/inliner-1_0.c @@ -0,0 +1,42 @@ +/* { dg-options "-O2 --param inline-hot-caller=0 -fdump-tree-optimized" } */ +int a; +int b[100]; +void abort (void); + +inline void +cold_function () +{ + int i; + for (i = 0; i < 99; i++) + if (b[i] / (b[i+1] + 1)) + abort (); +} + +inline void +hot_function () +{ + int i; + for (i = 0; i < 99; i++) + if (b[i] / (b[i+1] + 1)) + abort (); +} + +main () +{ + int i; + for (i = 0; i < 100; i++) + { + if (a) + cold_function (); + else + hot_function (); + } + return 0; +} + +/* cold function should not be inlined, while hot function should be. + Look for "cold_function () [tail call];" call statement not for the + declaration or other apperances of the string in dump. */ +/* { dg-final-use { scan-tree-dump "cold_function ..;" "optimized"} } */ +/* { dg-final-use { scan-tree-dump-not "hot_function ..;" "optimized"} } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/lipo.exp b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/lipo.exp new file mode 100644 index 000000000..26abc7f88 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/lipo.exp @@ -0,0 +1,60 @@ +# Copyright (C) 2001, 2002, 2004, 2005, 2007, 2008 +# 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 +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +# Test the functionality of programs compiled with profile-directed block +# ordering using -fprofile-generate followed by -fbranch-use. + +load_lib target-supports.exp + +# Some targets don't support tree profiling. +if { ![check_profiling_available ""] } { + return +} + +# The procedures in profopt.exp need these parameters. +set tool gcc +set prof_ext [list {gcda} {gcda.imports} ] + +# Override the list defined in profopt.exp. +set PROFOPT_OPTIONS [list {}] + +if $tracelevel then { + strace $tracelevel +} + +# Load support procs. +load_lib profopt.exp + +# These are globals used by profopt-execute. The first is options +# needed to generate profile data, the second is options to use the +# profile data. +set profile_option "-fprofile-generate -fripa -D_PROFILE_GENERATE" +set feedback_option "-fprofile-use -fripa -D_PROFILE_USE" + +# Add -fno-section-anchors for powerpc. Workround for Google ref b/6663281 +if {[istarget powerpc*-*-*]} { + set profile_option "$profile_option -fno-section-anchors" + set feedback_option "$feedback_option -fno-section-anchors" +} + +foreach src [lsort [glob -nocomplain $srcdir/$subdir/*_0.c]] { + # If we're only testing specific files and this isn't one of them, skip it. + if ![runtest_file_p $runtests $src] then { + continue + } + profopt-execute $src +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/lipo_inline1_0.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/lipo_inline1_0.c new file mode 100644 index 000000000..d48080981 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/lipo_inline1_0.c @@ -0,0 +1,29 @@ +/* { dg-options "-O2 -fdump-tree-optimized-details-blocks -fdump-ipa-inline-details -fopt-info" } */ + +extern int foo (void); +extern int goo (void); + + +int bar (void) +{ + return 2; +} + +int g; +int main () +{ + int s = 0, i; + + for (i = 0; i < 1000; i ++) + { + s += foo(); /* Should be inlined */ + s += goo(); /* Should be inlined */ + } + + g = s; + return 0; +} + +/* { dg-final-use { scan-tree-dump-not "foo" "optimized"} } */ +/* { dg-final-use { scan-tree-dump-not "goo" "optimized"} } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/lipo_inline1_1.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/lipo_inline1_1.c new file mode 100644 index 000000000..9725ca769 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/lipo_inline1_1.c @@ -0,0 +1,22 @@ +extern int bar(void); +extern int blah(void); +int foo (void) +{ + int i, s = 0; + + for (i = 0; i < 2; i++) + { + s += bar(); /* Inlined */ + s += blah(); /* Inlined */ + } + return s; +} + +int goo (void) +{ + return 10; +} + +/* { dg-final-use { scan-tree-dump-not "bar" "optimized"} } */ +/* { dg-final-use { scan-tree-dump-not "blah" "optimized"} } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/lipo_inline1_2.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/lipo_inline1_2.c new file mode 100644 index 000000000..9eeadb20a --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/lipo_inline1_2.c @@ -0,0 +1,6 @@ +int blah (void) +{ + return 2; +} + +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/pr34999_0.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/pr34999_0.c new file mode 100644 index 000000000..4ec42790e --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/pr34999_0.c @@ -0,0 +1,45 @@ +/* Same test as built-in-setjmp.c. Includes the case where + the source block of a crossing fallthru edge ends with a call. */ +/* { dg-require-effective-target freorder } */ +/* { dg-options "-O2 -freorder-blocks-and-partition" } */ + +extern int strcmp(const char *, const char *); +extern char *strcpy(char *, const char *); +extern void abort(void); +extern void exit(int); + +void *buf[20]; + +void __attribute__((noinline)) +sub2 (void) +{ + __builtin_longjmp (buf, 1); +} + +int +main () +{ + char *p = (char *) __builtin_alloca (20); + + strcpy (p, "test"); + + if (__builtin_setjmp (buf)) + { + if (strcmp (p, "test") != 0) + abort (); + + exit (0); + } + + { + int *q = (int *) __builtin_alloca (p[2] * sizeof (int)); + int i; + + for (i = 0; i < p[2]; i++) + q[i] = 0; + + while (1) + sub2 (); + } +} + diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/pr45354_0.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/pr45354_0.c new file mode 100644 index 000000000..b30ad7769 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/pr45354_0.c @@ -0,0 +1,43 @@ +/* { dg-require-effective-target freorder } */ +/* { dg-options "-O -freorder-blocks-and-partition -fschedule-insns -fselective-scheduling" { target powerpc*-*-* ia64-*-* x86_64-*-* } } */ + +extern void abort (void); + +int ifelse_val2; + +int __attribute__((noinline)) +test_ifelse2 (int i) +{ + int result = 0; + if (!i) /* count(6) */ + result = 1; /* count(1) */ + if (i == 1) /* count(6) */ + result = 1024; + if (i == 2) /* count(6) */ + result = 2; /* count(3) */ + if (i == 3) /* count(6) */ + return 8; /* count(2) */ + if (i == 4) /* count(4) */ + return 2048; + return result; /* count(4) */ +} + +void __attribute__((noinline)) +call_ifelse () +{ + ifelse_val2 += test_ifelse2 (0); + ifelse_val2 += test_ifelse2 (2); + ifelse_val2 += test_ifelse2 (2); + ifelse_val2 += test_ifelse2 (2); + ifelse_val2 += test_ifelse2 (3); + ifelse_val2 += test_ifelse2 (3); +} + +int +main() +{ + call_ifelse (); + if (ifelse_val2 != 23) + abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/pr47187_0.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/pr47187_0.c new file mode 100644 index 000000000..467ce252b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/pr47187_0.c @@ -0,0 +1,23 @@ +/* PR bootstrap/47187 */ +/* { dg-options "-O2" } */ + +char buf[64]; +char buf2[64]; + +void * +foo (char *p, long size) +{ + return __builtin_memcpy (buf, p, size); +} + +int +main (void) +{ + long i; + for (i = 0; i < 65536; i++) + if (foo ("abcdefghijkl", 12) != buf) + __builtin_abort (); + if (foo (buf2, 64) != buf) + __builtin_abort (); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/stringop-1_0.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/stringop-1_0.c new file mode 100644 index 000000000..f73061387 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/stringop-1_0.c @@ -0,0 +1,22 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */ +int a[1000]; +int b[1000]; +int size=1; +int max=10000; +main() +{ + int i; + for (i=0;i<max; i++) + { + __builtin_memcpy (a, b, size * sizeof (a[0])); + asm(""); + } + return 0; +} +/* { dg-final-use { 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 { cleanup-tree-dump "optimized" } } */ +/* { dg-final-use { cleanup-ipa-dump "profile" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/stringop-2_0.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/stringop-2_0.c new file mode 100644 index 000000000..d5c58561b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/stringop-2_0.c @@ -0,0 +1,20 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */ +int a[1000]; +int b[1000]; +int size=1; +int max=10000; +main() +{ + int i; + for (i=0;i<max; i++) + { + __builtin_memset (a, 10, size * sizeof (a[0])); + asm(""); + } + return 0; +} +/* { dg-final-use { 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 "a\\\[0\\\] = 168430090" "optimized"} } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ +/* { dg-final-use { cleanup-ipa-dump "profile" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/tracer-1_0.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/tracer-1_0.c new file mode 100644 index 000000000..385a1a5c2 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/tracer-1_0.c @@ -0,0 +1,18 @@ +/* { dg-options "-O2 -ftracer -fdump-tree-tracer" } */ +volatile int a, b, c; +int main () +{ + int i; + for (i = 0; i < 1000; i++) + { + if (i % 17) + a++; + else + b++; + c++; + } + return 0; +} +/* Superblock formation should produce two copies of the increment of c */ +/* { dg-final-generate { scan-tree-dump-times "c =" 2 "tracer" } } */ +/* { dg-final-use { cleanup-tree-dump "tracer" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/update-cunroll-2_0.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/update-cunroll-2_0.c new file mode 100644 index 000000000..d559b9245 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/update-cunroll-2_0.c @@ -0,0 +1,21 @@ + +/* { dg-options "-O2 -fdump-tree-optimized-blocks" } */ +int a[8]; +__attribute__ ((noinline)) +int t() +{ + int i; + for (i = 0; i < 3; i++) + if (a[i]) + break; + return i; +} +main () +{ + int i; + for (i = 0; i < 1000; i++) + t (); + return 0; +} +/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/update-loopch_0.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/update-loopch_0.c new file mode 100644 index 000000000..e45c67461 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/update-loopch_0.c @@ -0,0 +1,20 @@ +/* { dg-options "-O2 -fdump-ipa-profile-blocks -fdump-tree-optimized-blocks-details" } */ +int max = 33333; +int a[8]; +int +main () +{ + int i; + for (i = 0; i < max; i++) + { + a[i % 8]++; + } + return 0; +} +/* 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 "count:33333" "profile"} } */ +/* { dg-final-use { scan-tree-dump "count:33332" "optimized"} } */ +/* { dg-final-use { cleanup-ipa-dump "profile" } } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/update-tailcall_0.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/update-tailcall_0.c new file mode 100644 index 000000000..285491445 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/update-tailcall_0.c @@ -0,0 +1,20 @@ +/* { dg-options "-O2 -fdump-tree-tailc -fdump-tree-optimized" } */ +__attribute__ ((noinline)) +int factorial(int x) +{ + if (x == 1) + return 1; + else + return x*factorial(--x); +} +int gbl; +int +main() +{ + gbl = factorial(100); + return 0; +} +/* { dg-final-use { scan-tree-dump-not "Invalid sum" "tailc"} } */ +/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ +/* { dg-final-use { cleanup-tree-dump "tailc" } } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/val-prof-1_0.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/val-prof-1_0.c new file mode 100644 index 000000000..d6f603e8b --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/val-prof-1_0.c @@ -0,0 +1,22 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */ +int a[1000]; +int b = 256; +int c = 257; +main () +{ + int i; + int n; + for (i = 0; i < 1000; i++) + { + if (i % 17) + n = c; + else n = b; + a[i] /= n; + } + 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"} } */ +/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ +/* { dg-final-use { cleanup-ipa-dump "profile" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/val-prof-2_0.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/val-prof-2_0.c new file mode 100644 index 000000000..16839612d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/val-prof-2_0.c @@ -0,0 +1,32 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */ +unsigned int a[1000]; +unsigned int b = 256; +unsigned int c = 1024; +unsigned int d = 17; +main () +{ + int i; + unsigned int n; + for (i = 0; i < 1000; i++) + { + a[i]=100*i; + } + for (i = 0; i < 1000; i++) + { + if (i % 2) + n = b; + else if (i % 3) + n = c; + else + n = d; + a[i] %= n; + } + return 0; +} +/* { dg-final-use { 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 { scan-tree-dump-not "Invalid sum" "optimized"} } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ +/* { dg-final-use { cleanup-ipa-dump "profile" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/val-prof-3_0.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/val-prof-3_0.c new file mode 100644 index 000000000..d7b3914a8 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/val-prof-3_0.c @@ -0,0 +1,32 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */ +unsigned int a[1000]; +unsigned int b = 257; +unsigned int c = 1023; +unsigned int d = 19; +main () +{ + int i; + unsigned int n; + for (i = 0; i < 1000; i++) + { + a[i]=18; + } + for (i = 0; i < 1000; i++) + { + if (i % 2) + n = b; + else if (i % 3) + n = c; + else + n = d; + a[i] %= n; + } + return 0; +} +/* { dg-final-use { 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 { scan-tree-dump-not "Invalid sum" "optimized"} } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ +/* { dg-final-use { cleanup-ipa-dump "profile" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/val-prof-4_0.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/val-prof-4_0.c new file mode 100644 index 000000000..239bf595d --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/val-prof-4_0.c @@ -0,0 +1,32 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */ +unsigned int a[1000]; +unsigned int b = 999; +unsigned int c = 1002; +unsigned int d = 1003; +main () +{ + int i; + unsigned int n; + for (i = 0; i < 1000; i++) + { + a[i]=1000+i; + } + for (i = 0; i < 1000; i++) + { + if (i % 2) + n = b; + else if (i % 3) + n = c; + else + n = d; + a[i] %= n; + } + return 0; +} +/* { dg-final-use { 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 { scan-tree-dump-not "Invalid sum" "optimized"} } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ +/* { dg-final-use { cleanup-ipa-dump "profile" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/val-prof-5_0.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/val-prof-5_0.c new file mode 100644 index 000000000..1a804a767 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/val-prof-5_0.c @@ -0,0 +1,17 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */ +int a[1000]; +int b=997; +main() +{ + int i; + for (i = 0; i < 1000; i++) + if (a[i]) + 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" } } */ +/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ +/* { dg-final-use { cleanup-ipa-dump "profile" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/val-prof-6_0.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/val-prof-6_0.c new file mode 100644 index 000000000..c439fcffe --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/val-prof-6_0.c @@ -0,0 +1,20 @@ +/* { dg-options "-O2 -fdump-tree-optimized" } */ +char a[1000]; +char b[1000]; +int size=1000; +__attribute__ ((noinline)) +t(int size) +{ + __builtin_memcpy(a,b,size); +} +int +main() +{ + int i; + for (i=0; i < size; i++) + t(i); + return 0; +} +/* { dg-final-use { scan-tree-dump "Average value sum:499500" "optimized"} } */ +/* { dg-final-use { scan-tree-dump "IOR value" "optimized"} } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/val-prof-7_0.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/val-prof-7_0.c new file mode 100644 index 000000000..5f5326384 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/val-prof-7_0.c @@ -0,0 +1,26 @@ +/* { dg-options "-O2 -fdump-ipa-profile -mtune=core2" } */ +/* { dg-skip-if "" { ! { i?86-*-* x86_64-*-* } } { "*" } { "" } } */ + +#include <strings.h> + +int foo(int len) +{ + char array[1000]; + bzero(array, len); + return 0; +} + +int main() { + int i; + for (i = 0; i < 1000; i++) + { + if (i > 990) + foo(16); + else + foo(8); + } + return 0; +} + +/* { dg-final-use { scan-ipa-dump "Single value 8 stringop transformation on bzero" "profile" } } */ +/* { dg-final-use { cleanup-ipa-dump "profile" } } */ diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/wcoverage-mismatch_0.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/wcoverage-mismatch_0.c new file mode 100644 index 000000000..e4231057f --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/lipo/wcoverage-mismatch_0.c @@ -0,0 +1,20 @@ +/* { dg-options "-O2 -Wno-coverage-mismatch" } */ + +int __attribute__((noinline)) bar (void) +{ +} + +int foo (int i) +{ +#ifdef _PROFILE_USE + if (i) + bar (); +#endif + return 0; +} + +int main(int argc, char **argv) +{ + foo (argc); + return 0; +} diff --git a/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/merge_block.c b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/merge_block.c new file mode 100644 index 000000000..91bd47482 --- /dev/null +++ b/gcc-4.9/gcc/testsuite/gcc.dg/tree-prof/merge_block.c @@ -0,0 +1,21 @@ + +/* { dg-options "-O2 -fno-ipa-pure-const -fdump-tree-optimized-blocks -fno-early-inlining" } */ +int a[8]; +int t() +{ + int i; + for (i = 0; i < 3; i++) + if (a[i]) + break; + return i; +} +main () +{ + int i; + /* The loop will be optimized away after ipa-inline. */ + for (i = 0; i < 1000; i++) + t (); + return 0; +} +/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ |