diff options
author | Ben Cheng <bccheng@google.com> | 2013-03-28 11:14:20 -0700 |
---|---|---|
committer | Ben Cheng <bccheng@google.com> | 2013-03-28 12:40:33 -0700 |
commit | af0c51ac87ab2a87caa03fa108f0d164987a2764 (patch) | |
tree | 4b8b470f7c5b69642fdab8d0aa1fbc148d02196b /gcc-4.8/gcc/testsuite/gcc.dg/tree-prof | |
parent | d87cae247d39ebf4f5a6bf25c932a14d2fdb9384 (diff) | |
download | toolchain_gcc-af0c51ac87ab2a87caa03fa108f0d164987a2764.tar.gz toolchain_gcc-af0c51ac87ab2a87caa03fa108f0d164987a2764.tar.bz2 toolchain_gcc-af0c51ac87ab2a87caa03fa108f0d164987a2764.zip |
[GCC 4.8] Initial check-in of GCC 4.8.0
Change-Id: I0719d8a6d0f69b367a6ab6f10eb75622dbf12771
Diffstat (limited to 'gcc-4.8/gcc/testsuite/gcc.dg/tree-prof')
34 files changed, 963 insertions, 0 deletions
diff --git a/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/bb-reorg.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/bb-reorg.c new file mode 100644 index 000000000..f850c9bfd --- /dev/null +++ b/gcc-4.8/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 <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.8/gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1.c new file mode 100644 index 000000000..e9f3a418d --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1.c @@ -0,0 +1,19 @@ +/* { dg-options "-O2 -fdump-ipa-profile" } */ +/* { 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" "profile" } } */ +/* { dg-final-use { cleanup-ipa-dump "profile" } } */ diff --git a/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1a.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/ic-misattribution-1a.c new file mode 100644 index 000000000..fa9d6e705 --- /dev/null +++ b/gcc-4.8/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 "profile" } } */ diff --git a/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.c new file mode 100644 index 000000000..df7481f4d --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/indir-call-prof.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}; + +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" "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.8/gcc/testsuite/gcc.dg/tree-prof/inliner-1.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/inliner-1.c new file mode 100644 index 000000000..b5340b56d --- /dev/null +++ b/gcc-4.8/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-4.8/gcc/testsuite/gcc.dg/tree-prof/peel-1.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/peel-1.c new file mode 100644 index 000000000..65f0c562c --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/peel-1.c @@ -0,0 +1,25 @@ +/* { dg-options "-O3 -fdump-rtl-loop2_unroll -fno-unroll-loops -fpeel-loops" } */ +void abort(); + +int a[1000]; +int +__attribute__ ((noinline)) +t() +{ + int i; + for (i=0;i<1000;i++) + if (!a[i]) + return 1; + abort (); +} +main() +{ + int i; + for (i=0;i<1000;i++) + t(); + return 0; +} +/* { dg-final-use { scan-rtl-dump "Considering simply peeling loop" "loop2_unroll" } } */ +/* 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 { cleanup-rtl-dump "loop2_unroll" } } */ diff --git a/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/pr34999.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/pr34999.c new file mode 100644 index 000000000..4ec42790e --- /dev/null +++ b/gcc-4.8/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-4.8/gcc/testsuite/gcc.dg/tree-prof/pr44777.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/pr44777.c new file mode 100644 index 000000000..1c4da7f5f --- /dev/null +++ b/gcc-4.8/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-4.8/gcc/testsuite/gcc.dg/tree-prof/pr45354.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/pr45354.c new file mode 100644 index 000000000..b30ad7769 --- /dev/null +++ b/gcc-4.8/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-4.8/gcc/testsuite/gcc.dg/tree-prof/pr47187.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/pr47187.c new file mode 100644 index 000000000..467ce252b --- /dev/null +++ b/gcc-4.8/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-4.8/gcc/testsuite/gcc.dg/tree-prof/pr49299-1.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/pr49299-1.c new file mode 100644 index 000000000..dd45bafc7 --- /dev/null +++ b/gcc-4.8/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-4.8/gcc/testsuite/gcc.dg/tree-prof/pr49299-2.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/pr49299-2.c new file mode 100644 index 000000000..220c8c8ff --- /dev/null +++ b/gcc-4.8/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-4.8/gcc/testsuite/gcc.dg/tree-prof/pr50907.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/pr50907.c new file mode 100644 index 000000000..2ba26e392 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/pr50907.c @@ -0,0 +1,5 @@ +/* PR middle-end/50907 */ +/* { dg-require-effective-target freorder } */ +/* { dg-options "-O -freorder-blocks-and-partition -fschedule-insns -fselective-scheduling -fpic" { target { { powerpc*-*-* ia64-*-* x86_64-*-* } && fpic } } } */ + +#include "pr45354.c" diff --git a/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/pr52027.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/pr52027.c new file mode 100644 index 000000000..c12f8b484 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/pr52027.c @@ -0,0 +1,19 @@ +/* PR debug/52027 */ +/* { dg-require-effective-target freorder } */ +/* { dg-options "-O -freorder-blocks-and-partition -fno-reorder-functions" } */ + +void +foo (int len) +{ + char array[1000]; + __builtin_memset (array, 0, len); +} + +int +main () +{ + int i; + for (i = 0; i < 1000; i++) + foo (8); + return 0; +} diff --git a/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/pr52150.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/pr52150.c new file mode 100644 index 000000000..accdb4a4c --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/pr52150.c @@ -0,0 +1,16 @@ +/* PR gcov-profile/52150 */ +/* { dg-options "-O0" } */ + +void foo () __asm__ ("bar"); + +void +foo () +{ +} + +int +main () +{ + foo (); + return 0; +} diff --git a/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/prof-robust-1.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/prof-robust-1.c new file mode 100644 index 000000000..316cfc757 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/prof-robust-1.c @@ -0,0 +1,25 @@ +/* { dg-options "-O2 -w" } */ + +#include <stdio.h> +#include <stdlib.h> + +#ifdef _PROFILE_USE +int foo(int x) { + return 3 * x; +} +#else +int foo(int x) { + return 3 * x; +} +#endif + +int x = 1000; + +int main(int argc, char *argv[]) { + int i; + int sum = 0; + for (i = 0; i < x; i++) + sum += i; + printf("%d\n", sum); + return 0; +} diff --git a/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/stringop-1.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/stringop-1.c new file mode 100644 index 000000000..f73061387 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/stringop-1.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.8/gcc/testsuite/gcc.dg/tree-prof/stringop-2.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/stringop-2.c new file mode 100644 index 000000000..f70fafba3 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/stringop-2.c @@ -0,0 +1,24 @@ +/* { dg-options "-O2 -fdump-tree-optimized -fdump-ipa-profile" } */ +int a[1000]; +int b[1000]; +int size=1; +int max=10000; +#ifdef __mips +/* We allow short memcpy()s for MIPS16. */ +int __attribute__((nomips16)) +#endif +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.8/gcc/testsuite/gcc.dg/tree-prof/switch-case-1.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/switch-case-1.c new file mode 100644 index 000000000..50ee9e44f --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/switch-case-1.c @@ -0,0 +1,40 @@ +/* { dg-options "-O2 -fdump-rtl-expand-all" } */ +int g; + +__attribute__((noinline)) void foo (int n) +{ + switch (n) + { + case 1: + g++; break; + case 2: + g += 2; break; + case 3: + g += 1; break; + case 4: + g += 3; break; + case 5: + g += 4; break; + case 6: + g += 5; break; + case 7: + g += 6; break; + case 8: + g += 7; break; + case 9: + g += 8; break; + default: + g += 8; break; + } +} + +int main () +{ + int i; + for (i = 0; i < 10000; i++) + 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"} } */ +/* { dg-final-use { cleanup-rtl-dump "expand" } } */ diff --git a/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/switch-case-2.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/switch-case-2.c new file mode 100644 index 000000000..07d4363d3 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/switch-case-2.c @@ -0,0 +1,40 @@ +/* { dg-options "-O2 -fdump-rtl-expand-all" } */ +int g; + +__attribute__((noinline)) void foo (int n) +{ + switch (n) + { + case 99: + g += 2; break; + case 1: + g++; break; + case 100: + g += 1; break; + case 4: + g += 3; break; + case 5: + g += 4; break; + case 6: + g += 5; break; + case 7: + g += 6; break; + case 8: + g += 7; break; + case 9: + g += 8; break; + default: + g += 8; break; + } +} + +int main () +{ + int i; + for (i = 0; i < 10000; i++) + 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"} } */ +/* { dg-final-use { cleanup-rtl-dump "expand" } } */ diff --git a/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/tracer-1.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/tracer-1.c new file mode 100644 index 000000000..385a1a5c2 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/tracer-1.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.8/gcc/testsuite/gcc.dg/tree-prof/tree-prof.exp b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/tree-prof.exp new file mode 100644 index 000000000..1f50eb322 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/tree-prof.exp @@ -0,0 +1,56 @@ +# Copyright (C) 2001-2013 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 "-fprofile-generate"] } { + return +} + +# The procedures in profopt.exp need these parameters. +set tool gcc +set prof_ext "gcda" + +if $tracelevel then { + strace $tracelevel +} + +# Load support procs. +load_lib profopt.exp + +# Save and override the default list defined in profopt.exp. +set treeprof_save_profopt_options $PROFOPT_OPTIONS +set PROFOPT_OPTIONS [list {}] + +# 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 +} + +set PROFOPT_OPTIONS $treeprof_save_profopt_options diff --git a/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/unroll-1.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/unroll-1.c new file mode 100644 index 000000000..0663b1286 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/unroll-1.c @@ -0,0 +1,23 @@ +/* { dg-options "-O3 -fdump-rtl-loop2_unroll -funroll-loops -fno-peel-loops" } */ +void abort (); + +int a[1000]; +int +__attribute__ ((noinline)) +t() +{ + int i; + for (i=0;i<1000;i++) + if (!a[i]) + return 1; + abort (); +} +main() +{ + int i; + for (i=0;i<1000;i++) + t(); + return 0; +} +/* { dg-final-use { scan-rtl-dump "Considering unrolling loop with constant number of iterations" "loop2_unroll" } } */ +/* { dg-final-use { cleanup-rtl-dump "loop2_unroll" } } */ diff --git a/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/update-cunroll-2.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/update-cunroll-2.c new file mode 100644 index 000000000..d559b9245 --- /dev/null +++ b/gcc-4.8/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-4.8/gcc/testsuite/gcc.dg/tree-prof/update-loopch.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/update-loopch.c new file mode 100644 index 000000000..e2656a306 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/update-loopch.c @@ -0,0 +1,21 @@ +/* { dg-options "-O2 -fdump-ipa-profile-blocks-details -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 "loop depth 0, count 33334" "profile"} } */ +/* { dg-final-use { scan-tree-dump "loop depth 1, count 33332" "optimized"} } */ +/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */ +/* { dg-final-use { cleanup-ipa-dump "profile" } } */ +/* { dg-final-use { cleanup-tree-dump "optimized" } } */ diff --git a/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/update-tailcall.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/update-tailcall.c new file mode 100644 index 000000000..285491445 --- /dev/null +++ b/gcc-4.8/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-4.8/gcc/testsuite/gcc.dg/tree-prof/val-prof-1.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/val-prof-1.c new file mode 100644 index 000000000..d6f603e8b --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/val-prof-1.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.8/gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c new file mode 100644 index 000000000..16839612d --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/val-prof-2.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.8/gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/val-prof-3.c new file mode 100644 index 000000000..d7b3914a8 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/val-prof-3.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.8/gcc/testsuite/gcc.dg/tree-prof/val-prof-4.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/val-prof-4.c new file mode 100644 index 000000000..239bf595d --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/val-prof-4.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.8/gcc/testsuite/gcc.dg/tree-prof/val-prof-5.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/val-prof-5.c new file mode 100644 index 000000000..1a804a767 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/val-prof-5.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.8/gcc/testsuite/gcc.dg/tree-prof/val-prof-6.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/val-prof-6.c new file mode 100644 index 000000000..c439fcffe --- /dev/null +++ b/gcc-4.8/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-4.8/gcc/testsuite/gcc.dg/tree-prof/val-prof-7.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/val-prof-7.c new file mode 100644 index 000000000..6c64d0795 --- /dev/null +++ b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/val-prof-7.c @@ -0,0 +1,26 @@ +/* { dg-options "-O2 -fdump-ipa-profile -mtune=core2" } */ +/* { dg-skip-if "" { ! { i?86-*-* x86_64-*-* } } { "*" } { "" } } */ + +extern void bzero (void *, __SIZE_TYPE__); + +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.8/gcc/testsuite/gcc.dg/tree-prof/wcoverage-mismatch.c b/gcc-4.8/gcc/testsuite/gcc.dg/tree-prof/wcoverage-mismatch.c new file mode 100644 index 000000000..e4231057f --- /dev/null +++ b/gcc-4.8/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; +} |