This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Set correct probability for ORDER/UNORDER jumps
- From: Dehao Chen <dehao at google dot com>
- To: Xinliang David Li <davidxl at google dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Steven Bosscher <stevenb dot gcc at gmail dot com>
- Date: Fri, 24 Jan 2014 10:20:53 -0800
- Subject: Re: [PATCH] Set correct probability for ORDER/UNORDER jumps
- Authentication-results: sourceware.org; auth=none
- References: <CAO2gOZWhfyPKEmaEMBTap3e1RTAfsi6++J=BgY+C8gcmFfRT4w at mail dot gmail dot com> <CAAkRFZKioePmB+KHNwwfub0scFWie7gxotPQ6h_MXgmCQgix5g at mail dot gmail dot com>
A new test is added:
gcc/testsuite/ChangeLog:
2014-01-24 Dehao Chen <dehao@google.com>
* gcc.dg/predict-8.c: New test.
Index: gcc/testsuite/gcc.dg/predict-8.c
===================================================================
--- gcc/testsuite/gcc.dg/predict-8.c (revision 0)
+++ gcc/testsuite/gcc.dg/predict-8.c (revision 0)
@@ -0,0 +1,12 @@
+/* { dg-do compile { target { x86_64-*-* } } } */
+/* { dg-options "-O2 -fdump-rtl-expand -c" } */
+
+int foo(float a, float b) {
+ if (a == b)
+ return 1;
+ else
+ return 2;
+}
+
+/* { dg-final { scan-rtl-dump-times "REG_BR_PROB 100" 1 "expand"} } */
+/* { dg-final { cleanup-rtl-dump "expand" } } */
On Thu, Jan 23, 2014 at 4:30 PM, Xinliang David Li <davidxl@google.com> wrote:
> Is it possible to add a test case?
>
> David
>
> On Wed, Jan 22, 2014 at 6:08 PM, Dehao Chen <dehao@google.com> wrote:
>> During floating point comparison, compiler inserts conditional jumps
>> to check if the operand is NAN. These type of checks are normally
>> false. However, compiler sets the probability the same as the original
>> float-compare conditional jump. This patch sets the probability of
>> these conditional jumps as 1%.
>>
>> Bootstrapped and passed regression test.
>>
>> OK for trunk?
>>
>> Thanks,
>> Dehao
>>
>> gcc/ChangeLog:
>> 2014-01-22 Dehao Chen <dehao@google.com>
>>
>> * dojump.c (do_compare_rtx_and_jump): Sets correct probability for
>> compiler inserted conditional jumps for NAN float check.
>>
>> Index: gcc/dojump.c
>> ===================================================================
>> --- gcc/dojump.c (revision 206945)
>> +++ gcc/dojump.c (working copy)
>> @@ -1103,6 +1103,11 @@ do_compare_rtx_and_jump (rtx op0, rtx op1, enum rt
>>
>> else
>> {
>> + int first_prob = prob;
>> + if (first_code == UNORDERED)
>> + first_prob = REG_BR_PROB_BASE / 100;
>> + else if (first_code == ORDERED)
>> + first_prob = REG_BR_PROB_BASE - REG_BR_PROB_BASE / 100;
>> if (and_them)
>> {
>> rtx dest_label;
>> @@ -1116,11 +1121,13 @@ do_compare_rtx_and_jump (rtx op0, rtx op1, enum rt
>> else
>> dest_label = if_false_label;
>> do_compare_rtx_and_jump (op0, op1, first_code,
>> unsignedp, mode,
>> - size, dest_label, NULL_RTX, prob);
>> + size, dest_label, NULL_RTX,
>> + first_prob);
>> }
>> else
>> do_compare_rtx_and_jump (op0, op1, first_code, unsignedp, mode,
>> - size, NULL_RTX, if_true_label, prob);
>> + size, NULL_RTX, if_true_label,
>> + first_prob);
>> }
>> }