Given a loop

for (i = 0; i < 100; i++)
  something ();

translated as

L1:
  i_1 = phi (0, i_2)
  if (i_1 > 100)
    goto exit;

L2:
  something ();
  i_2 = i_1 + 1;
  goto L1;

Jump threading in dom1 produces

  i_3 = phi(0);
  goto L2;

L1:
  i_1 = phi(i_2);
  if (i_1 > 100)
    goto exit;

L2:
  i_4 = phi (i_3, i_1)
  something ();
  i_2 = i_4 + 1;
  goto L1;

Since dom does not iterate at -O1, the phi nodes with one argument
(in particular, i_3 = phi(0)) are not removed.  This prevents # of iterations
analysis from determining that the loop iterates a constant number of times,
since it does not handle such phi nodes. Consequently we lose the corresponding
branch predictor for this loop.

-- 
           Summary: Dom jump threading at -O1 confuses branch prediction
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: rakdver at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23622

Reply via email to