Hi,
this is patch I comitted.
Thanks for looking into it,
Honza

        
        PR middle-end/81030
        * gcc.dg/pr81030.c: New test.
        * cfgbuild.c (find_many_sub_basic_blocks): Update REG_BR_PROB note
        when gimple level profile disagrees with what RTL expander did.
Index: testsuite/ChangeLog
===================================================================
--- testsuite/ChangeLog (revision 250378)
+++ testsuite/ChangeLog (working copy)
@@ -1,3 +1,8 @@
+2017-07-17  Tom de Vries  <t...@codesourcery.com>
+
+       PR middle-end/81030
+       * gcc.dg/pr81030.c: New test.
+
 2017-07-20  Naveen H.S  <naveen.hurugalaw...@cavium.com>
 
        * gcc.dg/tree-ssa/vrp116.c: New Test.
Index: testsuite/gcc.dg/pr81030.c
===================================================================
--- testsuite/gcc.dg/pr81030.c  (revision 0)
+++ testsuite/gcc.dg/pr81030.c  (working copy)
@@ -0,0 +1,29 @@
+/* { dg-do compile } */
+/* { dg-options "-O1" } */
+
+void __assert_fail (const char *, const char *, unsigned int, const char *);
+
+int a, b, c, d, e, f, h;
+unsigned char g;
+
+int main ()
+{
+  int i, *j = &b;
+  if (a)
+    {
+      if (h)
+       {
+         int **k = &j;
+         d = 0;
+         *k = &e;
+       }
+      else
+       for (b = 0; b > -28; b = g)
+         ;
+      c || !j ? : __assert_fail ("c || !j", "small.c", 20, "main");
+      if (f)
+       for (i = 0; i < 1; i++)
+         ;
+    }
+  return 0;
+}
Index: ChangeLog
===================================================================
--- ChangeLog   (revision 250378)
+++ ChangeLog   (working copy)
@@ -1,3 +1,10 @@
+2017-07-18  Jan Hubicka  <hubi...@ucw.cz>
+           Tom de Vries  <t...@codesourcery.com>
+
+       PR middle-end/81030
+       * cfgbuild.c (find_many_sub_basic_blocks): Update REG_BR_PROB note
+       when gimple level profile disagrees with what RTL expander did.
+
 2017-07-20  Tom de Vries  <t...@codesourcery.com>
 
        PR tree-optimization/81489
Index: cfgbuild.c
===================================================================
--- cfgbuild.c  (revision 250378)
+++ cfgbuild.c  (working copy)
@@ -673,10 +673,18 @@ find_many_sub_basic_blocks (sbitmap bloc
                     && profile_status_for_fn (cfun) != PROFILE_READ))
              bb->count = profile_count::uninitialized ();
          }
-       else
-         /* If nothing changed, there is no need to create new BBs.  */
-         if (EDGE_COUNT (bb->succs) == n_succs[bb->index])
+       /* If nothing changed, there is no need to create new BBs.  */
+       else if (EDGE_COUNT (bb->succs) == n_succs[bb->index])
+         {
+           /* In rare occassions RTL expansion might have mistakely assigned
+              a probabilities different from what is in CFG.  This happens
+              when we try to split branch to two but optimize out the
+              second branch during the way. See PR81030.  */
+           if (JUMP_P (BB_END (bb)) && any_condjump_p (BB_END (bb))
+               && EDGE_COUNT (bb->succs) >= 2)
+             update_br_prob_note (bb);
            continue;
+         }
 
        compute_outgoing_frequencies (bb);
       }

Reply via email to