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

            Bug ID: 103270
           Summary: [12 regression] gcc.dg/vect/pr96698.c inner loop
                    turned from hot to cold after r12-4526
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: testsuite
          Assignee: unassigned at gcc dot gnu.org
          Reporter: luoxhu at gcc dot gnu.org
  Target Milestone: ---

For the testcase gcc.dg/vect/pr96698.c, the inner loop was hot (preheader count
< loop count), but it is NOT now after r12-4526, bb 3's profile count 354334801
is only 1/2 of the preheader bb 5's profile count 719407024.

But I guess it should be fixed in tree-ssa-loop-ch.c when copy_headers, there
are profile count update there, this case should be handled specially when the
single exit loop only has two bbs and the old header is new exit->src, no need
to scale down the old header profile count to preserve the hotness of the loop.


pr96698.c.138t.lim2:
void test (int a, int * i)
{
  int i__lsm.5;
  int c;
  int b;
  int _22;
  int _23;
  int _24;  <bb 2> [local count: 88915474]:
  if (a_12(D) <= 4)
    goto <bb 7>; [89.00%]
  else
    goto <bb 6>; [11.00%]

  <bb 7> [local count: 79134772]:
  i__lsm.5_11 = *i_16(D);
  goto <bb 5>; [100.00%]

  <bb 9> [local count: 116930484]:

  <bb 3> [local count: 354334801]:
  # b_3 = PHI <b_15(9), 0(5)>
  # c_17 = PHI <b_3(9), 0(5)>
  # i__lsm.5_20 = PHI <i__lsm.5_4(9), i__lsm.5_1(5)>
  _22 = i__lsm.5_20;
  _23 = a_2 & c_17;
  _24 = _22 + _23;
  i__lsm.5_4 = _24;
  b_15 = b_3 + -1;
  if (b_15 != -11)
    goto <bb 9>; [33.00%]
  else
    goto <bb 4>; [67.00%]

  <bb 4> [local count: 719407024]:
  # i__lsm.5_7 = PHI <i__lsm.5_4(3)>
  a_14 = a_2 + 1;
  if (a_14 <= 4)
    goto <bb 8>; [89.00%]
  else
    goto <bb 10>; [11.00%]

  <bb 8> [local count: 640272252]:

  <bb 5> [local count: 719407024]:
  # a_2 = PHI <a_14(8), a_12(D)(7)>
  # i__lsm.5_1 = PHI <i__lsm.5_7(8), i__lsm.5_11(7)>
  goto <bb 3>; [100.00%]

  <bb 10> [local count: 79134772]:
  # i__lsm.5_5 = PHI <i__lsm.5_7(4)>
  *i_16(D) = i__lsm.5_5;

  <bb 6> [local count: 88915474]:
  return;
}

Reply via email to