[Bug tree-optimization/102879] [12 Regression] Dead Code Elimination Regression at -O3

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Mar 10 10:06:34 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102879

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu.org

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Specifically

 ;;   basic block 3, loop depth 1
-;;    pred:       12
+;;    pred:       10
   foo ();
 ;;    succ:       4

...

+;;   basic block 10, loop depth 1
+;;    pred:       7
+;;                8
+  # _51 = PHI <_55(7), _4(8)>
+  _59 = _30 >> _51;
   iftmp.4_60 = (char) _59;
-;;    succ:       12
-
-;;   basic block 12, loop depth 1
-;;    pred:       10
-;;                11
-  # iftmp.4_61 = PHI <_29(10), iftmp.4_60(11)>
-  _62 = (int) iftmp.4_61;
+  _62 = (int) iftmp.4_60;
   d = _62;
   if (_62 == 0)
-    goto <bb 3>; [33.00%]
+    goto <bb 3>; [66.33%]
   else
-    goto <bb 4>; [67.00%]
+    goto <bb 4>; [33.67%]
 ;;    succ:       3
 ;;                4


the wrecking occurs in back_jt_path_registry::duplicate_thread_path via
update_bb_profile_for_threading doing

  else if (!(prob == profile_probability::always ()))
    {
      FOR_EACH_EDGE (c, ei, bb->succs)
        c->probability /= prob;

but taken_edge is the skip edge.  So it seems that this might be OK after
all but we've threaded the "unlikely path", leaving the "likely" one
exposed to the unroller most probable path with now the call to foo ()
more likely executed?!  This is

Checking profitability of path (backwards):  bb:12 (4 insns) bb:10
  Control statement insns: 2
  Overall: 2 insns
  [5] Registering jump thread: (10, 12) incoming edge;  (12, 4) nocopy;
path: 10->12->4 SUCCESS

where the 10->12 has 59% probability and the 10->4 67%

Again not sure why we need to adjust the 12->3/4 probabilities on the
path leading through 10->11?  Sure, we need to adjust the incoming
count into 12 and the counts of 3 and 4 but why adjust probabilities?


More information about the Gcc-bugs mailing list