diff mbox

Set correct probability for ORDER/UNORDER jumps

Message ID CAO2gOZWhfyPKEmaEMBTap3e1RTAfsi6++J=BgY+C8gcmFfRT4w@mail.gmail.com
State New
Headers show

Commit Message

Dehao Chen Jan. 23, 2014, 2:08 a.m. UTC
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.

Comments

Xinliang David Li Jan. 24, 2014, 12:30 a.m. UTC | #1
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);
>      }
>   }
diff mbox

Patch

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