From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- gcc/testsuite/gcc.dg/tree-prof/bb-reorg.c | 39 ++++++++++++++++ .../gcc.dg/tree-prof/ic-misattribution-1.c | 19 ++++++++ .../gcc.dg/tree-prof/ic-misattribution-1a.c | 22 +++++++++ gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c | 43 +++++++++++++++++ gcc/testsuite/gcc.dg/tree-prof/inliner-1.c | 42 +++++++++++++++++ gcc/testsuite/gcc.dg/tree-prof/pr34999.c | 45 ++++++++++++++++++ gcc/testsuite/gcc.dg/tree-prof/pr44777.c | 43 +++++++++++++++++ gcc/testsuite/gcc.dg/tree-prof/pr45354.c | 43 +++++++++++++++++ gcc/testsuite/gcc.dg/tree-prof/pr47187.c | 23 +++++++++ gcc/testsuite/gcc.dg/tree-prof/pr49299-1.c | 34 ++++++++++++++ gcc/testsuite/gcc.dg/tree-prof/pr49299-2.c | 34 ++++++++++++++ gcc/testsuite/gcc.dg/tree-prof/stringop-1.c | 22 +++++++++ gcc/testsuite/gcc.dg/tree-prof/stringop-2.c | 20 ++++++++ gcc/testsuite/gcc.dg/tree-prof/tracer-1.c | 18 ++++++++ gcc/testsuite/gcc.dg/tree-prof/tree-prof.exp | 54 ++++++++++++++++++++++ gcc/testsuite/gcc.dg/tree-prof/update-cunroll-2.c | 21 +++++++++ gcc/testsuite/gcc.dg/tree-prof/update-loopch.c | 21 +++++++++ gcc/testsuite/gcc.dg/tree-prof/update-tailcall.c | 20 ++++++++ gcc/testsuite/gcc.dg/tree-prof/val-prof-1.c | 22 +++++++++ gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c | 32 +++++++++++++ gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c | 32 +++++++++++++ gcc/testsuite/gcc.dg/tree-prof/val-prof-4.c | 32 +++++++++++++ gcc/testsuite/gcc.dg/tree-prof/val-prof-5.c | 17 +++++++ gcc/testsuite/gcc.dg/tree-prof/val-prof-6.c | 20 ++++++++ gcc/testsuite/gcc.dg/tree-prof/val-prof-7.c | 26 +++++++++++ .../gcc.dg/tree-prof/wcoverage-mismatch.c | 20 ++++++++ 26 files changed, 764 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/tree-prof/bb-reorg.c create mode 100644 gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1.c create mode 100644 gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1a.c create mode 100644 gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c create mode 100644 gcc/testsuite/gcc.dg/tree-prof/inliner-1.c create mode 100644 gcc/testsuite/gcc.dg/tree-prof/pr34999.c create mode 100644 gcc/testsuite/gcc.dg/tree-prof/pr44777.c create mode 100644 gcc/testsuite/gcc.dg/tree-prof/pr45354.c create mode 100644 gcc/testsuite/gcc.dg/tree-prof/pr47187.c create mode 100644 gcc/testsuite/gcc.dg/tree-prof/pr49299-1.c create mode 100644 gcc/testsuite/gcc.dg/tree-prof/pr49299-2.c create mode 100644 gcc/testsuite/gcc.dg/tree-prof/stringop-1.c create mode 100644 gcc/testsuite/gcc.dg/tree-prof/stringop-2.c create mode 100644 gcc/testsuite/gcc.dg/tree-prof/tracer-1.c create mode 100644 gcc/testsuite/gcc.dg/tree-prof/tree-prof.exp create mode 100644 gcc/testsuite/gcc.dg/tree-prof/update-cunroll-2.c create mode 100644 gcc/testsuite/gcc.dg/tree-prof/update-loopch.c create mode 100644 gcc/testsuite/gcc.dg/tree-prof/update-tailcall.c create mode 100644 gcc/testsuite/gcc.dg/tree-prof/val-prof-1.c create mode 100644 gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c create mode 100644 gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c create mode 100644 gcc/testsuite/gcc.dg/tree-prof/val-prof-4.c create mode 100644 gcc/testsuite/gcc.dg/tree-prof/val-prof-5.c create mode 100644 gcc/testsuite/gcc.dg/tree-prof/val-prof-6.c create mode 100644 gcc/testsuite/gcc.dg/tree-prof/val-prof-7.c create mode 100644 gcc/testsuite/gcc.dg/tree-prof/wcoverage-mismatch.c (limited to 'gcc/testsuite/gcc.dg/tree-prof') diff --git a/gcc/testsuite/gcc.dg/tree-prof/bb-reorg.c b/gcc/testsuite/gcc.dg/tree-prof/bb-reorg.c new file mode 100644 index 000000000..f850c9bfd --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/bb-reorg.c @@ -0,0 +1,39 @@ +/* { dg-require-effective-target freorder } */ +/* { dg-options "-O2 -freorder-blocks-and-partition" } */ + +#include + +#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/testsuite/gcc.dg/tree-prof/ic-misattribution-1.c b/gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1.c new file mode 100644 index 000000000..94a5953c9 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1.c @@ -0,0 +1,19 @@ +/* { dg-options "-O2 -fdump-ipa-tree_profile_ipa" } */ +/* { dg-additional-sources "ic-misattribution-1a.c" } */ + +extern void other_caller (void); + +void +callee (void) +{ + return; +} + +void +caller(void (*func) (void)) +{ + func (); +} + +/* { dg-final-use { scan-ipa-dump "hist->count 1 hist->all 1" "tree_profile_ipa" } } */ +/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1a.c b/gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1a.c new file mode 100644 index 000000000..caa10fec5 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1a.c @@ -0,0 +1,22 @@ +/* { dg-options "-DEMPTY" } */ +/* This file is only needed in combination with ic-misattribution-1.c + but there's no easy way to make this file ignored. */ +extern void callee (void); +extern void caller (void (*func) (void)); + +typedef void (*func_t) (void); +func_t func; + +int +main () +{ +#ifdef EMPTY +#else + func = callee; + caller (callee); + func (); +#endif + return 0; +} + +/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c b/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c new file mode 100644 index 000000000..8f7508b49 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c @@ -0,0 +1,43 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-tree_profile_ipa" } */ + +static int a1 (void) +{ + return 10; +} + +static int a2 (void) +{ + return 0; +} + +typedef int (*tp) (void); + +static tp aa [] = {a2, a1, a1, a1, a1}; + +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 transformation on insn" "tree_profile_ipa"} } */ +/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ +/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/inliner-1.c b/gcc/testsuite/gcc.dg/tree-prof/inliner-1.c new file mode 100644 index 000000000..b5340b56d --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/inliner-1.c @@ -0,0 +1,42 @@ +/* { dg-options "-O2 -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 be inlined, while hot function should not. + 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/testsuite/gcc.dg/tree-prof/pr34999.c b/gcc/testsuite/gcc.dg/tree-prof/pr34999.c new file mode 100644 index 000000000..4ec42790e --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/pr34999.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/testsuite/gcc.dg/tree-prof/pr44777.c b/gcc/testsuite/gcc.dg/tree-prof/pr44777.c new file mode 100644 index 000000000..1c4da7f5f --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/pr44777.c @@ -0,0 +1,43 @@ +/* PR middle-end/44777 */ +/* { dg-options "-O0" } */ +/* A variant of gcc.c-torture/execute/comp-goto-2.c. */ + +extern void abort (void); +extern void exit (int); + +#ifdef STACK_SIZE +#define DEPTH ((STACK_SIZE) / 512 + 1) +#else +#define DEPTH 1000 +#endif + +#if ! defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES) +int +x (int a) +{ + __label__ xlab; + void y (int a) + { + void *x = &&llab; + if (a==-1) + goto *x; + if (a==0) + goto xlab; + llab: + y (a-1); + } + y (a); + xlab:; + return a; +} +#endif + +int +main () +{ +#if ! defined (NO_LABEL_VALUES) && !defined (NO_TRAMPOLINES) + if (x (DEPTH) != DEPTH) + abort (); +#endif + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/tree-prof/pr45354.c b/gcc/testsuite/gcc.dg/tree-prof/pr45354.c new file mode 100644 index 000000000..b30ad7769 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/pr45354.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/testsuite/gcc.dg/tree-prof/pr47187.c b/gcc/testsuite/gcc.dg/tree-prof/pr47187.c new file mode 100644 index 000000000..467ce252b --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/pr47187.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/testsuite/gcc.dg/tree-prof/pr49299-1.c b/gcc/testsuite/gcc.dg/tree-prof/pr49299-1.c new file mode 100644 index 000000000..dd45bafc7 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/pr49299-1.c @@ -0,0 +1,34 @@ +/* { dg-options "-O2" } */ + +__attribute__((noreturn)) void (*fn) (void); + +volatile int v; + +__attribute__((noreturn)) void +fn0 (void) +{ + __builtin_exit (0); +} + +__attribute__((noreturn)) void +fn1 (void) +{ + __builtin_exit (1); +} + +__attribute__((noinline, noclone)) void +setfn (__attribute__((noreturn)) void (*x) (void)) +{ + fn = x; +} + +int +main () +{ + int i; + if (v < 1) + setfn (fn0); + else + setfn (fn1); + fn (); +} diff --git a/gcc/testsuite/gcc.dg/tree-prof/pr49299-2.c b/gcc/testsuite/gcc.dg/tree-prof/pr49299-2.c new file mode 100644 index 000000000..220c8c8ff --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/pr49299-2.c @@ -0,0 +1,34 @@ +/* { dg-options "-O2" } */ + +void (*fn) (void); + +volatile int v; + +__attribute__((noreturn)) void +fn0 (void) +{ + __builtin_exit (0); +} + +void +fn1 (void) +{ +} + +__attribute__((noinline, noclone)) void +setfn (void (*x) (void)) +{ + fn = x; +} + +int +main () +{ + int i; + if (v < 1) + setfn (fn0); + else + setfn (fn1); + fn (); + return 0; +} diff --git a/gcc/testsuite/gcc.dg/tree-prof/stringop-1.c b/gcc/testsuite/gcc.dg/tree-prof/stringop-1.c new file mode 100644 index 000000000..fe200c82f --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/stringop-1.c @@ -0,0 +1,22 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-tree_profile_ipa" } */ +int a[1000]; +int b[1000]; +int size=1; +int max=10000; +main() +{ + int i; + for (i=0;i. + +# 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 "gcda" + +# 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 -D_PROFILE_GENERATE" +set feedback_option "-fprofile-use -D_PROFILE_USE" + +foreach src [lsort [glob -nocomplain $srcdir/$subdir/*.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/testsuite/gcc.dg/tree-prof/update-cunroll-2.c b/gcc/testsuite/gcc.dg/tree-prof/update-cunroll-2.c new file mode 100644 index 000000000..d559b9245 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/update-cunroll-2.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/testsuite/gcc.dg/tree-prof/update-loopch.c b/gcc/testsuite/gcc.dg/tree-prof/update-loopch.c new file mode 100644 index 000000000..6b7dbd418 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/update-loopch.c @@ -0,0 +1,21 @@ +/* { dg-options "-O2 -fdump-ipa-tree_profile_ipa-blocks -fdump-tree-optimized-blocks" } */ +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" "tree_profile_ipa"} } */ +/* { dg-final-use { scan-tree-dump "count:33332" "optimized"} } */ +/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ +/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/update-tailcall.c b/gcc/testsuite/gcc.dg/tree-prof/update-tailcall.c new file mode 100644 index 000000000..285491445 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/update-tailcall.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/testsuite/gcc.dg/tree-prof/val-prof-1.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-1.c new file mode 100644 index 000000000..181b3d184 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-1.c @@ -0,0 +1,22 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-tree_profile_ipa" } */ +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" "tree_profile_ipa"} } */ +/* { 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 "tree_profile_ipa" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c new file mode 100644 index 000000000..f96255d0c --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c @@ -0,0 +1,32 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-tree_profile_ipa" } */ +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" "tree_profile_ipa" } } */ +/* 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\]* \\+ 0xffff" "optimized"} } */ +/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ +/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c new file mode 100644 index 000000000..802dbf02a --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c @@ -0,0 +1,32 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-tree_profile_ipa" } */ +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" "tree_profile_ipa" } } */ +/* 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 "tree_profile_ipa" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-4.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-4.c new file mode 100644 index 000000000..d4d3085aa --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-4.c @@ -0,0 +1,32 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-tree_profile_ipa" } */ +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" "tree_profile_ipa" } } */ +/* 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 "tree_profile_ipa" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-5.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-5.c new file mode 100644 index 000000000..581f4d54a --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-5.c @@ -0,0 +1,17 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-tree_profile_ipa" } */ +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" "tree_profile_ipa" } } */ +/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ +/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-6.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-6.c new file mode 100644 index 000000000..c439fcffe --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-6.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/testsuite/gcc.dg/tree-prof/val-prof-7.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-7.c new file mode 100644 index 000000000..664b62039 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-7.c @@ -0,0 +1,26 @@ +/* { dg-options "-O2 -fdump-ipa-tree_profile_ipa -mtune=core2" } */ +/* { dg-skip-if "" { ! { i?86-*-* x86_64-*-* } } { "*" } { "" } } */ + +#include + +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" "tree_profile_ipa" } } */ +/* { dg-final-use { cleanup-ipa-dump "tree_profile_ipa" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-prof/wcoverage-mismatch.c b/gcc/testsuite/gcc.dg/tree-prof/wcoverage-mismatch.c new file mode 100644 index 000000000..e4231057f --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-prof/wcoverage-mismatch.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; +} -- cgit v1.2.3