diff mbox

Set correct probability for ORDER/UNORDER jumps

Message ID CAO2gOZWLUUEAmBDWthEmsiMDnRi565sfb7SLn5rur4=GkD8gWA@mail.gmail.com
State New
Headers show

Commit Message

Dehao Chen Jan. 24, 2014, 6:20 p.m. UTC
A new test is added:

gcc/testsuite/ChangeLog:

2014-01-24  Dehao Chen  <dehao@google.com>

        * gcc.dg/predict-8.c: New test.


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

Comments

Jakub Jelinek Jan. 24, 2014, 6:57 p.m. UTC | #1
On Fri, Jan 24, 2014 at 10:20:53AM -0800, Dehao Chen wrote:
> --- 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-*-* } } } */

If you want it for x86_64 64-bit, then
/* { dg-do compile { target { { i?86-*-* x86_64-*-* } && lp64 } } } */

(or just limit the scan-rtl-dump-times regexp to the above mentioned
target).

> +/* { dg-options "-O2 -fdump-rtl-expand -c" } */

No -c in dg-options please.

	Jakub
H.J. Lu Jan. 24, 2014, 7:38 p.m. UTC | #2
On Fri, Jan 24, 2014 at 10:57 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Fri, Jan 24, 2014 at 10:20:53AM -0800, Dehao Chen wrote:
>> --- 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-*-* } } } */
>
> If you want it for x86_64 64-bit, then
> /* { dg-do compile { target { { i?86-*-* x86_64-*-* } && lp64 } } } */
>

It should be "! { ia32 }" instead of "lp64" unless it doesn't work
for x32.
diff mbox

Patch

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" } } */