cold-attribute-1.c: New testcase.
authorJan Hubicka <jh@suse.cz>
Sun, 31 Aug 2008 11:40:11 +0000 (13:40 +0200)
committerJan Hubicka <hubicka@gcc.gnu.org>
Sun, 31 Aug 2008 11:40:11 +0000 (11:40 +0000)
* 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
gcc/predict.c
gcc/predict.def
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/cold-attribute-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/cold-attribute-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/cold-attribute-3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/cold-attribute-4.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/cold-attribute-4.s [new file with mode: 0644]

index 11c05928aceba6c0b114266e716a992d9b30d86b..9b7ece0908227c3a095ec09a508a5d9c109b2d93 100644 (file)
@@ -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
index 6ca1a0cddc2516a1f81e3c39a6b1568b8cee1f64..e02f9f890c2fd417bbe94f3c29d37627a5bed436 100644 (file)
@@ -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)
index 62ae9d9f8d3dee4dc1ae14d442f9baaf1059327e..e97e563fdb46c1ad64ddb27a553412fbc3ad9783 100644 (file)
@@ -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.  */
index 7e855c6ea24a554cb66173f18d62f711d5ebbedc..3e4a2e9cc271b50792ec0317c276511b64f4f155 100644 (file)
@@ -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 (file)
index 0000000..22615b3
--- /dev/null
@@ -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 (file)
index 0000000..93ea906
--- /dev/null
@@ -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 (file)
index 0000000..5225428
--- /dev/null
@@ -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 (file)
index 0000000..37a41e9
--- /dev/null
@@ -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 (file)
index 0000000..68d05d0
--- /dev/null
@@ -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