From 277b4867eee3e48b4423e7341b9b5670f827d1c8 Mon Sep 17 00:00:00 2001 From: Jan Hubicka Date: Sun, 31 Aug 2008 13:40:11 +0200 Subject: [PATCH] cold-attribute-1.c: New testcase. * gcc.target/i386/cold-attribute-1.c: New testcase. * gcc.target/i386/cold-attribute-2.c: New testcase. * gcc.target/i386/cold-attribute-3.c: New testcase. * gcc.target/i386/cold-attribute-4.c: New testcase. * predict.c (PROB_VERY_LIKELY): Make small enough so things become cold. * predict.def (PRED_NORETURN_CALL, PRED_COLD_CALL): Use it. From-SVN: r139827 --- gcc/ChangeLog | 6 +++ gcc/predict.c | 6 ++- gcc/predict.def | 4 +- gcc/testsuite/ChangeLog | 7 ++++ .../gcc.target/i386/cold-attribute-1.c | 18 ++++++++ .../gcc.target/i386/cold-attribute-2.c | 14 +++++++ .../gcc.target/i386/cold-attribute-3.c | 12 ++++++ .../gcc.target/i386/cold-attribute-4.c | 12 ++++++ .../gcc.target/i386/cold-attribute-4.s | 41 +++++++++++++++++++ 9 files changed, 116 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/cold-attribute-1.c create mode 100644 gcc/testsuite/gcc.target/i386/cold-attribute-2.c create mode 100644 gcc/testsuite/gcc.target/i386/cold-attribute-3.c create mode 100644 gcc/testsuite/gcc.target/i386/cold-attribute-4.c create mode 100644 gcc/testsuite/gcc.target/i386/cold-attribute-4.s diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 11c05928ace..9b7ece09082 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2008-08-31 Jan Hubicka + + * predict.c (PROB_VERY_LIKELY): Make small enough so things + become cold. + * predict.def (PRED_NORETURN_CALL, PRED_COLD_CALL): Use it. + 2008-08-31 Jakub Jelinek PR debug/37287 diff --git a/gcc/predict.c b/gcc/predict.c index 6ca1a0cddc2..e02f9f890c2 100644 --- a/gcc/predict.c +++ b/gcc/predict.c @@ -66,8 +66,10 @@ along with GCC; see the file COPYING3. If not see static sreal real_zero, real_one, real_almost_one, real_br_prob_base, real_inv_br_prob_base, real_one_half, real_bb_freq_max; -/* Random guesstimation given names. */ -#define PROB_VERY_UNLIKELY (REG_BR_PROB_BASE / 100 - 1) +/* Random guesstimation given names. + PROV_VERY_UNLIKELY should be small enough so basic block predicted + by it gets bellow HOT_BB_FREQUENCY_FRANCTION. */ +#define PROB_VERY_UNLIKELY (REG_BR_PROB_BASE / 2000 - 1) #define PROB_EVEN (REG_BR_PROB_BASE / 2) #define PROB_VERY_LIKELY (REG_BR_PROB_BASE - PROB_VERY_UNLIKELY) #define PROB_ALWAYS (REG_BR_PROB_BASE) diff --git a/gcc/predict.def b/gcc/predict.def index 62ae9d9f8d3..e97e563fdb4 100644 --- a/gcc/predict.def +++ b/gcc/predict.def @@ -69,11 +69,11 @@ DEF_PREDICTOR (PRED_LOOP_ITERATIONS_GUESSED, "guessed loop iterations", DEF_PREDICTOR (PRED_CONTINUE, "continue", HITRATE (50), 0) /* Branch to basic block containing call marked by noreturn attribute. */ -DEF_PREDICTOR (PRED_NORETURN, "noreturn call", HITRATE (99), +DEF_PREDICTOR (PRED_NORETURN, "noreturn call", PROB_VERY_LIKELY, PRED_FLAG_FIRST_MATCH) /* Branch to basic block containing call marked by cold function attribute. */ -DEF_PREDICTOR (PRED_COLD_FUNCTION, "cold function call", HITRATE (99), +DEF_PREDICTOR (PRED_COLD_FUNCTION, "cold function call", PROB_VERY_LIKELY, PRED_FLAG_FIRST_MATCH) /* Loopback edge is taken. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7e855c6ea24..3e4a2e9cc27 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2008-08-31 Jan Hubicka + + * gcc.target/i386/cold-attribute-1.c: New testcase. + * gcc.target/i386/cold-attribute-2.c: New testcase. + * gcc.target/i386/cold-attribute-3.c: New testcase. + * gcc.target/i386/cold-attribute-4.c: New testcase. + 2008-08-31 Jakub Jelinek PR debug/37287 diff --git a/gcc/testsuite/gcc.target/i386/cold-attribute-1.c b/gcc/testsuite/gcc.target/i386/cold-attribute-1.c new file mode 100644 index 00000000000..22615b38790 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/cold-attribute-1.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +#include +static inline +__attribute__ ((cold)) +my_cold_memset (void *a, int b,int c) +{ + memset (a,b,c); +} +t(void *a,int b,int c) +{ + if (a) + my_cold_memset (a,b,c); +} + +/* The IF conditional should be predicted as cold and my_cold_memset inlined + for size expanding memset as rep; stosb. */ +/* { dg-final { scan-assembler "stosb" } } */ diff --git a/gcc/testsuite/gcc.target/i386/cold-attribute-2.c b/gcc/testsuite/gcc.target/i386/cold-attribute-2.c new file mode 100644 index 00000000000..93ea906614f --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/cold-attribute-2.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +#include +t(int c) +{ + if (__builtin_expect (c, 0)) + { + cold_hint (); + return c * 11; + } + return c; +} + +/* { dg-final { scan-assembler "imul" } } */ diff --git a/gcc/testsuite/gcc.target/i386/cold-attribute-3.c b/gcc/testsuite/gcc.target/i386/cold-attribute-3.c new file mode 100644 index 00000000000..5225428c5c1 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/cold-attribute-3.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +#include + +int +__attribute__ ((cold)) +t(int c) +{ + return c * 11; +} + +/* { dg-final { scan-assembler "imul" } } */ diff --git a/gcc/testsuite/gcc.target/i386/cold-attribute-4.c b/gcc/testsuite/gcc.target/i386/cold-attribute-4.c new file mode 100644 index 00000000000..37a41e954da --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/cold-attribute-4.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ +#include + +int +__attribute__ ((cold)) +t(int c) +{ + return -1; +} + +/* { dg-final { scan-assembler "orl" } } */ diff --git a/gcc/testsuite/gcc.target/i386/cold-attribute-4.s b/gcc/testsuite/gcc.target/i386/cold-attribute-4.s new file mode 100644 index 00000000000..68d05d09d4b --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/cold-attribute-4.s @@ -0,0 +1,41 @@ + .file "cold-attribute-4.c" + .text + .p2align 4,,15 +.globl t + .type t, @function +t: +.LFB14: + movl $-1, %eax + ret +.LFE14: + .size t, .-t + .section .eh_frame,"a",@progbits +.Lframe1: + .long .LECIE1-.LSCIE1 +.LSCIE1: + .long 0x0 + .byte 0x1 + .string "zR" + .uleb128 0x1 + .sleb128 -8 + .byte 0x10 + .uleb128 0x1 + .byte 0x3 + .byte 0xc + .uleb128 0x7 + .uleb128 0x8 + .byte 0x90 + .uleb128 0x1 + .align 8 +.LECIE1: +.LSFDE1: + .long .LEFDE1-.LASFDE1 +.LASFDE1: + .long .LASFDE1-.Lframe1 + .long .LFB14 + .long .LFE14-.LFB14 + .uleb128 0x0 + .align 8 +.LEFDE1: + .ident "GCC: (GNU) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)" + .section .note.GNU-stack,"",@progbits -- 2.30.2