dojump.c (do_compare_rtx_and_jump): Sets correct probability for compiler inserted...
authorDehao Chen <dehao@google.com>
Thu, 27 Mar 2014 00:41:10 +0000 (00:41 +0000)
committerDehao Chen <dehao@gcc.gnu.org>
Thu, 27 Mar 2014 00:41:10 +0000 (00:41 +0000)
* dojump.c (do_compare_rtx_and_jump): Sets correct probability for
compiler inserted conditional jumps for NAN float check.
* gcc.dg/predict-8.c: New test.

From-SVN: r208860

gcc/ChangeLog
gcc/dojump.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/predict-8.c [new file with mode: 0644]

index 9477cf0..b9fc168 100644 (file)
@@ -1,3 +1,8 @@
+2014-03-26  Dehao Chen  <dehao@google.com>
+
+       * dojump.c (do_compare_rtx_and_jump): Sets correct probability for
+       compiler inserted conditional jumps for NAN float check.
+
 2014-03-26  Jakub Jelinek  <jakub@redhat.com>
 
        * ubsan.h (ubsan_create_data): Change second argument's type
index 7846314..1c3a2be 100644 (file)
@@ -1103,6 +1103,11 @@ do_compare_rtx_and_jump (rtx op0, rtx op1, enum rtx_code code, int unsignedp,
 
          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 rtx_code code, int unsignedp,
                  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 a5bcb88..98ee981 100644 (file)
@@ -1,3 +1,7 @@
+2014-03-26  Dehao Chen  <dehao@google.com>
+
+       * gcc.dg/predict-8.c: New test.
+
 2014-03-26  Fabien ChĂȘne  <fabien@gcc.gnu.org>
 
         PR c++/52369
diff --git a/gcc/testsuite/gcc.dg/predict-8.c b/gcc/testsuite/gcc.dg/predict-8.c
new file mode 100644 (file)
index 0000000..8c78ca7
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-do compile { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-O2 -fdump-rtl-expand" } */
+
+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" } } */