aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2008-08-31 13:40:11 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2008-08-31 11:40:11 +0000
commit277b4867eee3e48b4423e7341b9b5670f827d1c8 (patch)
tree57ded3bb457ee70d3fede2ec7f8847787321ac33
parent8518c095a8aaa6375e1e7046c824d7c2a9893855 (diff)
downloadgcc-277b4867eee3e48b4423e7341b9b5670f827d1c8.zip
gcc-277b4867eee3e48b4423e7341b9b5670f827d1c8.tar.gz
gcc-277b4867eee3e48b4423e7341b9b5670f827d1c8.tar.bz2
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
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/predict.c6
-rw-r--r--gcc/predict.def4
-rw-r--r--gcc/testsuite/ChangeLog7
-rw-r--r--gcc/testsuite/gcc.target/i386/cold-attribute-1.c18
-rw-r--r--gcc/testsuite/gcc.target/i386/cold-attribute-2.c14
-rw-r--r--gcc/testsuite/gcc.target/i386/cold-attribute-3.c12
-rw-r--r--gcc/testsuite/gcc.target/i386/cold-attribute-4.c12
-rw-r--r--gcc/testsuite/gcc.target/i386/cold-attribute-4.s41
9 files changed, 116 insertions, 4 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 11c0592..9b7ece0 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2008-08-31 Jan Hubicka <jh@suse.cz>
+
+ * 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 <jakub@redhat.com>
PR debug/37287
diff --git a/gcc/predict.c b/gcc/predict.c
index 6ca1a0c..e02f9f8 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 62ae9d9..e97e563 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 7e855c6..3e4a2e9 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2008-08-31 Jan Hubicka <jh@suse.cz>
+
+ * 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 <jakub@redhat.com>
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 0000000..22615b3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cold-attribute-1.c
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+#include <string.h>
+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 0000000..93ea906
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cold-attribute-2.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+#include <string.h>
+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 0000000..5225428
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cold-attribute-3.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+#include <string.h>
+
+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 0000000..37a41e9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/i386/cold-attribute-4.c
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+#include <string.h>
+
+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 0000000..68d05d0
--- /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