This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Set correct probability for ORDER/UNORDER jumps


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);
>>      }
>>   }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]